Table of Contents
Join a Room with Stream
Connecting and joining a Room is a complex chain of events. You will need to ensure success status of previous event to proceed to the next event. The following basic steps are required to join room successfully
- Initiate Room & Connect
- If connected, initiate Stream.
- Publish Stream
joinRoom() method comes as a handy tool for developer. It handles all complexities of connecting and joining the room.
Method: static Future<void> joinRoom(String token, Map<String, dynamic> localInfo, Map<String, dynamic> roomInfo, List<dynamic> advanceOptions)
Parameters:
@param String token– JWT Token received through Video API Call@param Map<String,dynamic> locfo– Stream Initialization Meta Info. Optional.@param Map<String,dynamic> roomInfo– Room info for joining room
Event Listeners:
onRoomConnected– When Client End Point is connected to the room successfullyonRoomDisConnected– Client End Point got disconnected to the roomonRoomError– Client End Point’s attempt to connect to room has failedonUserConnected– Everyone is notified that a new user is connected to the RoomonUserDisConnected– Everyone is notified that a connected user is disconnected from the RoomonConnectionLost– When End Point looses network connectiononConnectionInterrupted– When connection is interrupted e.g Switch from WiFi to 4G and vice versaonUserReconnectSuccess– When End-Point successfully gets reconnected with the portalonReconnect– When End-Point trying to reconnect within given time periodonPublishedStream– Publisher is notified that its Stream has been published into the RoomonUnPublishedStream– Publisher is notified that its Stream is unpublished/removed from the Room
//Map<String, dynamic>: where localInfo is like below:
Map<String, dynamic> localInfo= {
'audio': true,
'video': true,
'data': true,
'audioMuted': false,
'videoMuted': false,
'name': 'flutter',
};
//Map<String, dynamic>: where roomInfo is like below:
Map<String, dynamic> roomInfo = {
'allow_reconnect': true,
'number_of_attempts': 3,
'timeout_interval': 20,
'audio_only': false,
'forceTurn': false
};
//Method calling
await EnxRtc.joinRoom(token, localInfo, roomInfo, advanceOptions);
//Callbacks
EnxRtc.onRoomConnected = (Map<dynamic, dynamic> map) {
//Connection success
};
EnxRtc.onRoomError = (Map<dynamic, dynamic> map) {
// Connection Failed or any error in room
};
EnxRtc.onRoomDisConnected = (Map<dynamic, dynamic> map) {
// Called when room is disconnected success
};
EnxRtc.onConnectionLost = (Map<dynamic, dynamic> map) {
// In case connection lost due to internet lose
};
EnxRtc.onConnectionInterrupted = (Map<dynamic, dynamic> map) {
// In case any interruption in connection
};
EnxRtc.onUserReconnectSuccess = (Map<dynamic, dynamic> map) {
// When reconnect done successfully
};
EnxRtc.onReconnect = (Map<dynamic, dynamic> map) {
};
Disconnect from a Room
A Client End Point can disconnect itself from the room to close its session. A disconnected End-Point will loose media and signaling socket immediately.
Method: static Flutter<void> disconnect() – Without any parameter
EnxRtc.disconnect();
