weso-browser

1.0.8-1 • Public • Published

weso-browser

Simple and light weight websocket client for the browser:

for more details on the protocol, checkout weso

`npm install weso-browser`

Usage example :

const weso = require('weso-browser')
 
const server = weso({
  url: 'localhost',
  port: 7266,
  retryDelay: 1000,
  publish: [ 'test' ],
  subscribe: [
    'initApps',
    'appDown',
    'appUp',
  ]
})
 
server.on.error(err => console.log('error', err))
server.on.close(err => console.log('close', err))
 
/*
  route = 'appUp',
  data = what ever the server sent
  ws = the websocket client instance
*/
server.appUp(({ route, data, ws }) => {
  console.log('yolo swag:', data, route)
  // send 'pouet' back to the websocket server on the route pouet
  server.test('pouet')
})
 

Shitty stuff :

You can init the server and start posting stuff synchronously, but it will silently ignore any message send before the server is started. So you better wait until the server is open.

Later on i may store all messages until the server is open, for now, just be aware of it.

Readme

Keywords

none

Package Sidebar

Install

npm i weso-browser

Weekly Downloads

0

Version

1.0.8-1

License

ISC

Last publish

Collaborators

  • kigiri