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.joinevent is emitted. - When an existing user joins a chat room, a
$.online.hereevent is emitted. - When a user intentionally leaves a chat room, a
$.offline.leaveevent is emitted. - When a user loses network connectivity, a
$.offline.disconnectevent 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);
});