This poject uses ws to configure a basic Websocket server. Documentation can be found here
There is no persistance. This app runs entirely in memory.
Clients are identified with a Base64 Bearer Token in headers. Example tokens are logged on startup, and can be passed to your TCP client to establish a connection.
In your TCP client, connect with a Bearer Token. Once connected, you can broadcast a message to the global channel with a JSON push.
On startup, the server will log a GUID roomId, which is the global ID for chat all users are added to on initial connection.
{
"type": "rooms/message",
"roomId": "aeea2113-3a11-4041-9b41-d88c93eb9315",
"message": "This is Alice."
}Users are spawned at a default location 0,0. On every position update, each user within proximity will recieve an updated map of nearby users.
Example Move Message
{
"type": "presence/move",
"coords": {
"x": 100,
"y": 0
}
}It is highly reccomended to use Docker + Dev Containers, which will configure your development environment automatically. The DevContainer will inherit your .gitconfig from your hostmachine at runtime.
You're also welcome to run this on your host machine without a container. The prerequisites to do so can be pulled from the base image in /.devcontainer.
- Docker: Installed on host machine via your method of choice. This app was developed with Docker Desktop on OSX.
- Dev Containers: This app was developed with VSCode Dev Container Plugin.
- TCP Client: This app was developed with Postman.
- Run the dev container
- In the container's shell, run
npm run dev - Connect to
ws://localhost:8080with your TCP client of choice.