Shared Objects and Red5ProSharedObjectSocket

Shared Objects and Red5ProSharedObjectSocket

To establish a Shared Object connection when targeting an HTML-based client, a previously establish connection must be made and provided to the Shared Object instance. Though you can easily use a previously established connection from a streaming client you can also use the Red5ProSharedObjectSocket class from the HTML SDK.

To instantiate and start a socket connection using the Red5ProSharedObjectSocket class:

(function (red5prosdk) {

  var socket = new red5prosdk.Red5ProSharedObjectSocket()
      protocol: 'wss',
      port: 443,
      app: 'live'
    .then(function (socket) {
      // Socket connection is established.
    .catch(function (error) {
      // An error has occurred in establishing a connection.


The Red5ProSharedObjectSocket class from the Red5 Pro HTML SDK is a proxy to an underlying WebSocket that provides convenience in communicating to and from the Red5 Pro Server.

Once the Red5ProSharedObjectSocket connection is available, it is provided to a Red5ProSharedObject instance - along with a shared object name - to establish a connection to the Remote Shared Object on the server:

var so;
function establishSharedObject (socket) {
  so = new red5prosdk.Red5ProSharedObject('sharedObjectTest', socket);
  so.on('*', handleSharedObjectEvents);

function handleSharedObjectEvents (event) {
  // Handle events.

For more information about the type of events and data provided, refer to the Shared Object Events section.