2.0.1 • Published 2 years ago

organic-plasma-socketio-channel v2.0.1

Weekly downloads
26
License
MIT
Repository
github
Last release
2 years ago

organic-plasma-socketio-channel

A cross browser <-> server two-way channel based on socketio

usage

0) server-side pre-requirements

1) dna

browser

{
  
  "source": "organic-plasma-socketio-channel/env/client",
  "port": Number,
  "endpoint": String
  "transportChemicalsShape": Object
}
  • providing port will instruct socketio-channel to be connected at localhost:${port}
  • providing endpoint (overrides port) will instruct socketio-channel to connect at given endpoint, example http://localhost:1337
  • transportChemicalsShape will be used to do a deep equal match towards all chemicals emitted in plasma and those matching will be transported via the socketio channel

server

{
  "source": "organic-plasma-socketio-channel",
  "reactOnConnection": String,
  "socketPropertyName": "socket",
  "transportChemicalsShape": Object
}
  • transportChemicalsShape will be used to do a deep equal match towards all chemicals emitted in plasma and those matching will be transported via the socketio channel
  • reactOnConnection indicates the type of chemical to react on which contains a reference to socketio socket instance. See organic-socketio-server
  • socketPropertyName indicates the name of the property within reactOnConnection chemical holding reference to socketio socket instance. Defaults to socket. See organic-socketio-server

2) code

// server-side
plasma.emit({
  type: 'MyChemical',
  transportType: 'socketio',
  value: 'myValue'
})

// client-side
plasma.on('MyChemical', (c) => {
  console.log(c.value) // 'myValue'
})

// and vise-versa
2.0.1

2 years ago

2.0.0

4 years ago

1.2.0

5 years ago

1.1.0

5 years ago

1.0.0

6 years ago