respoke header logorespoke header logo
  • Developers
    • Docs
      • ← Docs

        Full Respoke.js Browser API
      • respoke
      • Call
      • Client
      • Connection
      • DirectConnection
      • Endpoint
        • Properties and Methods
          • groupConnectionCount
          • directConnection
          • connections
          • presence
          • getPresence
          • sendMessage
          • startAudioCall
          • startVideoCall
          • startScreenShare
          • startCall
          • startDirectConnection
        • Events
          • presence
      • EventEmitter
      • Group
      • LocalMedia
      • MediaStats
      • RemoteMedia
    • Forums
    • GitHub
  • Blog
Sign upLog in
respoke header logo
  • ← Docs

    Full Respoke.js Browser API
  • respoke
  • Call
  • Client
  • Connection
  • DirectConnection
  • Endpoint
    • Properties and Methods
      • groupConnectionCount
      • directConnection
      • connections
      • presence
      • getPresence
      • sendMessage
      • startAudioCall
      • startVideoCall
      • startScreenShare
      • startCall
      • startDirectConnection
    • Events
      • presence
  • EventEmitter
  • Group
  • LocalMedia
  • MediaStats
  • RemoteMedia

respoke.Endpoint

from respoke/endpoint.js

Extends

respoke.EventEmitter

Description

respoke.Endpoints 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

NameTypeDescription
paramsobject
params.messagestring
params.connectionIdstring
params.ccSelf=truebooleanCopy this client's own endpoint on this message so that they arrive at other devices it might be logged into elsewhere.
params.push=falsebooleanWhether or not to consider the message for push notifications to mobile devices.
params.onSuccessrespoke.Client.successHandlerSuccess handler for this invocation of this method only.
params.onErrorrespoke.Client.errorHandlerError 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

NameTypeDescription
paramsobject
params.onErrorrespoke.Call.onErrorCallback for errors that happen during call setup or media renegotiation.
params.onLocalMediarespoke.Call.onLocalMediaCallback for receiving an HTML5 Video element with the local audio and/or video attached.
params.onConnectrespoke.Call.onConnectCallback for receiving an HTML5 Video element with the remote audio and/or video attached.
params.onHanguprespoke.Call.onHangupCallback for being notified when the call has been hung up.
params.onAllowrespoke.Call.onAllowWhen setting up a call, receive notification that the browser has granted access to media.
params.onMuterespoke.Call.onMuteCallback for changing the mute state on any type of media. This callback will be called when media is muted or unmuted.
params.onAnswerrespoke.Call.onAnswerCallback for when the callee answers the call.
params.onApproverespoke.Call.onApproveCallback 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.onRemoteMediarespoke.Call.onRemoteMediaCallback called every time a remote stream is added to the call. Corresponds to 'remote-stream-received' event.
params.onRequestingMediarespoke.Call.onRequestingMediaCallback for when the app is waiting for the user to give permission to start getting audio or video.
params.onStatsrespoke.MediaStatsParser.statsHandlerCallback for receiving statistical information.
params.previewLocalMediarespoke.Call.previewLocalMediaA function to call if the developer wants to perform an action between local media becoming available and calling approve().
params.receiveOnlybooleanwhether or not we accept media
params.sendOnlybooleanwhether or not we send media
params.needDirectConnectionbooleanflag to enable skipping media & opening direct connection.
params.forceTurnbooleanIf 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.disableTurnbooleanIf 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.connectionIdstringThe 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

NameTypeDescription
paramsobject
params.onErrorrespoke.Call.onErrorCallback for errors that happen during call setup or media renegotiation.
params.onLocalMediarespoke.Call.onLocalMediaCallback for receiving an HTML5 Video element with the local audio and/or video attached.
params.onConnectrespoke.Call.onConnectCallback for receiving an HTML5 Video element with the remote audio and/or video attached.
params.onHanguprespoke.Call.onHangupCallback for being notified when the call has been hung up.
params.onAllowrespoke.Call.onAllowWhen setting up a call, receive notification that the browser has granted access to media.
params.onMuterespoke.Call.onMuteCallback for changing the mute state on any type of media. This callback will be called when media is muted or unmuted.
params.onAnswerrespoke.Call.onAnswerCallback for when the callee answers the call.
params.onApproverespoke.Call.onApproveCallback 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.onRemoteMediarespoke.Call.onRemoteMediaCallback called every time a remote stream is added to the call. Corresponds to 'remote-stream-received' event.
params.onRequestingMediarespoke.Call.onRequestingMediaCallback for when the app is waiting for the user to give permission to start getting audio or video.
params.onStatsrespoke.MediaStatsParser.statsHandlerCallback for receiving statistical information.
params.previewLocalMediarespoke.Call.previewLocalMediaA function to call if the developer wants to perform an action between local media becoming available and calling approve().
params.receiveOnlybooleanwhether or not we accept media
params.sendOnlybooleanwhether or not we send media
params.needDirectConnectionbooleanflag to enable skipping media & opening direct connection.
params.forceTurnbooleanIf 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.disableTurnbooleanIf 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.connectionIdstringThe 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.

startScreenShare(params)

Description

The endpoint who calls endpoint.startScreenShare will be the one whose screen is shared. If you'd like to implement this as a screenshare request in which the endpoint who starts the call is the watcher and not the sharer, it is recommended that you use endpoint.sendMessage to send a control message to the user whose screenshare is being requested so that user's app can call endpoint.startScreenShare.

Usage

By default, the call will be one-way screen share only, with the recipient sending nothing. To turn it into a bidirectional call with the recipient sending video and both parties sending audio, set params.sendOnly to false.

