-
• #2
Here is snippet that may help. You could use port 80 if wished.
var server = require('ws').createServer(servePage);
server.listen(8000); server.on("websocket", function(ws) { ws.on('message', function(evt){ // handle the message }); });
```
-
• #3
How should I write this together with:
var server = require("http").createServer(); server.listen(8000);
?
-
• #4
It's just as shown here: http://www.espruino.com/ws#websocket-server
Creating a WebSocket server on a port also creates an HTTP server on that same port. You can see that
onPageRequest
gets called in the example, and that's exactly the same function that'd get called if you didhttp.createServer(onPageRequest).listen(8080);
.Hope that helps!
All the examples I saw work on different ports (for example 80 + 8800, ...) I'm just starting an acquaintance. And for my project you need this functionality.