Class Index | File Index

Classes


Methods

Fields

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.
join requests to join a group.
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.
onfiletransfer is called whenever a peer offers a file transfer.
onjoined is called whenever we join or leave a group or whenever the permissions we have in a group change.
onpeerconnection is called before we establish a new peer connection.
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.
The set of files currently being transferred.
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.
The negotiated protocol version.
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.
{Promise}
connect(url)
connect connects to the server.
fileTransfer(id, username, message)
fileTransfer handles a usermessage of kind 'filetransfer'.
findByLocalId(localId)
findByLocalId finds an active connection with the given localId.
{RTCConfiguration}
getRTCConfiguration returns the RTCConfiguration that should be used with this peer connection.
getTransferredFile(userid, fileid, up)
Retrieve a transferred file from the transferredFiles dictionary.
gotAbort is called when we receive an abort message from the server.
gotAnswer(id, sdp)
gotAnswer is called when we receive an answer from the server.
gotClose is called when we receive a close request from the server.
gotOffer(id, label, source, username, sdp, replace)
gotOffer is called when we receive an offer from the server.
gotRemoteIce(id, candidate)
gotRemoteIce is called when we receive an ICE candidate from the server.
gotRenegotiate is called when we receive a renegotiation request from the server.
groupAction(kind, data)
groupAction sends a request to act on the current 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.
sendFile(id, file)
Initiate a file upload.
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.

join
join requests to join a group. The onjoined callback will be called when we've effectively joined.

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.

onfiletransfer
onfiletransfer is called whenever a peer offers a file transfer. If the transfer is accepted, it should set up the file transfer callbacks and return immediately. It may also throw an exception in order to reject the file transfer.

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'.

onpeerconnection
onpeerconnection is called before we establish a new peer connection. It may either return null, or a new RTCConfiguration that overrides the value obtained from the server.

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.

transferredFiles
The set of files currently being transferred.

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.

version
The negotiated protocol version.
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}

fileTransfer(id, username, message)
fileTransfer handles a usermessage of kind 'filetransfer'. Don't call this, it is called automatically as needed.
Parameters:
{string} id
{string} username
{object} message

{Stream} findByLocalId(localId)
findByLocalId finds an active connection with the given localId. It returns null if none was find.
Parameters:
{string} localId
Returns:
{Stream}

{RTCConfiguration} getRTCConfiguration()
getRTCConfiguration returns the RTCConfiguration that should be used with this peer connection. This usually comes from the server, but may be overridden by the onpeerconnection callback.
Returns:
{RTCConfiguration}

{TransferredFile} getTransferredFile(userid, fileid, up)
Retrieve a transferred file from the transferredFiles dictionary.
Parameters:
{string} userid
{string} fileid
{boolean} up
Returns:
{TransferredFile}

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

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

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

gotOffer(id, label, source, username, sdp, replace)
gotOffer is 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)
gotRemoteIce is called when we receive an ICE candidate from the server. Don't call this.
Parameters:
{string} id
{RTCIceCandidate} candidate

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

groupAction(kind, data)
groupAction sends a request to act on the current group.
Parameters:
{string} kind
{any} data Optional

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.

sendFile(id, file)
Initiate a file upload. This will cause the onfiletransfer callback to be called, at which point you should set up the onevent callback.
Parameters:
{string} id
{File} file

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 May 02 2024 23:17:14 GMT+0200 (Central European Summer Time)