https://github.com/sairash/chitosocket-js
ChitoSocket-js Wrapper for chitosocket server
https://github.com/sairash/chitosocket-js
Last synced: 2 months ago
JSON representation
ChitoSocket-js Wrapper for chitosocket server
- Host: GitHub
- URL: https://github.com/sairash/chitosocket-js
- Owner: sairash
- Created: 2023-05-26T19:02:25.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2023-05-26T19:16:20.000Z (about 2 years ago)
- Last Synced: 2025-03-09T21:19:46.232Z (3 months ago)
- Language: JavaScript
- Size: 1000 Bytes
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Chitosocket Js
This is a js wrapper for [Chitosocket Server](https://github.com/sairash/chitosocket)
```cmd
npm i @sairash/chitosocket
```##### Start A new Websocket connection
```js
cs = new chitosocket(`ws://localhost:6969/ws/`);
```##### Get event on message
```js
cs.on("message", (data) => {
console.log(data);
});
```##### Send message on event
```js
cs.emit("message", { user_id: 1, message: "This is a message." });
```##### Get all the events client is listening to
```js
console.log(cs.get_events());
```##### Get raw websocket
```js
const ws = cs.ws();
```##### Run function on any message from server
```js
ws.all_messages( (data) => {
console.log(data);
})
```