From 761f9035d5741424c9fef77ee86bc4ae4ba59a8a Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Thu, 25 Jun 2015 23:18:18 +0200 Subject: [PATCH] Get rid of the ping API call, useless now --- public/js/vroom.js | 25 ------------------------- vroom.pl | 10 ++++------ 2 files changed, 4 insertions(+), 31 deletions(-) diff --git a/public/js/vroom.js b/public/js/vroom.js index bd173f9..92795e1 100644 --- a/public/js/vroom.js +++ b/public/js/vroom.js @@ -1644,31 +1644,6 @@ 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 - }); - } - } - }); - }, 120000); // Notify the server a new participant has joined (ourself) // If we were prompted for our display name before joining // we send it. Not that I like sending this kind of data to the server diff --git a/vroom.pl b/vroom.pl index 2b02f11..17fe9d8 100755 --- a/vroom.pl +++ b/vroom.pl @@ -202,7 +202,6 @@ helper create_room => sub { return 0; } if ($self->get_room_by_name($name)){ - return 0; } my $sth = eval { $self->db->prepare('INSERT INTO `rooms` @@ -1119,6 +1118,10 @@ websocket '/socket.io/:ver/websocket/:id' => sub { # Heartbeat reply, update timestamp elsif ($msg->type eq 'heartbeat'){ $peers->{$id}->{last} = time; + # Update room last activity ~ every 40 heartbeat, so about every 2 minutes + if ((int (rand 200)) <= 5){ + $self->update_room_last_activity($peers->{$id}->{room}); + } } }); @@ -1589,11 +1592,6 @@ any '/api' => sub { status => 503 ); } - # Handle activity pings sent every minute by each participant - elsif ($req->{action} eq 'ping'){ - $self->update_room_last_activity($room->{name}); - return $self->render(json => {}); - } # Update room configuration elsif ($req->{action} eq 'update_room_conf'){ $room->{locked} = ($req->{param}->{locked}) ? '1' : '0';