0.5.3 • Published 9 years ago

landho-client v0.5.3

Weekly downloads
4
License
MIT
Repository
github
Last release
9 years ago

landho-client

This is a client for landho services exposed via a web socket.

Install

npm install --save landho-client

Usage

var landho_client = require('landho-client'),
    WebSocket = require('ws')

var socket = new WebSocket('http://0.0.0.0:5000')
socket.on('connect', function ()
{
    var client = landho_client(socket),
        foo = client.service('foo')
    
    // Calling a request/response method
    foo('add', { a: 1, b: 72 }, function (err, result)
    {
        console.log(result) // -> 73
    })
    
    // Calling a method that returns a channel
    foo('counter', { start: 100 }, function (err, channel)
    {
        // `result` contains the initial value
        console.log(result) // -> 100
        
        // Listen to events emitted by the channel
        channel.on('update', function (c)
        {
            console.log(c) // -> 101...102...103...
        })
        
        // When you don't want updates anymore, close the channel
        setTimeout(function ()
        {
            channel.close()
        }, 5000)
    })
})

See tests/index.js for a complete, working example that includes a server component.

0.5.3

9 years ago

0.5.2

10 years ago

0.5.1

10 years ago

0.5.0

10 years ago

0.3.2

10 years ago

0.3.1

10 years ago

0.3.0

10 years ago

0.2.0

10 years ago

0.1.0

10 years ago