Created
January 26, 2016 16:03
-
-
Save mrjazz/217489fa46787bc72a97 to your computer and use it in GitHub Desktop.
This file contains 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
// npm install websocket | |
var server = require('websocket').server, http = require('http'); | |
var socket = new server({ | |
httpServer: http.createServer().listen(8080) | |
}); | |
socket.on('request', function(request) { | |
var connection = request.accept(null, request.origin); | |
connection.sendUTF('hi'); | |
setInterval(function() { | |
connection.sendUTF(Math.round(Math.random() * 100)); | |
}, 1000); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment