SignalEvent class

The Session object dispatches SignalEvent object when any client connected to the session sends a signal. A client can send a signal (to other connected clients) by calling the signal() method of the Session object.

SignalEvent properties

The SignalEvent object has the following properties

fromConnection (Connection) — The connection that sent the signal.

target (Object) — The object that dispatched the event.

type (String) — The event type, "signalReceived".

Example

The following code initializes a session and sets up an event listener for when a signal is received.

var apiKey = ""; // Replace with your API key. See https://dashboard.tokbox.com/projects
var sessionID = ""; // Replace with your own session ID.
                    // See https://dashboard.tokbox.com/projects/
var token = ""; // Replace with a generated token that has been assigned the moderator role.
                // See https://dashboard.tokbox.com/projects/

var session = TB.initSession(sessionID);
session.addEventListener("signalReceived", signalHandler);
session.connect(apiKey, token);

function signalHandler(event) {
    alert("Signal received from connection: " +event.fromConnection.connectionId);
}

IRC Live Chat

Have a quick question? Chat with TokBox Support on IRC. Join chat