tencent cloud

Tencent Real-Time Communication

소식 및 공지 사항
제품 업데이트
Tencent Cloud 오디오/비디오 단말 SDK 재생 업그레이드 및 권한 부여 인증 추가
TRTC 월간 구독 패키지 출시 관련 안내
제품 소개
제품 개요
기본 개념
제품 기능
제품 장점
응용 시나리오
성능 데이터
구매 가이드
Billing Overview
무료 시간 안내
Monthly subscription
Pay-as-you-go
TRTC Overdue and Suspension Policy
과금 FAQ
Refund Instructions
신규 사용자 가이드
Demo 체험
Call
개요(TUICallKit)
Activate the Service
Run Demo
빠른 통합(TUICallKit)
오프라인 푸시
Conversational Chat
온클라우드 녹화(TUICallKit)
AI Noise Reduction
UI 사용자 정의
Calls integration to Chat
Additional Features
No UI Integration
Server APIs
Client APIs
Solution
ErrorCode
릴리스 노트
FAQs
라이브 스트리밍
Billing of Video Live Component
Overview
Activating the Service (TUILiveKit)
Demo 실행
No UI Integration
UI Customization
Live Broadcast Monitoring
Video Live Streaming
Voice Chat Room
Advanced Features
Client APIs
Server APIs
Error Codes
Release Notes
FAQs
RTC Engine
Activate Service
SDK 다운로드
API 코드 예시
Usage Guidelines
API 클라이언트 API
고급 기능
RTC RESTFUL API
History
Introduction
API Category
Room Management APIs
Stream mixing and relay APIs
On-cloud recording APIs
Data Monitoring APIs
Pull stream Relay Related interface
Web Record APIs
AI Service APIs
Cloud Slicing APIs
Cloud Moderation APIs
Making API Requests
Call Quality Monitoring APIs
Usage Statistics APIs
Data Types
Appendix
Error Codes
콘솔 가이드
애플리케이션 관리
사용량 통계
모니터링 대시보드
개발 보조
Solution
Real-Time Chorus
FAQs
과금 개요
기능 관련
UserSig 관련
방화벽 제한 처리
설치 패키지 용량 축소 관련 질문
Andriod 및 iOS 관련
Web 관련
Flutter 관련
Electron 관련
TRTCCalling Web 관련
멀티미디어 품질 관련
기타 질문
Protocols and Policies
컴플라이언스 인증
보안 백서
정보 보안에 관한 참고 사항
Service Level Agreement
Apple Privacy Policy: PrivacyInfo.xcprivacy
TRTC 정책
개인 정보 보호 정책
데이터 처리 및 보안 계약
용어집

CoHostStore

PDF
포커스 모드
폰트 크기
마지막 업데이트 시간: 2026-03-05 16:32:08

Introduction

Cross-room connection feature allows hosts from different live rooms to interact in real-time. CoHostStore provides a comprehensive set of APIs to manage the entire cross-room connection lifecycle.
Important:
Always use the factory method CoHostStore.create with a valid live room ID to create a CoHostStore instance. Do not attempt to initialize directly.
Note:
Connection state updates are delivered through the coHostState publisher. Subscribe to it to receive real-time updates about connection status, connected hosts, invitations and applications.
Warning:
If a connection request does not receive a response within the specified timeout, the timeout event will be triggered. Always handle timeout scenarios in your UI.

Features

Bidirectional Connection:Hosts can initiate connection requests to other hosts, and also receive connection requests from other hosts
State Management:Real-time tracking of connection status, connected hosts, invitation list and applicants
Event-Driven Architecture:Provides connection event stream for monitoring various connection state changes
Layout Templates:Supports multiple connection layout templates, such as dynamic grid layout and 1-to-6 layout

Subscribable Data

CoHostState fields are described below:
Property
Type
Description
coHostStatus
ValueListenable<CoHostStatus>
Real-time cross-room connection status.
connected
ValueListenable<List<SeatUserInfo>>
List of hosts currently connected with current live room.
invitees
ValueListenable<List<SeatUserInfo>>
List of hosts to whom requests have been sent.
applicant
ValueListenable<SeatUserInfo?>
Host who initiated connection request to current live room.
candidatesCursor
ValueListenable<String>
Recommended user list cursor.
candidates
ValueListenable<List<SeatUserInfo>>
Recommended user list.

API List

Function
Description
Create object instance.
Connection event callbacks.
Connection event callbacks.
Initiate connection request.
Cancel connection request.
Accept connection request.
Reject connection request.
Exit connection.
Get recommended host list.

Creating Instance

CoHostStore.create

Create object instance

Observing State and Events

addCoHostListener

Add connection callback listener
void addCoHostListener(CoHostListener listener);
Version
Supported since version 3.5.
Parameters
Parameter
Type
Required
Description
listener
Required
Listener.

removeCoHostListener

Remove connection callback listener
void removeCoHostListener(CoHostListener listener);
Version
Supported since version 3.5.
Parameters
Parameter
Type
Required
Description
listener
Required
Listener.

Connection Operations

requestHostConnection

