Home

Awesome

gossipmonger-tcp-transport

Stability: 1 - Experimental

NPM version

TCP Transport for Gossipmonger (an implementation of the Scuttlebutt gossip protocol endpoint for real-time peer-to-peer replication).

Contributors

@tristanls, @KenanSulayman, @yuskesh

Usage

var GossipmongerTcpTransport = require('gossipmonger-tcp-transport');
var transport = new GossipmongerTcpTransport();

transport.on('deltas', function (remotePeer, deltas) {
    // process deltas
});

transport.on('digest', function (remotePeer, digest) {
    // process digest
});

transport.on('error', function (error) {
    // process the error
    // if error handler is not registered if an error occurs it will be thrown
});

transport.on('listening', function () {
    console.log('listening...'); 
});

transport.listen();

Tests

npm test

Overview

TCP Transport for Gossipmonger.

Documentation

TcpTransport

Public API

TcpTransport.listen([options], [callback])

Creates new TCP transport and starts the server.

new TcpTransport([options])

Creates a new TCP transport. The host and port specified in the options will be the ones advertised to other peers to connect to. They must be reachable from the "outside".

If "internal" host and port are different from the "outside" ones, specify the "internal" version in options when calling transport.listen([options], [callback])

tcpTransport.close([callback])

Stops the server from listening to requests from other peers.

tcpTransport.deltas(remotePeer, localPeer, deltasToSend)

Sends deltasToSend to the remotePeer.

tcpTransport.digest(remotePeer, localPeer, digestToSend)

Sends digestToSend to the remotePeer.

tcpTransport.listen([options], [callback])

Starts the server to listen to requests from other peers.

tcpTransport.rpc(remotePeer, payload)

CAUTION: reserved for internal use

An internal common implementation for tcpTransport.deltas(...) and tcpTransport.digest(...).

Event deltas

Emitted when TcpTransport receives deltas from a peer.

Event digest

Emitted when TcpTransport receives digest from a peer.

Event error

Emitted when TcpTransport encounters an error. If no handler is registered, an exception will be thrown.

Event listening

Emitted when TcpTransport starts listening for connections from peers.