client-ketchup

A simple interface for keeping remote clients up to date with their authoritative state
Initial Motivation
The goal of client-ketchup
is to be a small API for managing the states of a constantly changing set of connected clients.
A server might have an enormous application state object but each client only needs to know about different pieces of this data.
When a specific client's state changes, we generate a small set of string-ified patches to send to them so that they can
update (or catch-up) their local state.
This helps avoid sending a massive amount of data over whenever we have new state information to each connected client.
The intended use case was for running multiplayer game servers, but an example potential different case might be a websocket powered real-time
database.
To Install
$ npm install --save client-ketchup
Usage
var CreateClientStateTracker = require('client-ketchup')
var CST = CreateClientStateTracker()
CST.add('some-client-id-1')
var minimalPatches = CST.update({foo: 'bar', bazz: 'buzz'})
myClients['some-client-id-1'].websocket.send(minimalPatches)
var patchObject = require('minimal-object-diff').patch
var minimalPatches = GetPatchesFromServerSomehow()
var myLocalState = GetLocalState()
myLocalState = patchObject(myLocalState, JSON.parse(minimalPatches))
client-ketchup
only concerns itself with helping to keep track of and generate optimized diffs for your client data.
The method of transport
(websocket, server-sent events, carrier pidgen, etc)
is up to the consumer.
Typically you'll already have your network protocol in place and client-ketchup
will be sprinkled in order to reduce bandwidth.
git clone https://github.com/chinedufn/client-ketchup && cd client-ketchup && npm install && npm run demo
TODO:
See Also
License
MIT