0.1.5 • Published 7 years ago

tricep v0.1.5

Weekly downloads
3
License
MIT
Repository
github
Last release
7 years ago

tricep

Build Status Coverage Status Code Climate NPM Version Known Vulnerabilities NSP Status

A hapijs plugin for setting up TCP support using native node TCP (net).

Server

const Hapi = require('hapi');
const Tricep = require('tricep');

const server = new Hapi.Server();

server.connection();

server.register({
    register: Tricep,
    options: {
        server: {
            port: 9876,
            host: 'localhost'
        },
        onConnect: (client) => {

            client.write('Hello.');
        },
        onError: (err) => {

            console.log('Error: ', err);
        }
    }
}, (err) => {

    // Do your thing.
});

After registering, server.tricep will be available which represents the net server object.

Client

const Tricep = require('tricep');

const client = new Tricep.Client({
    port: 9876,
    host: 'localhost'
});

client.connect(() {

    // Client is now connected.

    client.onData = (data) {

        console.log(data.toString('utf8'));
    };
});

See the API and net for more information.

Contributing

0.1.5

7 years ago

0.1.4

7 years ago

0.1.3

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago