talker
Simplified client/server communication, using websockets
Usage
Check example
Connect
client
var talk = ;var shoe = ; // will be called everytime connection is broken { return ;} // connectvar remote = ; // alternatively connect using auth-tokenvar secure = ;
server
var http = ;var talk = ;var shoe = ; var server = http; // authenticate { if token === 'my-secret-auth-token' ; } // on client connected { // client.id === 123 // application logic here...} // accept connections; // alternatively accept connections and authenticate clients; server;
EventEmitter API
client
// create emittervar emitter = remote; // listen on events from serveremitter; // emit events to serveremitter; // create namespaced emittervar chat = remote; chat;
server
{ var emitter = remote; emitter; var chat = remote; chat;}
RPC API
client
// create default rpcvar rpc = remote; rpc; // create namespaced rpcvar users = remote; users;
server
{ // default var rpc = remote; // namespaced var users = remote}
Stream API
client
var head = filename: 'hello.txt' binary: true // create upload stream with additional metavar stream = remote; // write buffers, since binary is set to truestream;stream; stream;
server
{ remote;}
TODO
- tests
- coverage
Author
Vladimir Popov rusintez@gmail.com
License
MIT