Manages socket connections and messages
import { Client } from '@cast-web/protocol'; const client = new Client(); // wait for the client to connect await client.connect({ host: '192.168.1.101' }); client.on('connect', () => console.log('client connect')); client.on('close', () => console.log('client close')); client.on('error', error => console.log('client error:', error)); client.on('message', message => console.log('client message:', message)); // create channels here
Closes the client connection
Important to prevent EventEmitter leaks.
Connects to the client.
Promise - indicating connection established
Creates a channel on the client. // TODO: reference Channel
import { ConnectionChannel, Namespaces } from '@cast-web/types'; ... const connection = client.createChannel<ConnectionChannel>('sender-0', 'receiver-0', Namespaces.Connection, 'JSON');
Channel
Sends a message on the client connection.
import { Namespaces } from '@cast-web/types'; ... this.bus.send({ 'sender-0', 'receiver-0', Namespaces.Connection }, JSON.stringify({ foo: 'bar' }));
Generated using TypeDoc
Manages socket connections and messages