diff --git a/src/js/main.js b/src/js/main.js index 5cd59db..09e3a30 100644 --- a/src/js/main.js +++ b/src/js/main.js @@ -518,6 +518,7 @@ $(function() { if (!key.length) return; updateKeyVal(key); $('#join-modal').modal('hide'); + socket.emit('user joined'); } $('#settings-modal').on('hide.bs.modal', function (e) { diff --git a/src/room.js b/src/room.js index 6c0b59a..ae844a7 100644 --- a/src/room.js +++ b/src/room.js @@ -40,12 +40,15 @@ class Room { numUsers: this.numUsers, users: this.users }); + }); + + socket.on('user joined', () => { // echo globally (all clients) that a person has connected socket.broadcast.emit('user joined', { username: socket.username, numUsers: this.numUsers, users: this.users - }); + }); }); // when the client emits 'typing', we broadcast it to others