Last active
July 15, 2019 06:01
-
-
Save pushkarnk/b63275f98acfe86d6251074c54e6dc9c 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
const WebSocket = require('ws'); | |
for (i=0; i < 50; i++) { | |
let ws = this.ws = new WebSocket("ws://localhost:9001/"); | |
ws.onopen = (event) => { | |
console.log("Websocket opened"); | |
ws.send("This is the first message that was sent"); | |
ws.send("This is the second message that was sent"); | |
}; | |
ws.on('message', function incoming(data) { | |
console.log(data); | |
}); | |
setTimeout(function(i) { | |
ws.close() | |
}, 5000 + i*1000); | |
ws.onclose = (event) => { | |
console.log("WebSocket closed") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment