Added a "User left" message when someone leaves from a chatroom

This commit is contained in:
abrendan
2024-01-30 13:35:28 +00:00
parent 10da1b3392
commit 1ec626532c
2 changed files with 12 additions and 0 deletions

View File

@@ -36,4 +36,11 @@ io.on('connection', function(socket){
socket.on("recieve", function(message){
socket.emit("recieve", message);
})
socket.on("leave", function(room, username){
if (room && username) {
socket.leave(room);
io.in(room).emit("recieve", "Server : " + username + " has left the chat.");
}
});
})