respoke.Endpoint
from respoke/endpoint.jsExtends
respoke.EventEmitterDescription
respoke.Endpoint
s are users of a Respoke app.
An Endpoint can be a person in a browser or device, or an app using Respoke APIs from a server.
A Client can interact with endpoints through messages, audio or video calls, or direct connections.
An Endpoint may be authenticated from multiple devices to the same app (each of which is
represented by a Connection).
Usage
var jim = client.getEndpoint({ id: 'jim' });
groupConnectionCount
Type
number
Description
The number this endpoint's connections that are joined to groups. So if
an endpoint has 3 connections in the same group, the
groupConnectionCount
for that endpoint would be 3.
directConnection
Type
respoke.DirectConnection
Description
A direct connection to this endpoint. This can be used to send direct messages.
connections
Type
Array<respoke.Connection>
Description
Array of connections for this endpoint.
presence
Type
string|number|object|Array
Description
Represents the presence status. Typically a string, but other types are supported.
Defaults to 'unavailable'
.
Usage
Do not modify this directly - it won't update presence with Respoke. Presence must be updated by the remote endpoint.
getPresence()
Description
Deprecated: use endpoint.presence instead.
Usage
Return the presence.
sendMessage(params)
Description
Send a message to the endpoint through the infrastructure.
Usage
endpoint.sendMessage({
message: "wassuuuuup"
});
Using callbacks will disable promises.
Returns
{Promise|undefined}
Arguments
Name | Type | Description |
---|---|---|
params | object | |
params.message | string | |
params.connectionId | string | |
params.ccSelf=true | boolean | Copy this client's own endpoint on this message so that they arrive at other devices it might be logged into elsewhere. |
params.push=false | boolean | Whether or not to consider the message for push notifications to mobile devices. |
params.onSuccess | respoke.Client.successHandler | Success handler for this invocation of this method only. |
params.onError | respoke.Client.errorHandler | Error handler for this invocation of this method only. |
startAudioCall(params)
Description
Create a new audio-only call.
Usage
endpoint.startAudioCall({
onConnect: function (evt) {}
});
Returns
{respoke.Call}
Arguments
Name | Type | Description |
---|---|---|
params | object | |
params.onError | respoke.Call.onError | Callback for errors that happen during call setup or media renegotiation. |
params.onLocalMedia | respoke.Call.onLocalMedia | Callback for receiving an HTML5 Video element with the local audio and/or video attached. |
params.onConnect | respoke.Call.onConnect | Callback for receiving an HTML5 Video element with the remote audio and/or video attached. |
params.onHangup | respoke.Call.onHangup | Callback for being notified when the call has been hung up. |
params.onAllow | respoke.Call.onAllow | When setting up a call, receive notification that the browser has granted access to media. |
params.onMute | respoke.Call.onMute | Callback for changing the mute state on any type of media. This callback will be called when media is muted or unmuted. |
params.onAnswer | respoke.Call.onAnswer | Callback for when the callee answers the call. |
params.onApprove | respoke.Call.onApprove | Callback for when the user approves local media. This callback will be called whether or not the approval was based on user feedback. I. e., it will be called even if the approval was automatic. |
params.onRemoteMedia | respoke.Call.onRemoteMedia | Callback called every time a remote stream is added to the call. Corresponds to 'remote-stream-received' event. |
params.onRequestingMedia | respoke.Call.onRequestingMedia | Callback for when the app is waiting for the user to give permission to start getting audio or video. |
params.onStats | respoke.MediaStatsParser.statsHandler | Callback for receiving statistical information. |
params.previewLocalMedia | respoke.Call.previewLocalMedia | A function to call if the developer wants to perform an action between local media becoming available and calling approve(). |
params.receiveOnly | boolean | whether or not we accept media |
params.sendOnly | boolean | whether or not we send media |
params.needDirectConnection | boolean | flag to enable skipping media & opening direct connection. |
params.forceTurn | boolean | If true, media is not allowed to flow peer-to-peer and must flow through relay servers. If it cannot flow through relay servers, the call will fail. |
params.disableTurn | boolean | If true, media is not allowed to flow through relay servers; it is required to flow peer-to-peer. If it cannot, the call will fail. |
params.connectionId | string | The connection ID of the remoteEndpoint, if it is not desired to call all connections belonging to this endpoint. |
params.metadata | * | Metadata to be attached to the audio call, accessible by the callee. |
startVideoCall(params)
Description
Create a new call with audio and video.
Usage
endpoint.startVideoCall({
onConnect: function (evt) {}
});
Returns
{respoke.Call}
Arguments
Name | Type | Description |
---|---|---|
params | object | |
params.onError | respoke.Call.onError | Callback for errors that happen during call setup or media renegotiation. |
params.onLocalMedia | respoke.Call.onLocalMedia | Callback for receiving an HTML5 Video element with the local audio and/or video attached. |
params.onConnect | respoke.Call.onConnect | Callback for receiving an HTML5 Video element with the remote audio and/or video attached. |
params.onHangup | respoke.Call.onHangup | Callback for being notified when the call has been hung up. |
params.onAllow | respoke.Call.onAllow | When setting up a call, receive notification that the browser has granted access to media. |
params.onMute | respoke.Call.onMute | Callback for changing the mute state on any type of media. This callback will be called when media is muted or unmuted. |
params.onAnswer | respoke.Call.onAnswer | Callback for when the callee answers the call. |
params.onApprove | respoke.Call.onApprove | Callback for when the user approves local media. This callback will be called whether or not the approval was based on user feedback. I. e., it will be called even if the approval was automatic. |
params.onRemoteMedia | respoke.Call.onRemoteMedia | Callback called every time a remote stream is added to the call. Corresponds to 'remote-stream-received' event. |
params.onRequestingMedia | respoke.Call.onRequestingMedia | Callback for when the app is waiting for the user to give permission to start getting audio or video. |
params.onStats | respoke.MediaStatsParser.statsHandler | Callback for receiving statistical information. |
params.previewLocalMedia | respoke.Call.previewLocalMedia | A function to call if the developer wants to perform an action between local media becoming available and calling approve(). |
params.receiveOnly | boolean | whether or not we accept media |
params.sendOnly | boolean | whether or not we send media |
params.needDirectConnection | boolean | flag to enable skipping media & opening direct connection. |
params.forceTurn | boolean | If true, media is not allowed to flow peer-to-peer and must flow through relay servers. If it cannot flow through relay servers, the call will fail. |
params.disableTurn | boolean | If true, media is not allowed to flow through relay servers; it is required to flow peer-to-peer. If it cannot, the call will fail. |
params.connectionId | string | The connection ID of the remoteEndpoint, if it is not desired to call all connections belonging to this endpoint. |
params.metadata | * | Metadata to be attached to the video call, accessible by the callee. |
startCall(params)
Description
Create a new call.
Usage
endpoint.startCall({
onConnect: function (evt) {}
});
Returns
{respoke.Call}
Arguments
Name | Type | Description |
---|---|---|
params | object | |
params.onError | respoke.Call.onError | Callback for errors that happen during call setup or media renegotiation. |
params.onLocalMedia | respoke.Call.onLocalMedia | Callback for receiving an HTML5 Video element with the local audio and/or video attached. |
params.onConnect | respoke.Call.onConnect | Callback for receiving an HTML5 Video element with the remote audio and/or video attached. |
params.onHangup | respoke.Call.onHangup | Callback for being notified when the call has been hung up. |
params.onAllow | respoke.Call.onAllow | When setting up a call, receive notification that the browser has granted access to media. |
params.onMute | respoke.Call.onMute | Callback for changing the mute state on any type of media. This callback will be called when media is muted or unmuted. |
params.onAnswer | respoke.Call.onAnswer | Callback for when the callee answers the call. |
params.onApprove | respoke.Call.onApprove | Callback for when the user approves local media. This callback will be called whether or not the approval was based on user feedback. I. e., it will be called even if the approval was automatic. |
params.onRemoteMedia | respoke.Call.onRemoteMedia | Callback called every time a remote stream is added to the call. Corresponds to 'remote-stream-received' event. |
params.onRequestingMedia | respoke.Call.onRequestingMedia | Callback for when the app is waiting for the user to give permission to start getting audio or video. |
params.onStats | respoke.MediaStatsParser.statsHandler | Callback for receiving statistical information. |
params.previewLocalMedia | respoke.Call.previewLocalMedia | A function to call if the developer wants to perform an action between local media becoming available and calling approve(). |
params.constraints | Array<RTCConstraints> | |
params.receiveOnly | boolean | whether or not we accept media |
params.sendOnly | boolean | whether or not we send media |
params.needDirectConnection | boolean | flag to enable skipping media & opening direct connection. |
params.forceTurn | boolean | If true, media is not allowed to flow peer-to-peer and must flow through relay servers. If it cannot flow through relay servers, the call will fail. |
params.disableTurn | boolean | If true, media is not allowed to flow through relay servers; it is required to flow peer-to-peer. If it cannot, the call will fail. |
params.connectionId | string | The connection ID of the remoteEndpoint, if it is not desired to call all connections belonging to this endpoint. |
params.videoLocalElement | HTMLVideoElement | Pass in an optional html video element to have local video attached to it. |
params.videoRemoteElement | HTMLVideoElement | Pass in an optional html video element to have remote video attached to it. |
params.metadata | * | Metadata to be attached to the call, accessible by the callee. |
startDirectConnection(params)
Description
Create a new DirectConnection. This method creates a new Call as well, attaching this DirectConnection to it for the purposes of creating a peer-to-peer link for sending data such as messages to the other endpoint. Information sent through a DirectConnection is not handled by the cloud infrastructure. If there is already a direct connection open, this method will resolve the promise with that direct connection instead of attempting to create a new one.
Usage
endpoint.startDirectConnection({
onOpen: function (evt) {}
});
Returns
{Promise<respoke.DirectConnection>} The DirectConnection which can be used to send data and messages
directly to the other endpoint.
Arguments
Name | Type | Description |
---|---|---|
params | object | |
params.onSuccess | respoke.Call.directConnectionSuccessHandler | Success handler for this invocation of this method only. |
params.onError | respoke.Client.errorHandler | Error handler for this invocation of this method only. |
params.onStart | respoke.DirectConnection.onStart | A callback for when setup of the direct connection begins. The direct connection will not be open yet. |
params.onOpen | respoke.DirectConnection.onOpen | A callback for receiving notification of when the DirectConnection is open and ready to be used. |
params.onError | respoke.DirectConnection.onError | Callback for errors setting up the direct connection. |
params.onClose | respoke.DirectConnection.onClose | A callback for receiving notification of when the DirectConnection is closed and the two Endpoints are disconnected. |
params.onAccept | respoke.DirectConnection.onAccept | Callback for when the user accepts the request for a direct connection and setup begins. |
params.onMessage | respoke.DirectConnection.onMessage | A callback for receiving messages sent through the DirectConnection. |
params.connectionId | string | An optional connection ID to use for this connection. This allows the connection to be made to a specific instance of an endpoint in the case that the same endpoint is logged in from multiple locations. |
Events
presence
event
Description
This event indicates that the presence for this endpoint has been updated.
Event Callback Arguments
Name | Type | Description |
---|---|---|
evt.presence | string | |
evt.name | string | the event name. |
evt.target | respoke.Endpoint |