From 7c42333af4fb02aa079ed289d4eea477451bf23e Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Wed, 11 Mar 2015 11:53:26 +0100 Subject: [PATCH] Ping only after joining the room Fix #98 --- public/js/vroom.js | 51 +++++++++++++++++++++++++-------------------------- 1 file changed, 25 insertions(+), 26 deletions(-) diff --git a/public/js/vroom.js b/public/js/vroom.js index a751c8d..e096078 100644 --- a/public/js/vroom.js +++ b/public/js/vroom.js @@ -1463,6 +1463,31 @@ function initVroom(room) { }); } }, 10000); + // Ping the room every minutes + // Used to detect inactive rooms + setInterval(function(){ + $.ajax({ + data: { + req: JSON.stringify({ + action: 'ping', + param: { + room: roomName + } + }) + }, + error: function(data) { + showApiError(data); + }, + success: function(data) { + if (data.msg && data.msg != ''){ + $.notify(data.msg, { + className: 'info', + autoHide: false + }); + } + } + }); + }, 60000); } // Notify the server a new participant has joined (ourself) // If we were prompted for our display name before joining @@ -1943,32 +1968,6 @@ function initVroom(room) { }); } - // Ping the room every minutes - // Used to detect inactive rooms - setInterval(function(){ - $.ajax({ - data: { - req: JSON.stringify({ - action: 'ping', - param: { - room: roomName - } - }) - }, - error: function(data) { - showApiError(data); - }, - success: function(data) { - if (data.msg && data.msg != ''){ - $.notify(data.msg, { - className: 'info', - autoHide: false - }); - } - } - }); - }, 60000); - // Ping all the peers every 5 sec to measure latency // Do this through dataChannel setInterval(function(){