Suggestions

close search

Connecting

Connecting the Stringee Client to Stringee's server allows authentication to procede and data to flow.

How to do it

The Stringee Client is initialized with a context.

1. Create client

Only one instance of StringeeClient should be instantiated and used at all times.

  // global
  var stringeeClient;

  // Init
  stringeeClient = new StringeeClient();

2. Listners

StringeeClient uses listner pattern to notify your client about specific events. You need to implement listeners for connection and object change events.

  stringeeClient.on('connect', function () {
    console.log('++++++++++++++ connected to StringeeServer');
  });

  stringeeClient.on('authen', function (res) {
    console.log('authen', res);
  });

  stringeeClient.on('disconnect', function () {
    console.log('++++++++++++++ disconnected');
  });

3. Connect client

Once you have initialized Stringee Client and registered listeners, connect the SDK:

    stringeeClient.connect('YOUR_ACCESS_TOKEN');

See Authentication to get your access token.

4. Disconnect client

You can disconnect Stringee Client by calling:

  stringeeClient.disconnect();