Skip to content
/ tricep Public

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

Notifications You must be signed in to change notification settings

Phenelo/tricep

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

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

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published