README.md

Synposis

An elegant way to define lightweight protocols on-top of TCP/TLS sockets in node.js

Motivation

Working within node.js it is very easy to write lightweight network protocols that communicate over TCP or TLS. The definition of such protocols often requires repeated (and tedious) parsing of individual TCP/TLS packets into a message header and some JSON body.

Build Status

Installation

[sudo] npm install nssocket

How it works

With nssocket this tedious bookkeeping work is done automatically for you in two ways:

Messages

Messages in nssocket are serialized JSON arrays of the following form:

["namespace", "to", "event", { "this":"is", "the":"payload" }]

Although this is not as optimal as other message formats (pure binary, msgpack) most of your applications are probably IO-bound, and not by the computation time needed for serialization / deserialization. When working with NsSocket instances, all events are namespaced under data to avoid collision with other events.