@sairash/chitosocket
v1.0.1
Published
A Wrapper for WebSocket that makes it easier to work with chitosocket backend.
Downloads
1
Readme
Chitosocket Js
This is a js wrapper for Chitosocket Server
npm i @sairash/chitosocket
Start A new Websocket connection
cs = new chitosocket(`ws://localhost:6969/ws/`);
Get event on message
cs.on("message", (data) => {
console.log(data);
});
Send message on event
cs.emit("message", { user_id: 1, message: "This is a message." });
Get all the events client is listening to
console.log(cs.get_events());
Get raw websocket
const ws = cs.ws();
Run function on any message from server
ws.all_messages( (data) => {
console.log(data);
})