1.1.5 • Published 6 years ago

poly-socketio v1.1.5

Weekly downloads
49
License
MIT
Repository
github
Last release
6 years ago

poly-socketio npm version CircleCI Code Climate Test Coverage

Polyglot SocketIO server that allows cross-language communication via JSON

Installation

npm i --save poly-socketio

Usage

This is used in AIVA to communicate JSON data among the Nodejs, Python and Ruby runtimes.

const polyIO = require('poly-socketio')
const IOPORT = 6466
var ioPromise = polyIO.server({port: IOPORT, clientCount: 1, timeoutMs: 15000, debug: false})
polyIO.client({port: IOPORT}) // this exposes a global.client

var msg = {
  input: 'hello js',
  to: 'echo.js',
  intent: 'ping'
}
global.client.pass(msg)
  .then((reply) => {
    if (reply.output === 'ping hello js') {
      console.log('success!')
    } else {
      console.log('error')
    }
  })