uwebsockets - Paaspop/Paaspop-Server GitHub Wiki

uWebsockets

uWebsocketsJS is a websocket server made for NodeJS using a C++ engine for the websockets. This makes sure that it's fast and can handle alot of clients at the same time.

In this document you'll read more about the available HTTP and WS routes, the different websocket channels and client roles and how game data is stored.

Table of content

HTTP Routes

The websocket server opens up two http routes for communication from the admin panel.

Name Description Required body object
/start_game Stores the token to join a game and allows clients to join
  • token (admin token)
  • game_token
  • game_name
  • join_mid_game
  • response_answer
/stop_game Removes all stored game information and stops allowing clients to join
  • token (admin token)
  • game_name

WS Routes

There is only one websocket route, which is ''/'', when a client tries to connect to this route it will check if the client contains a admin token, game token or client protocol. If none of these three options are found, the client will be disconnected. Otherwise the client will be assigned the correct role.

Channels

The app has three channels available for the connected clients. These are:

  • admin_channel
  • game_channel
  • user_channel

Roles

Admin role

The admin clients will be subscribed to the admin_channel. When a message is published to the game_channel or user_channel it will automatically also be published to the admin_channel.

The admin clients are the only clients who are able to publish data to the game_channel or user_channel. This can be done by sending messages using the following prefixes:

  • /users
  • /game

Game role

The game client will be subscribed to the game_channel.
The game clients publish data to the users_channel

User role

The user client will be subscribed to the users_channel.
The user clients publish data to the game_channel

Storage

When a game is started, the game data will be stored using node-persist. This stores small JSON values in to files which can be found in /storage.

When a game is stopped, each file in the folder will be deleted.

⚠️ **GitHub.com Fallback** ⚠️