@chipsgg/openservice-ws-client
v2.0.0
Published
Websocket client for openservice-ws-server
Downloads
427
Readme
Openservice Websocket Client
Websocket client for openservice-ws-server.
Install
yarn add @chipsgg/openservice-ws-client
Geting Started
import Client from "@chipsgg/openservice-ws-client";
//websockets must be supported in browser
const WS = require("ws");
const channels = ["public", "private", "auth", "community"];
Client(WS, { channels }).then(async ({ state, actions }) => {
// do somthing
await actions.public('echo', { message: 'hello world!' })
.then(console.log)
.catch(console.error)
await actions.community('on', { topic: 'chats', path: ['public'] })
state.on('community.chats.public', console.log)
})