Skip to content

Commit aaef026

Browse files
committed
Reduce Notify Spam
Host notification no longer appears if you are already the host. Delays for other alerts are reduced.
1 parent 201225c commit aaef026

File tree

3 files changed

+22
-14
lines changed

3 files changed

+22
-14
lines changed

js/host.js

+2
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ socket.on('changeHostLabel', function(data) {
4343
message: username + " is now the host."
4444
}, {
4545
type: 'info',
46+
delay: 800,
4647
animate: {
4748
enter: 'animated fadeInUp',
4849
exit: 'animated fadeOutRight'
@@ -70,6 +71,7 @@ function disconnected() {
7071
message: " You are now out of sync of the host"
7172
}, {
7273
type: 'warning',
74+
delay: 400,
7375
animate: {
7476
enter: 'animated fadeInUp',
7577
exit: 'animated fadeOutRight'

js/sync.js

+1
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ function syncVideo(roomnum) {
7777
message: " The room is now synced with you"
7878
}, {
7979
type: 'success',
80+
delay: 400,
8081
animate: {
8182
enter: 'animated fadeInUp',
8283
exit: 'animated fadeOutRight'

server.js

+19-14
Original file line numberDiff line numberDiff line change
@@ -329,21 +329,26 @@ io.sockets.on('connection', function(socket) {
329329
socket.on('change host', function(data) {
330330
var roomnum = data.room
331331
var newHost = socket.id
332-
console.log("I want to be the host and my socket id is: " + newHost);
333-
//console.log(io.sockets.adapter.rooms['room-' + socket.roomnum])
332+
var currHost = io.sockets.adapter.rooms['room-' + socket.roomnum].host
334333

335-
// Broadcast to current host and set false
336-
socket.broadcast.to(io.sockets.adapter.rooms['room-' + socket.roomnum].host).emit('unSetHost');
337-
// Reset host
338-
io.sockets.adapter.rooms['room-' + socket.roomnum].host = newHost
339-
// Broadcast to new host and set true
340-
socket.emit('setHost')
341-
342-
io.sockets.adapter.rooms['room-' + socket.roomnum].hostName = socket.username
343-
// Update host label in all sockets
344-
io.sockets.in("room-" + roomnum).emit('changeHostLabel', {
345-
username: socket.username
346-
});
334+
// If socket is already the host!
335+
if (newHost != currHost) {
336+
console.log("I want to be the host and my socket id is: " + newHost);
337+
//console.log(io.sockets.adapter.rooms['room-' + socket.roomnum])
338+
339+
// Broadcast to current host and set false
340+
socket.broadcast.to(currHost).emit('unSetHost');
341+
// Reset host
342+
io.sockets.adapter.rooms['room-' + socket.roomnum].host = newHost
343+
// Broadcast to new host and set true
344+
socket.emit('setHost')
345+
346+
io.sockets.adapter.rooms['room-' + socket.roomnum].hostName = socket.username
347+
// Update host label in all sockets
348+
io.sockets.in("room-" + roomnum).emit('changeHostLabel', {
349+
username: socket.username
350+
});
351+
}
347352

348353
});
349354

0 commit comments

Comments
 (0)