Connecting the Stringee Client to the Stringee server allows authentication to proceed and data to flow.
The Stringee Client is initialized with a context.
Only one instance of StringeeClient should be instantiated and used at all times.
// global
var stringeeClient;
// Init
stringeeClient = new StringeeClient();
StringeeClient uses a listener pattern to notify your app about specific events. You need to implement listeners for connection and object (Conversation, Message) 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');
});
Once you have initialized Stringee Client and registered listeners, connect the SDK:
stringeeClient.connect('YOUR_ACCESS_TOKEN');
See Authentication to get your access token.
You can disconnect Stringee Client by calling:
stringeeClient.disconnect();