rtc.signaling.MucSignaling Class
Signaling for multi user chats
The following messages are sent to the server:
// join the room. has to be sent before any other message.
// response will be 'joined' on success
// other peers in the room will get 'peer_joined'
{
"type": "join",
"status": { .. status .. }
}
// leave the room. server will close the connectino.
{
"type": "leave"
}
// update status object
// other peers will get 'peer_status'
{
"type": "status",
"status": { .. status .. }
}
// send message to a peer. will be received as 'from'
{
"type": "to",
"peer": "peer_id",
"event": "event_id",
"data": { .. custom data .. }
}
The following messages are received form the server:
// joined the room. is the response to 'join'
{
"type": "joined",
"id": "own_id",
"peers": {
"peer_id": { .. status .. }
}
}
// another peer joined the room.
{
"type": "peer_joined",
"peer": "peer_id",
"status": { .. status .. }
}
// anosther peer updated its status object using 'status'
{
"type": "peer_status",
"peer": "peer_id",
"status": { .. status .. }
}
// another peer left the room
{
"type": "peer_left",
"peer": "peer_id"
}
// message from another peer sent by 'to'
{
"type": "from",
"peer": "peer_id",
"event": "event_id",
"data": { .. custom data .. }
}
The messages transmitted in the to
/from
messages are emitted as events in MucSignalingPeer
Constructor
rtc.signaling.MucSignaling
(
-
channel
Parameters:
-
channel
rtc.signaling.ChannelThe channel to the signaling server
Methods
close
()
Closes the connection to the signaling server
connect
()
Promise
Establishes the connection with the signaling server
Returns:
Promise:
Promise which is resolved when the connection is established
setStatus
(
-
obj
Sets the local status object and broadcasts the change to the peers
Parameters:
-
obj
ObjectNew status object
Properties
id
String
The id of the local peer. Only available after joining.
Events
closed
()
The connection to the signaling server was closed
peer_joined
(
-
peer
A new peer joined the room
Parameters:
-
peer
rtc.signaling.SignalingPeerThe new peer