Skip to content

node-organic/organic-plasma-socketio-channel

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published