1.1.2 • Published 6 years ago

w-spot-ws v1.1.2

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

w-spot-ws

Build Status npm Version JS Standard

Web socket implementation of w-spot

Installation

$ npm install w-spot-ws --save

Usage

'use strict'

const wSpotWS = require('w-spot-ws')

async function tryExample () {
  // Create multiple spot
  const NewYork = wSpotWS.client()
  const HongKong = wSpotWS()
  const Japan = wSpotWS.client()

  const port = 8080

  await HongKong.listenAsServer(port)
  await NewYork.connectAsClient(`ws://localhost:${port}`)
  await Japan.connectAsClient(`ws://localhost:${port}`)

  {
    class Person {
      async hi (msg) {
        return `hi, ${msg}`
      }
    }

    // Create a instance to a spot
    const john = NewYork.load(Person, 'jp.realglobe.new-york.john')
    await john.hi('I am in NewYork!')
  }

  {
    // Use remote instance
    const john = Japan.use('jp.realglobe.new-york.john')
    await john.hi('Calling from Japan!')
  }

}

tryExample().catch((err) => console.error(err))

API Guide

License

This software is released under the MIT License.

Links

1.1.2

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago