CoHostStore provides a comprehensive set of APIs to manage the entire cross-room connection lifecycle.CoHostStore instance. Do not attempt to initialize directly.Property | Type | Description |
coHostStatus | Real-time cross-room connection status. | |
connected | List of hosts currently connected with current live room. | |
invitees | List of hosts to whom requests have been sent. | |
applicant | Host who initiated connection request to current live room. | |
candidatesCursor | ValueListenable<String> | Recommended user list cursor. |
candidates | Recommended user 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. | |
Mute/unmute remote host's audio. | |
Get recommended host list. |
void addCoHostListener(CoHostListener listener);
Parameter | Type | Description |
listener | Listener. |
void removeCoHostListener(CoHostListener listener);
Parameter | Type | Description |
listener | Listener. |
Future<CompletionHandler> requestHostConnection({required String targetHostLiveID,required CoHostLayoutTemplate layoutTemplate,required int timeout,String extraInfo = '',});
Parameter | Type | Description |
targetHostLiveID | String | Target host's live room ID. |
layoutTemplate | Connection layout template. | |
timeout | int | Timeout in seconds. The maximum limit is 30 seconds. |
extraInfo | String? | Extension information. |
Future<CompletionHandler> cancelHostConnection(String toHostLiveID);
Parameter | Type | Description |
toHostLiveID | String | Target host's live room ID. |
Future<CompletionHandler> acceptHostConnection(String fromHostLiveID);
Parameter | Type | Description |
fromHostLiveID | String | Live room ID of the host initiating connection request. |
Future<CompletionHandler> rejectHostConnection(String fromHostLiveID);
Parameter | Type | Description |
fromHostLiveID | String | Live room ID of the host initiating connection request. |
Future<CompletionHandler> exitHostConnection();
Future<CompletionHandler> muteRemoteHostAudio({required String liveID,required bool isMuted,});
Parameter | Type | Description |
liveID | String | Live ID of the remote host. |
isMuted | bool | Whether to mute the remote host's audio. true means mute, false means unmute. |
Future<CompletionHandler> getCoHostCandidates(String cursor);
Parameter | Type | Description |
cursor | String | Cursor. |
Enum Value | Value | Description |
connected | 0 | Currently connected with other hosts. |
disconnected | 1 | Not connected with other hosts. |
Enum Value | Value | Description |
hostVoiceConnection | 2 | Voice chat room connection layout. |
hostVideoLandscapeFixed2Seats | 400 | Host video landscape fixed 2 seats layout. |
hostDynamicGrid | 600 | Host dynamic grid layout. |
hostDynamic1v6 | 601 | Host dynamic 1v6 layout. |
hostVideoLeftFocus9Seats | 602 | Host video left focus 9 seats layout. |
hostVideoUniformGrid9Seats | 603 | Host video uniform grid 9 seats layout. |
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. |
Property | Type | Description |
coHostStatus | Real-time cross-room connection status. | |
connected | List of hosts currently connected with current live room. | |
invitees | List of hosts to whom requests have been sent. | |
applicant | Host who initiated connection request to current live room. | |
candidatesCursor | ValueListenable<String> | Recommended user list cursor. |
candidates | Recommended user list. |
// Create store instancefinal store = CoHostStore.create('live_room_123');// Define listenerslate 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 changesstore.coHostState.coHostStatus.addListener(statusListener);store.coHostState.connected.addListener(connectedListener);// Add connection event listenerfinal 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 requestfinal 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 donestore.coHostState.coHostStatus.removeListener(statusListener);store.coHostState.connected.removeListener(connectedListener);store.removeCoHostListener(coHostListener);
フィードバック