Skip to content

Latest commit

 

History

History
executable file
·
55 lines (39 loc) · 1.27 KB

README.md

File metadata and controls

executable file
·
55 lines (39 loc) · 1.27 KB

nes adds native WebSocket support to hapi-based application servers. Instead of treating the WebSocket connections as a separate platform with its own security and application context, nes builds on top of the existing hapi architecture to provide a flexible and organic extension.

Build Status

Lead Maintainer - Eran Hammer

Example

Server

var Hapi = require('hapi');
var Nes = require('nes');

var server = new Hapi.Server();
server.connection();

server.register(Nes, function (err) {

    server.route({
        method: 'GET',
        path: '/h',
        config: {
            id: 'hello',
            handler: function (request, reply) {

                return reply('world!');
            }
        }
    });

    server.start(function (err) { /* ... */ });
});

Client

var Nes = require('nes');

var client = new Nes.Client('ws://localhost');
client.connect(function (err) {

        client.request('hello', function (err, payload) {   // Can also request '/h'

            // payload -> 'world!'
        });
    });
});