NOTE: At this time, screen sharing only works with Chrome and Firefox, and both require browser extensions to access screen sharing features. Please see instructions at https://github.com/respoke/respoke-chrome-extension and https://github.com/respoke/respoke-firefox-screen-sharing-extension.

endpoint.startScreenShare({
    onConnect: function (evt) {}
});

Returns

{respoke.Call}

Arguments

NameTypeDescription
paramsobject
params.onErrorrespoke.Call.onErrorCallback for errors that happen during call setup or media renegotiation.
params.onLocalMediarespoke.Call.onLocalMediaCallback for receiving an HTML5 Video element with the local audio and/or video attached.
params.onConnectrespoke.Call.onConnectCallback for when the screenshare is connected and the remote party has received the video.
params.onHanguprespoke.Call.onHangupCallback for being notified when the call has been hung up.
params.onAllowrespoke.Call.onAllowWhen setting up a call, receive notification that the browser has granted access to media.
params.onAnswerrespoke.Call.onAnswerCallback for when the callee answers the call.
params.onApproverespoke.Call.onApproveCallback 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.onRemoteMediarespoke.Call.onRemoteMediaCallback called every time a remote stream is added to the call. Corresponds to 'remote-stream-received' event.
params.onRequestingMediarespoke.Call.onRequestingMediaCallback for when the app is waiting for the user to give permission to start getting audio or video.
params.onStatsrespoke.MediaStatsParser.statsHandlerCallback for receiving statistical information.
params.constraintsArray<RTCConstraints>Additional media to add to the call.
params.screenConstraintsRTCConstraintsOverrides for the screen media.
params.sendOnly=truebooleanWhether the call should be unidirectional.
params.forceTurnbooleanIf 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.disableTurnbooleanIf 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.connectionIdstringThe connection ID of the remoteEndpoint, if it is not desired to call all connections belonging to this endpoint.
params.sourcestringPass in what type of mediaSource you want. If omitted, you'll have access to both the screen and windows. In firefox, you'll have access to the screen only.
params.metadata*Metadata to be attached to the screenShare, accessible by the callee.

startCall(params)

Description

Create a new call.

Usage

endpoint.startCall({
    onConnect: function (evt) {}
});

Returns

{respoke.Call}

Arguments

NameTypeDescription
paramsobject
params.onErrorrespoke.Call.onErrorCallback for errors that happen during call setup or media renegotiation.
params.onLocalMediarespoke.Call.onLocalMediaCallback for receiving an HTML5 Video element with the local audio and/or video attached.
params.onConnectrespoke.Call.onConnectCallback for receiving an HTML5 Video element with the remote audio and/or video attached.
params.onHanguprespoke.Call.onHangupCallback for being notified when the call has been hung up.
params.onAllowrespoke.Call.onAllowWhen setting up a call, receive notification that the browser has granted access to media.
params.onMuterespoke.Call.onMuteCallback for changing the mute state on any type of media. This callback will be called when media is muted or unmuted.
params.onAnswerrespoke.Call.onAnswerCallback for when the callee answers the call.
params.onApproverespoke.Call.onApproveCallback 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.onRemoteMediarespoke.Call.onRemoteMediaCallback called every time a remote stream is added to the call. Corresponds to 'remote-stream-received' event.
params.onRequestingMediarespoke.Call.onRequestingMediaCallback for when the app is waiting for the user to give permission to start getting audio or video.
params.onStatsrespoke.MediaStatsParser.statsHandlerCallback for receiving statistical information.
params.previewLocalMediarespoke.Call.previewLocalMediaA function to call if the developer wants to perform an action between local media becoming available and calling approve().
params.constraintsArray<RTCConstraints>
params.receiveOnlybooleanwhether or not we accept media
params.sendOnlybooleanwhether or not we send media
params.needDirectConnectionbooleanflag to enable skipping media & opening direct connection.
params.forceTurnbooleanIf 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.disableTurnbooleanIf 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.connectionIdstringThe connection ID of the remoteEndpoint, if it is not desired to call all connections belonging to this endpoint.
params.videoLocalElementHTMLVideoElementPass in an optional html video element to have local video attached to it.
params.videoRemoteElementHTMLVideoElementPass 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

NameTypeDescription
paramsobject
params.onSuccessrespoke.Call.directConnectionSuccessHandlerSuccess handler for this invocation of this method only.
params.onErrorrespoke.Client.errorHandlerError handler for this invocation of this method only.
params.onStartrespoke.DirectConnection.onStartA callback for when setup of the direct connection begins. The direct connection will not be open yet.
params.onOpenrespoke.DirectConnection.onOpenA callback for receiving notification of when the DirectConnection is open and ready to be used.
params.onErrorrespoke.DirectConnection.onErrorCallback for errors setting up the direct connection.
params.onCloserespoke.DirectConnection.onCloseA callback for receiving notification of when the DirectConnection is closed and the two Endpoints are disconnected.
params.onAcceptrespoke.DirectConnection.onAcceptCallback for when the user accepts the request for a direct connection and setup begins.
params.onMessagerespoke.DirectConnection.onMessageA callback for receiving messages sent through the DirectConnection.
params.connectionIdstringAn 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

NameTypeDescription
evt.presencestring
evt.namestringthe event name.
evt.targetrespoke.Endpoint
respoke logodigium logo
Site
Home
Pricing
Features
Request Access
Developers
Quickstart
Documentation
Forums
GitHub
Connect
Twitter
Google+
Facebook
Linkedin
Copyright © 2016 Digium, Inc.
Terms & Conditions
Privacy Policy
info@respoke.io
+1 256-428-6254