Last active
February 13, 2016 10:01
-
-
Save rkaw92/24e2ae81edcbd7e33681 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
var WebSocket = require('ws'); | |
var ws = new WebSocket('ws://localhost:7717'); | |
var fs = require('fs'); | |
var loremIpsum = fs.readFileSync(__dirname + '/lipsum.txt', 'utf-8'); | |
// loremIpsum += loremIpsum; | |
// loremIpsum += loremIpsum; | |
// loremIpsum += loremIpsum; | |
// loremIpsum += loremIpsum; | |
// loremIpsum += loremIpsum; | |
ws.on('open', function open() { | |
function spam() { | |
try { | |
ws.send(loremIpsum, function(error) { | |
if (error) { console.log(error); throw error; } | |
spam(); | |
}); | |
} | |
catch(error) { | |
console.log('catch:', error); | |
} | |
} | |
console.log('Starting spam...'); | |
spam(); | |
}); | |
ws.on('error', function(error) { | |
console.log(error); | |
}); | |
ws.on('close', function() { | |
console.log('close'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment