The ChatEngine.connect()
method also allows you to include a user state
object that can be shared with other users on the platform. State is stored in PubNub. Username, location or avatar are examples of information that could be included in the state object. The contents of the state object has no special meaning to ChatEngine or PubNub.
ChatEngine.connect('john-UUID', {
name: 'John Doe',
team: 'red'
});
Listen to $.state
Event
A $.state
event is triggered to all users in the global
chat room if a user connects with a user state.
ChatEngine.global.on('$.state', (payload) => {
console.log(payload.user + ' state: ' + payload.state);
});