json conversations over a stream
Conversation-Stream allows you to have a JSON conversation over a stream.
npm install conversation-stream
To listen for messages you just need to listen to the
var cs =var conversation = ;fromStream;conversation;
To send messages you call
To send messages and wait for a reply you call
var cs = ;var conversation = ;toStream;conversation;conversation;
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
We could even use WebSockets using shoe.