From f7f21ff0c14a1c2328ada9b3682cd4f6ecf9d049 Mon Sep 17 00:00:00 2001 From: Wayne Wang Date: Fri, 10 Jan 2014 03:18:30 +0800 Subject: [PATCH] keep up to one socket alive --- src/static/js/page.room.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/static/js/page.room.js b/src/static/js/page.room.js index ea29800..9f108a9 100644 --- a/src/static/js/page.room.js +++ b/src/static/js/page.room.js @@ -80,10 +80,14 @@ $(document).ready(function(){ }); }); - + + if(page.room.socket!=undefined){ + page.room.socket.close(); + } var token = $('#parameters').data('channeltoken'); var channel = new goog.appengine.Channel(token); var socket = channel.open(); + page.room.socket = socket; socket.onmessage = function(data){ var message = JSON.parse(data.data);