peer-emitter
remote events with semantic acks
usage
fire-and-forget events
Works just like a remote event emitter.
send
var emitter = ;emitter;
receive
var emitter = ; emitter;
acknowlegded events
Just add a callback
send
Add a callback when emitting the event to make it acknowlegeable.
var emitter = ; // using a callback makes the event require to be acknowlegdedemitter; // you can specify custom timeouts per emit like so { if timeout console; else console;}onAcktimeout = 3000;emitter;
receive
Add one more argument to the event handler to control when the ack is sent.
If you do not use an extra argument, and the event is acknowlegeable, ack is sent after the event handler is called.
var emitter = ; emitter;
acknowlegded streams
make sure everything gets there
readable
var emitter = ; // Creating a stream need a name for the objects that are sent or// received so you can have multiple streams over the same emitter// as long as they have different names.// Nice names are names of the data types that are transacted.// e.g. you can have a stream of apples, and a stream of orangesvar readStream = emitter; // To ack each item, you will need to write it to an ack streamvar ackStream = readStream; readStream;
writable
var emitter = ; // creating a stream need a name for the objects that are sent or// received so you can have multiple streams over the same emitter// as long as they have different names.var writeStream = emitter;s; // You also may want to extract an acknowledgement stream for the alpha channelvar ackStream = writeStream;ackStream; { console;} // if you want acks, you probably want to know if they fail aswellvar timeoutStream = writeStream;timeoutStream; { console;}