From 1d355b02712bf608ee3bed28db871bba204fd9f3 Mon Sep 17 00:00:00 2001 From: Nate Harris Date: Tue, 5 Nov 2019 22:55:56 -0500 Subject: [PATCH 1/2] New person_single message for only one person in a room --- public/js/lib/templates.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/public/js/lib/templates.js b/public/js/lib/templates.js index d5ced02..a752492 100644 --- a/public/js/lib/templates.js +++ b/public/js/lib/templates.js @@ -104,7 +104,8 @@ define({ server: { person_joined: 'A person joined this room.', person_left: 'A person left this room.', - person_count: 'There is {payload} person(s) in this room, including you.', + person_count: 'There are {payload} people in this room, including you.', + person_single: 'You are the only person in this room.', command_failed: 'Server command failed, you\'re probably trying to du something bogus.', bogus: 'Received a bogus message from server.' }, @@ -112,4 +113,4 @@ define({ client: { title: 'Cryptalk - Offline' } -}); \ No newline at end of file +}); From fb190db4c8da6b9a943464cc71c23dac9dbe2dfb Mon Sep 17 00:00:00 2001 From: Nate Harris Date: Tue, 5 Nov 2019 23:00:23 -0500 Subject: [PATCH 2/2] Update server.js --- server.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/server.js b/server.js index ad99050..2c66989 100644 --- a/server.js +++ b/server.js @@ -53,7 +53,11 @@ io.on('connection', function(socket) { socket.on('room:count', function () { if( socket.current_room !== undefined ) { var clientsList = io.sockets.adapter.rooms[socket.current_room]; - socket.emit('message:server', {msg:'person_count', payload: clientsList.length } ); + if( clientsList.length > 1) { + socket.emit('message:server', {msg:'person_count', payload: clientsList.length } ); + } else { + socket.emit('message:server', {msg:'person_single'} ); + } } else { socket.emit('message:server', {msg:'command_failed'} ); } @@ -99,4 +103,4 @@ io.on('connection', function(socket) { } }); -}); \ No newline at end of file +});