Skip to content
This repository was archived by the owner on Oct 10, 2018. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Nodejs cli tool for benchmarking websocket servers. Currently supports:
* [Faye](https://github.com/faye/faye)
* [Primus](https://github.com/primus/primus)
* [WAMP](https://github.com/tavendo/AutobahnJS)
* [ws](https://github.com/websockets/ws)

## Installation

Expand Down Expand Up @@ -45,7 +46,7 @@ command help
-g, --generator <file> Js file for generate message or special event
-m, --message <n> Number of message for a client. Default to 0
-o, --output <output> Output file
-t, --type <type> Type of websocket server to bench(socket.io, engine.io, faye, primus, wamp). Default to socket.io
-t, --type <type> Type of websocket server to bench(socket.io, engine.io, faye, primus, wamp, ws). Default to socket.io
-p, --transport <type> Type of transport to websocket(engine.io, websockets, browserchannel, sockjs, socket.io). Default to websockets (Just for Primus)
-k, --keep-alive Keep alive connection
-v, --verbose Verbose Logging
Expand Down Expand Up @@ -88,6 +89,9 @@ generator structure :
// WAMP session
// client.subscribe('com.myapp.hello').then(function(args) { });

// ws client
// client.send("Hello World");

done();
},

Expand All @@ -101,6 +105,7 @@ generator structure :
// client.emit('test', { hello: 'world' });
// client.publish('/test', { hello: 'world' });
// client.call('com.myapp.add2', [2, 3]).then(function (res) { });
// client.send('hello world');
done();
},

Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ program
.option('-m, --message <n>', 'number of message for a client. Default to 0', parseInt)
.option('-o, --output <output>', 'Output file')
.option('-t, --type <type>', 'type of websocket server to bench(socket.io, engine.io, faye, primus, wamp). Default to io')
.option('-p, --transport <type>', 'type of transport to websocket(engine.io, websockets, browserchannel, sockjs, socket.io). Default to websockets')
.option('-p, --transport <type>', 'type of transport to websocket(engine.io, websockets, browserchannel, sockjs, socket.io, ws). Default to websockets')
.option('-k, --keep-alive', 'Keep alive connection')
.option('-v, --verbose', 'Verbose Logging')
.parse(process.argv);
Expand Down
1 change: 1 addition & 0 deletions lib/generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ module.exports = {
// Your logic
//client.emit('test', { hello: 'world' });
//client.publish('/test', { hello: 'world' });
//client.send(JSON.stringify({hello: 'world'}));
done();
}
};
3 changes: 3 additions & 0 deletions lib/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ switch (workerType) {
case 'wamp':
BenchmarkWorker = require('./workers/wampworker.js');
break;
case 'ws':
BenchmarkWorker = require('./workers/wsworker.js');
break;
default:
logger.error('error workerType ' + workerType);
}
Expand Down
39 changes: 39 additions & 0 deletions lib/workers/wsworker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*global module, require*/
var ws = require('ws'),
util = require('util'),
BaseWorker = require('./baseworker.js'),
logger = require('../logger.js');

/**
* SocketIOWorker Worker class inherits form BaseWorker
*/
var SocketIOWorker = function (server, generator) {
SocketIOWorker.super_.apply(this, arguments);
};

util.inherits(SocketIOWorker, BaseWorker);

SocketIOWorker.prototype.createClient = function (callback) {
var self = this;
var client = new ws(this.server, { 'force new connection' : true});

client.on('open', function () {
callback(false, client);
});

client.on('close', function (err) {
if (self.verbose) {
logger.error("SocketIO Worker connect_failed" + JSON.stringify(err));
}
callback(true, client);
});

client.on('error', function (err) {
if (self.verbose) {
logger.error("SocketIO Worker error: " + JSON.stringify(err));
}
callback(true, client);
});
};

module.exports = SocketIOWorker;
15 changes: 8 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,17 @@
"author": "",
"license": "BSD",
"dependencies": {
"socket.io-client": "~1.3.5",
"engine.io-client": "~0.9.0",
"commander": "~1.1.1",
"colors": "~0.6",
"autobahn": "~0.9.5",
"cli-table": "~0.3.0",
"colors": "~0.6",
"commander": "~1.1.1",
"engine.io-client": "~0.9.0",
"faye": "~0.8.9",
"winston": "~0.7.1",
"socket.io": "~1.3.5",
"primus": "~1.5.2",
"autobahn": "~0.9.5"
"socket.io": "~1.3.5",
"socket.io-client": "~1.3.5",
"winston": "~0.7.1",
"ws": "^4.0.0"
},
"devDependencies": {
"chai": "~1.6.0",
Expand Down