Created
August 1, 2016 08:25
-
-
Save z3t0/4c63f44d8324241e6bbc1b48110f92d5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function Server (host, port) { | |
| // Create WebSocketServer | |
| var wss = new WebSocketServer({host: host, port: port}) | |
| wss.on('connection', this.onConnect(ws)) | |
| } | |
| Server.prototype.onConnect = function (ws) { | |
| // Debug | |
| console.log(`Client connected: ${ws.address}`) | |
| // Received Message Handler | |
| ws.on('message', onMessage(message)) | |
| } | |
| Server.prototype.onMessage = function (message) { | |
| console.log(`Received ${message}`) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment