Created
October 25, 2017 04:00
-
-
Save willard1218/5ce0221c054b482eff98453e2f60b567 to your computer and use it in GitHub Desktop.
web socket
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
const WebSocket = require('ws'); | |
const wss = new WebSocket.Server({ port: 8080 }); | |
wss.on('connection', function connection(ws) { | |
ws.on('message', function incoming(data) { | |
console.log("reveice : " + data) | |
if (ws.readyState === WebSocket.OPEN) { | |
// | |
for ( var i = 0 ; i < 100 ; i ++) { | |
setTimeout(function() { | |
ws.send(i); | |
}, 1000 * i); | |
} | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment