From 157e478abb96bed40b904be97072d7b2503b3a7a Mon Sep 17 00:00:00 2001 From: OttoMao Date: Mon, 18 May 2015 09:50:19 +0800 Subject: [PATCH] backup index page --- lib/wsServer.js | 22 ++++++++++++---------- web/index.html | 1 - 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/lib/wsServer.js b/lib/wsServer.js index 0a52ecd..487a5f3 100644 --- a/lib/wsServer.js +++ b/lib/wsServer.js @@ -49,17 +49,18 @@ function wsServer(config){ //web socket interface var wss = new WebSocketServer({port: config.port}); wss.broadcast = function(data) { - if(typeof data == "object"){ - data = JSON.stringify(data); - } + var key = data.id; + if(typeof data == "object"){ + data = JSON.stringify(data); + } - for(var i in this.clients){ - try{ - this.clients[i].send(data); - }catch(e){ - logUtil.printLog("websocket failed to send data, " + e, logUtil.T_ERR); - } - } + for(var i in this.clients){ + try{ + this.clients[i].send(data); + }catch(e){ + logUtil.printLog("websocket failed to send data, " + e, logUtil.T_ERR); + } + } }; wss.on("connection",function(ws){ @@ -78,6 +79,7 @@ function wsServer(config){ type : "update", content: data }); + }catch(e){ console.log("ws error"); console.log(e); diff --git a/web/index.html b/web/index.html index 3204395..d2cd8b4 100644 --- a/web/index.html +++ b/web/index.html @@ -34,7 +34,6 @@
-