https://github.com/devramsean0/ws-chat
https://github.com/devramsean0/ws-chat
Last synced: 8 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/devramsean0/ws-chat
- Owner: devramsean0
- Created: 2023-09-25T12:03:09.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2025-10-07T16:39:13.000Z (8 months ago)
- Last Synced: 2025-10-07T20:44:34.167Z (8 months ago)
- Language: TypeScript
- Size: 161 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# WS-CHAT
A low resources chat service that communicates over Websockets
## Setup
### Installimg the libary
#### Yarn
`yarn global add @devramsean0/ws-chat`
#### NPM
`npm install -g @devramsean0/ws-chat`
### Setting up a server
To setup a server in it's most basic form run the command:
`ws-chat server`
Alternatively you can replicate [docker-compose.yml](https://github.com/devramsean0/ws-chat/blob/main/docker-compose.yml) Subsituting in your own build args after git cloning (`git clone https://github.com/devramsean0/ws-chat.git`) this repository
To change the port to listen on add the argument
`--port `
To set an authCode add the argument `--authCode `
To change the time between each Ping check add the argument `--heartbeatTime
### Setting up a client
To connect a client to a server running locally run the command `ws-chat client --username `
To connect a client to a remote server add the following argument `--ip `
To connect to a server running on a different port to 8080 add the following argument `--port `
To connect to a server with an auth code set add the following argument
`--authCode `
## Message Schema
This is the object that carries all custom data over the WS
### `type == "message"`
```json
{
"type": "message",
"username": string,
"message": message,
"authCode": string,
"password": md5String
}
```
### `type == "authFail"`
```json
{
"type": "authFail",
"step": "password | authToken"
}
```
### `type == "authREQ"`
````json
{
"type": "authREQ",
"authCode": string,
"password": string,
"username": string,
"oldMessageCount": number,
}
### `type = "join/leave"`
```json
{
"type": "join/leave",
"status": "joined" | "left" | "reconnected"
}
````
**Thanks to [kyranet/tiny-chat](https://github.com/kyranet/tiny-chat/) for the inspiration behind this project**