Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
prevent websocket end with refresh
  • Loading branch information
phodal committed Nov 21, 2015
1 parent 898c3c8 commit 35c95f3
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions index.js
Expand Up @@ -77,12 +77,14 @@ wss.on("connection", function (ws) {
position: devicePosition
});

ws.send(data);
ws.send(data, function (error) {
//it's a bug of websocket, see in https://github.com/websockets/ws/issues/337
});
}

var orientation = setInterval(emitOrientation, 1000);

ws.on("message", function(data) {
ws.on("message", function (data) {
clearInterval(orientation);
orientation = setInterval(emitOrientation, data);
});
Expand Down

0 comments on commit 35c95f3

Please sign in to comment.