Chiχ Transport
General purpose transporter.
It's job is:
- receiving
- sending
- keep track of client scope.
Includes several transports:
- websocket
- websocket browser (client)
- websocket client (server)
- websocket proxy (server)
- chrome (unfinished)
- window (unfinished)
- dummy
These transports will only accept input and output as defined by the provided (JSON) schemas.
When messages are received their payload will be received and emitted, it's then up to the listener what to do with these messages.
When the listener has done it's logic it can choose to send back the data by using the send() method of the transport(s).
Schema:
Both input & output messages have the below structure:
{ protocol: 'your-protocol', command: '<action>' payload: ...data }
The schema's must define which commands are available and what their payload structure will look like, this is done by creating json schema's for them.
Examples:
All transport requires a set of schemas.
Schemas
Default set of schemas is available through chix-runtime/schemas
const schemas =
These define the valid incoming and outgoing messages, any unknown/invalid messages will send out an error message.
Note: The
role
will determine what is considered incoming and outgoing.
Dummy
const transport = schemas: schemas const connection = 'fake-conn' // incomingtransport // outgoingtransport
Websocket
Websocket server
const port = 8000 const server = http const options = protocol: 'noflo' schemas: schemas secure: true const transport = options server server
Websocket Browser
In-browser server/client
const options = protocol: 'noflo' schemas: schemas secure: true host: 'www.example.com' port: 8000 mount: '' secret: '123456' // client mode requires secret role: 'client' // 'server' or 'client' mode const transport = options server
Websocket Client
Server side client
const options = protocol: 'noflo' schemas: schemas secure: true host: 'www.example.com' port: 8000 mount: '' secret: '123456' // client mode requires secret role: 'client' // 'server' or 'client' mode const transport = options server
Websocket Proxy
Proxy requests by being both client and server
const port = 8000 const server = http const options = protocol: 'noflo' schemas: schemas secure: true const transport = options server server
Chrome
Meant to be used within chrome content scripts (not used yet)
const options = protocol: 'noflo' schemas: schemas const transport = options