conducto
WebSocket and HTTP framework. WIP
Server
var conducto = require('conducto');
var server = new conducto.Server();
server.use({
method: 'sum',
payload: {
required: true,
type: 'array',
items: {
type: 'number'
}
},
handler: function(payload, res) {
var sum = 0;
for (var i = 0; i < payload.length; i++) {
sum += payload[i];
}
res(null, sum);
}
});
server.listen(3000);
Client
var client = new conducto.Client();
client.open('ws://localhost:3000');
client.on('open', function() {
client.emit('sum', ['foo', 'bar'], function(err, res) {
});
client.emit('sum', [0, 1, 2, 3], function(err, res) {
console.log(res);
});
});