Suggestions

close search

Signaling — REST

Use the OpenTok signaling API to send text and data to clients connected to an OpenTok session.

Once client endpoints are connected to a session using the OpenTok client SDKs, developers may choose to send signals to connected clients from the app server, rather than between client endpoints. Unlike the moderation capabilities of the JS SDK, the only function of the REST API for moderation is to provide the option to remove a connection from a session.

This topic includes the following sections:

Sending a signal to a specific client in a session

Send an HTTP POST to the signal resource of a specific connection ID, for a client connected to the session:

SESSION_ID=SOMESESSIONID
CONNECTION_ID=SOMECONNECTIONID
API_KEY=123456
API_SECRET=ABCDEF1234567890
DATA='{"type":"foo","data":"bar"}'
curl -v \
-H "Content-Type: application/json" \
-X POST \
-H "X-TB-PARTNER-AUTH:${API_KEY}:${API_SECRET}" \
-d "${DATA}" \
http://api.opentok.com/v2/project/${API_KEY}/session/${SESSION_ID}/connection/${CONNECTION_ID}/signal

Sending a signal to all clients in a session

For both signal examples below, the request body will be used to forward both the type and data fields. These correspond to the type and data parameters passed in the client signal received handlers.

Send an HTTP POST to the signal resource of the session:

SESSION_ID=SOMESESSIONID
API_KEY=123456
API_SECRET=ABCDEF1234567890
DATA='{"type":"foo","data":"bar"}'
curl -v \
-H "Content-Type: application/json" \
-X POST \
-H "X-TB-PARTNER-AUTH:${API_KEY}:${API_SECRET}" \
-d "${DATA}" \
http://api.opentok.com/v2/project/${API_KEY}/session/${SESSION_ID}/signal