ChatEngine generates $.online.*
and $.offline.*
events for each user when they join
or leave
chat rooms. These events can be consumed by other users in the chat room to show online
/offline
status.
- When a new user joins a chat room, a
$.online.join
event is emitted. - When an existing user joins a chat room, a
$.online.here
event is emitted. - When a user intentionally leaves a chat room, a
$.offline.leave
event is emitted. - When a user loses network connectivity, a
$.offline.disconnect
event is generated.
Listen to $.online
events
ChatEngine.on('$.online.*', (payload) => {
appendMessage('Status', payload.user.uuid + ' is in this room!');
});
Listen to $.offline
events
chat.on('$.offline.*', (payload) => {
console.log('User left the room:', payload.user);
});