sg-socket-client

3.1.3 • Public • Published

sg-socket-client

Build Status npm Version JS Standard

Web socket client for SUGOS

Installation

$ npm install sg-socket-client --save

Usage

'use strict'
 
const sgSocketClient = require('sg-socket-client')
const co = require('co')
 
let socket = sgSocketClient('http://localhost:8084')
socket.on('connect', () => { /* ... */ })
socket.on('my:event', () => { /* ... */ })
socket.on('disconnect', () => { /* ... */ })
 
// Using call extension
co(function * () {
  // Wait for ack
  let result = socket.call('my:event', { foo: 'bar' })
  console.log(result)
})
 
// Using locking extension
 
co(function * () {
  // Resource to lock.
  let resource = 'screen'
  
  // Start locking
  // Throws error if another client lock the resource
  yield socket.lock(resource)
 
  // Stop locking
  yield socket.unlock(resource)
})
 

License

This software is released under the Apache-2.0 License.

Links

Readme

Keywords

Package Sidebar

Install

npm i sg-socket-client

Weekly Downloads

1

Version

3.1.3

License

Apache-2.0

Unpacked Size

66.2 kB

Total Files

18

Last publish

Collaborators

  • okunishinishi
  • realglobe