Initiate host connection request
Future<CompletionHandler> requestHostConnection({
required String targetHostLiveID,
required CoHostLayoutTemplate layoutTemplate,
required int timeout,
String extraInfo = '',
});
Initiate a cross-room connection request to target host. After calling this method, a connection request is sent to the target host. The request will remain active until: • Target host accepts via acceptHostConnection(fromHostLiveID:completion:) • Target host rejects via rejectHostConnection(fromHostLiveID:completion:) • Timeout expires • You cancel via cancelHostConnection(toHostLiveID:completion:)
Version
Supported since version 3.5.
Parameters
Parameter
Type
Required
Description
targetHostLiveID
String
Required
Target host's live room ID.
layoutTemplate
Required
Connection layout template.
timeout
int
Required
Request timeout (unit: seconds).
extraInfo
String?
Required
Extension information.

cancelHostConnection

Cancel host connection request
Future<CompletionHandler> cancelHostConnection(String toHostLiveID);
Version
Supported since version 3.5.
Parameters
Parameter
Type
Required
Description
toHostLiveID
String
Required
Target host's live room ID.

acceptHostConnection

Accept host connection request
Future<CompletionHandler> acceptHostConnection(String fromHostLiveID);
Version
Supported since version 3.5.
Parameters
Parameter
Type
Required
Description
fromHostLiveID
String
Required
Live room ID of the host initiating connection request.

rejectHostConnection

Reject host connection request
Future<CompletionHandler> rejectHostConnection(String fromHostLiveID);
Version
Supported since version 3.5.
Parameters
Parameter
Type
Required
Description
fromHostLiveID
String
Required
Live room ID of the host initiating connection request.

exitHostConnection

Exit host connection
Future<CompletionHandler> exitHostConnection();
Version
Supported since version 3.5.

getCoHostCandidates

Get recommended host list that can connect with current host
Future<CompletionHandler> getCoHostCandidates(String cursor);
Version
Supported since version 3.5.
Parameters
Parameter
Type
Required
Description
cursor
String
Required
Cursor.

Data Structures

CoHostStatus

Current user's cross-room connection status
Enum Value
Value
Description
connected
0
Currently connected with other hosts.
disconnected
1
Not connected with other hosts.

CoHostLayoutTemplate

Connection layout template
Enum Value
Value
Description
hostVoiceConnection
2
Voice chat room connection layout.
hostDynamicGrid
600
Host dynamic grid layout.
hostDynamic1v6
601
Host dynamic 1v6 layout.

CoHostListener

Connection request callback events
Methods
Method
Description
onCoHostRequestReceived
This callback is triggered when a connection request is received.
onCoHostRequestCancelled
This callback is triggered when a connection request is cancelled.
onCoHostRequestAccepted
This callback is triggered when a connection request is accepted.
onCoHostRequestRejected
This callback is triggered when a connection request is rejected.
onCoHostRequestTimeout
This callback is triggered when a connection request times out.
onCoHostUserJoined
This callback is triggered when a user joins the connection.
onCoHostUserLeft
This callback is triggered when a user leaves the connection.

CoHostState

Cross-room connection related state data provided externally by CoHostStore
Property
Type
Description
coHostStatus
ValueListenable<CoHostStatus>
Real-time cross-room connection status.
connected
ValueListenable<List<SeatUserInfo>>
List of hosts currently connected with current live room.
invitees
ValueListenable<List<SeatUserInfo>>
List of hosts to whom requests have been sent.
applicant
ValueListenable<SeatUserInfo?>
Host who initiated connection request to current live room.
candidatesCursor
ValueListenable<String>
Recommended user list cursor.
candidates
ValueListenable<List<SeatUserInfo>>
Recommended user list.

Usage Example

// Create store instance
final store = CoHostStore.create('live_room_123');

// Define listeners
late final VoidCallback statusListener = _onStatusChanged;
late final VoidCallback connectedListener = _onConnectedChanged;

void _onStatusChanged() {
print('Connection status: ${store.coHostState.coHostStatus.value}');
}

void _onConnectedChanged() {
print('Connected hosts: ${store.coHostState.connected.value.length}');
}

// Subscribe to state changes
store.coHostState.coHostStatus.addListener(statusListener);
store.coHostState.connected.addListener(connectedListener);

// Add connection event listener
final coHostListener = CoHostListener(
onCoHostRequestReceived: (inviter, extensionInfo) {
print('Received connection request from ${inviter.userName}');
// Show accept/reject UI
},
onCoHostRequestAccepted: (invitee) {
print('Connection request accepted by ${invitee.userName}');
},
onCoHostUserJoined: (userInfo) {
print('Host ${userInfo.userName} joined connection');
},
);
store.addCoHostListener(coHostListener);

// Initiate connection request
final result = await store.requestHostConnection(
targetHostLiveID: 'target_live_id',
layoutTemplate: CoHostLayoutTemplate.hostDynamicGrid,
timeout: 30,
extraInfo: '',
);
if (result.code == 0) {
print('Connection request sent successfully');
}

// Unsubscribe when done
store.coHostState.coHostStatus.removeListener(statusListener);
store.coHostState.connected.removeListener(connectedListener);
store.removeCoHostListener(coHostListener);

도움말 및 지원

문제 해결에 도움이 되었나요?

피드백