A hapijs plugin for setting up TCP support using native node TCP (net).
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.
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.
- Include 100% test coverage.
- Follow the Hapi coding conventions
- Submit an issue first for significant changes.