Create client:
const client = new StreamrWsClient({
direction: 'all'
});
Please see StreamrConnectionOptions for more configuration details.
const streamId = 'streamId';
const pubsub = await StreamrWsClient.create({
direction: 'sub',
streamId: streamId
});
pubsub.sub(
(data) => console.log(data),
(err) => console.error('Failed to subscribe:', err)
);
const streamId = 'streamId';
const pubsub = StreamrWsClient.create({
direction: 'sub',
streamId: streamId
});
const data = { some: 'object' };
pubsub.pub(data, (err) => console.error('Failed to publish:', err));