feat: typing user list in chat

This commit is contained in:
Barış Soner Uşaklı
2023-09-02 21:18:00 -04:00
parent 7e4b4d3a33
commit 600357444d
8 changed files with 108 additions and 16 deletions

View File

@@ -97,6 +97,19 @@ function onConnection(socket) {
}, onMessage, socket, payload);
});
socket.on('disconnecting', () => {
for (const room of socket.rooms) {
if (room && room.match(/^chat_room_\d+$/)) {
Sockets.server.in(room).emit('event:chats.typing', {
roomId: room.split('_').pop(),
uid: socket.uid,
username: '',
typing: false,
});
}
}
});
socket.on('disconnect', () => {
onDisconnect(socket);
});