Commit 39b0063f authored by Yoann Pigné's avatar Yoann Pigné

more robust server (client can disconnect whenever)

parent 49ba7535
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
var elmt = document.getElementById("debug") var elmt = document.getElementById("debug")
var handler = new netstream.DOMGSSink(elmt); var handler = new netstream.DOMGSSink(elmt);
var transport = new netstream.Receiver("ws", "172.17.22.154", "2003", "/gs/stream", handler); var transport = new netstream.Receiver("ws", "127.0.0.1", "2003", "/gs/stream", handler);
// transport.debug = true; // transport.debug = true;
})(); })();
</script> </script>
......
var SERVER_IP = "172.17.22.154"; var SERVER_IP = "127.0.0.1";
var http = require('http') var http = require('http')
, fs = require('fs') , fs = require('fs')
, WebSocketServer = require('ws').Server , WebSocketServer = require('ws').Server
, WebSocket = require('ws')
, sourceID="nodeServer" , sourceID="nodeServer"
, timeID=0 , timeID=0
, net = require('net') , net = require('net')
...@@ -67,7 +68,9 @@ wss.on('connection', function(ws) { ...@@ -67,7 +68,9 @@ wss.on('connection', function(ws) {
console.log('events_server disconnected'); console.log('events_server disconnected');
}); });
c.on("data", function (data) { c.on("data", function (data) {
ws.send(data); if(ws.readyState === WebSocket.OPEN){
ws.send(data);
}
}); });
}); });
events_server.listen(function() { //'listening' listener events_server.listen(function() { //'listening' listener
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment