Conversation-Stream
Conversation-Stream allows you to have a JSON conversation over a stream.
npm install conversation-stream
Summary
To listen for messages you just need to listen to the message
event
var cs =var conversation = ;fromStream;conversation;
To send messages you call conversation.send(message)
To send messages and wait for a reply you call conversation.send(message, callback)
var cs = ;var conversation = ;toStream;conversation;conversation;
Example
Lets try to setup a simple server
var cs = ;var net = ;net;
To start a conversation to the server we need to create a socket to the server and pipe our message to that.
var socket = net;var conversation = ;socket;conversation;conversation;conversation;
If we wanted to use tls
instead of tcp
we could just have implemented the above example using tls
streams.
We could even use WebSockets using shoe.