opentok/opentok-node

Add support for callback registration API

Closed this issue · 1 comments

This is a request for comments regarding the API for upcoming platform functionality. The platform functionality is not generally available at the moment and there is no guarantee it will be released in any form.

Working with Callbacks

You can register callbacks to receive notifications for streams and connections created and destroyed
in an OpenTok session and also to receive notifications when your archives start and stop.

You register a callback you can use the opentok.registerCallback(group, event, url, callback) method indicating
the group and the event you are interested in and the url where you want to receive the notifications.

var url = "http://mydomain.com/opentok/callbacks";
opentok.registerCallback('connection', 'created', url, function(error, callback) {
  if (error) return console.log("error:", error);

  console.log("Registered callback: ", callback.id);
});

Note that you can only register a callback for a specific group&event. When registering a new callback for the
same event you are replacing the previous registration.

To unregister a callback you have can use the opentok.unregisterCallback(callbackId, callback) method.

opentok.unregisterCallback(callbackId, function(error) {
  if (error) return console.log("error:", error);
});

You can also get a list of all the Callbacks you've registered for your API Key. This is
done using the opentok.listCallbacks(callback) method.

opentok.listCallbacks(function(error, callbacks) {
  if (error) return console.log("error:", error);

  for (var i = 0; i < callbacks.length; i++) {
    console.log(callbacks[i].id);
  }
});
aiham commented

Merged in #156