@marketrix.ai/link-client
v2.0.0
Published
This is the client-side library for the Link protocol. It allows you to connect to a Link server and manage multiplexed streams over a single WebSocket connection.
Readme
Link Client
This is the client-side library for the Link protocol. It allows you to connect to a Link server and manage multiplexed streams over a single WebSocket connection.
Installation
npm install @marketrix.ai/link-clientUsage
import { Client } from '@marketrix.ai/link-client';
const client = new Client({
url: 'ws://localhost:8080',
connectionId: 'client-1', // Optional
retryInterval: 1000 // Optional: retry connection every 1s
});
client.connect();
client.onOpen(() => {
console.log('Connected to server');
// Create a new stream
const stream = client.createStream('my-stream-1');
stream.onData((data) => {
console.log('Received data:', data);
});
stream.send({ message: 'Hello World' });
});
client.onClose(() => {
console.log('Disconnected from server');
});