Automatic network communication
scuttler is a module that helps you write distributed, cross-platform network applications that automatically connect their users.
npm install scuttler
// Specify a port for the internal TCP server.var scuttler = port// Send a message to all peers.// String, Number, Object, and Array// objects are all acceptable.scuttler// Read the latest data from a given user.// Note: The user argument is an IP address.scuttler// Listen for messages from all peers.scuttler// Listen for peer connection/disconnection.scuttlerscuttler
This is a really basic (read: shitty) chat application, taken from the project’s example directory. Any computer on the network that runs the program will be automatically connected with everybody else. They’ll also be presented with the most recent messages of all of their peers.
var Scuttler =var scuttler = processargv2processstdinscuttlerscuttlerscuttler
I love tests, but I’m not really sure how to write them for this module, seeing as it relies on communication with other computers. If you have any ideas, get in touch, but for what it’s worth, all the major dependencies have tests, and the example application runs without error on OS X, Linux, and Windows.