Class Index | File Index

Classes


Class ServerConnection


Defined in: protocol.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
ServerConnection encapsulates a websocket connection to the server and all the associated streams.
Field Summary
Field Attributes Field Name and Description
 
The set of all down streams, indexed by their id.
 
The group that we have joined, or null if we haven't joined yet.
 
id
The id of this connection.
 
onchat is called whenever a new chat message is received.
 
onclose is called when the connection is closed
 
onconnected is called when the connection has been established
 
ondownstream is called whenever a new down stream is added.
 
onjoined is called whenever we join or leave a group or whenever the permissions we have in a group change.
 
onuser is called whenever a user in the group changes.
 
onusermessage is called when an application-specific message is received.
 
The permissions granted to this connection.
 
The ICE configuration used by all associated streams.
 
The underlying websocket.
 
up
The set of all up streams, indexed by their id.
 
userdata is a convenient place to attach data to a ServerConnection.
 
The username we joined as.
 
The set of users in this group, including ourself.
Method Summary
Method Attributes Method Name and Description
 
chat(kind, dest, value)
chat sends a chat message to the server.
 
close forcibly closes a server connection.
 
connect(url)
connect connects to the server.
 
findByLocalId(localId)
 
Called when we receive an abort message from the server.
 
gotAnswer(id, sdp)
Called when we receive an answer from the server.
 
Called when we receive a close request from the server.
 
gotOffer(id, label, source, username, sdp, replace)
Called when we receive an offer from the server.
 
gotRemoteIce(id, candidate)
Called when we receive an ICE candidate from the server.
 
Called when we receive a renegotiation request from the server.
 
groupAction(kind, message)
groupAction sends a request to act on the current group.
 
join(group, username, password)
join requests to join a group.
 
leave(group)
leave leaves a group.
 
newUpStream(localId)
newUpStream requests the creation of a new up stream.
 
request(what)
request sets the list of requested tracks
 
send(m)
send sends a message to the server.
 
userAction(kind, dest, value)
userAction sends a request to act on a user.
 
userMessage(kind, dest, value, noecho)
userMessage sends an application-specific message to a user.
Class Detail
ServerConnection()
ServerConnection encapsulates a websocket connection to the server and all the associated streams.
Field Detail
down
The set of all down streams, indexed by their id.

group
The group that we have joined, or null if we haven't joined yet.

id
The id of this connection.

onchat
onchat is called whenever a new chat message is received.

onclose
onclose is called when the connection is closed

onconnected
onconnected is called when the connection has been established

ondownstream
ondownstream is called whenever a new down stream is added. It should set up the stream's callbacks; actually setting up the UI should be done in the stream's ondowntrack callback.

onjoined
onjoined is called whenever we join or leave a group or whenever the permissions we have in a group change. kind is one of 'join', 'fail', 'change' or 'leave'.

onuser
onuser is called whenever a user in the group changes. The users array has already been updated.

onusermessage
onusermessage is called when an application-specific message is received. Id is null when the message originated at the server, a user-id otherwise. 'kind' is typically one of 'error', 'warning', 'info' or 'mute'. If 'id' is non-null, 'privileged' indicates whether the message was sent by an operator.

permissions
The permissions granted to this connection.

rtcConfiguration
The ICE configuration used by all associated streams.

socket
The underlying websocket.

up
The set of all up streams, indexed by their id.

userdata
userdata is a convenient place to attach data to a ServerConnection. It is not used by the library.

username
The username we joined as.

users
The set of users in this group, including ourself.
Method Detail
chat(kind, dest, value)
chat sends a chat message to the server. The server will normally echo the message back to the client.
Parameters:
{string} kind
- The kind of message, either '', 'me' or an application-specific type.
{string} dest
- The id to send the message to, empty for broadcast.
{string} value
- The text of the message.

close()
close forcibly closes a server connection. The onclose callback will be called when the connection is effectively closed.

{Promise} connect(url)
connect connects to the server.
Parameters:
{string} url
- The URL to connect to.
Returns:
{Promise}

{Stream} findByLocalId(localId)
Parameters:
{string} localId
Returns:
{Stream}

gotAbort(id)
Called when we receive an abort message from the server. Don't call this.
Parameters:
{string} id

gotAnswer(id, sdp)
Called when we receive an answer from the server. Don't call this.
Parameters:
{string} id
{string} sdp

gotClose(id)
Called when we receive a close request from the server. Don't call this.
Parameters:
{string} id

gotOffer(id, label, source, username, sdp, replace)
Called when we receive an offer from the server. Don't call this.
Parameters:
{string} id
{string} label
{string} source
{string} username
{string} sdp
{string} replace

gotRemoteIce(id, candidate)
Called when we receive an ICE candidate from the server. Don't call this.
Parameters:
{string} id
{RTCIceCandidate} candidate

gotRenegotiate(id)
Called when we receive a renegotiation request from the server. Don't call this.
Parameters:
{string} id

groupAction(kind, message)
groupAction sends a request to act on the current group.
Parameters:
{string} kind
- One of 'clearchat', 'lock', 'unlock', 'record' or 'unrecord'.
{string} message Optional
- An optional user-readable message.

join(group, username, password)
join requests to join a group. The onjoined callback will be called when we've effectively joined.
Parameters:
{string} group
- The name of the group to join.
{string} username
- the username to join as.
{string} password
- the password.

leave(group)
leave leaves a group. The onjoined callback will be called when we've effectively left.
Parameters:
{string} group
- The name of the group to join.

{Stream} newUpStream(localId)
newUpStream requests the creation of a new up stream.
Parameters:
{string} localId Optional
- The local id of the stream to create. If a stream already exists with the same local id, it is replaced with the new stream.
Returns:
{Stream}

request(what)
request sets the list of requested tracks
Parameters:
{Object>} what
- A dictionary that maps labels to a sequence of 'audio', 'video' or 'video-low. An entry with an empty label '' provides the default.

send(m)
send sends a message to the server.
Parameters:
{message} m
- the message to send.

userAction(kind, dest, value)
userAction sends a request to act on a user.
Parameters:
{string} kind
- One of "op", "unop", "kick", "present", "unpresent".
{string} dest
- The id of the user to act upon.
{any} value Optional
- An action-dependent parameter.

userMessage(kind, dest, value, noecho)
userMessage sends an application-specific message to a user. This is similar to a chat message, but is not saved in the chat history.
Parameters:
{string} kind
- The kind of application-specific message.
{string} dest
- The id to send the message to, empty for broadcast.
{unknown} value Optional
- An optional parameter.
{boolean} noecho Optional
- If set, don't echo back the message to the sender.

Documentation generated by JsDoc Toolkit 2.4.0 on Thu Dec 02 2021 00:12:47 GMT+0100 (CET)