Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/oatpp/helicopter
WebSocket server for multiplayer games
https://github.com/oatpp/helicopter
high-performance messaging multiplayer websocket
Last synced: 3 months ago
JSON representation
WebSocket server for multiplayer games
- Host: GitHub
- URL: https://github.com/oatpp/helicopter
- Owner: oatpp
- License: apache-2.0
- Created: 2022-08-04T20:34:00.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-09-06T20:48:25.000Z (over 2 years ago)
- Last Synced: 2024-10-29T22:49:32.248Z (3 months ago)
- Topics: high-performance, messaging, multiplayer, websocket
- Language: C++
- Homepage:
- Size: 162 KB
- Stars: 13
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Helicopter
WebSocket server for multiplayer games.
:warning: **This project is in development and is NOT ready to use.**
## API
### Brief
There are two types of clients in Helicopter server:
- `Game Host` - the one who creates the game.
- `Game Client` - the one who joins the already created game.`Game Host` is responsible for managing game state and calculating physics.
:point_right: Helicopter server is agnostic of the game logic/physics/state etc. :point_left:`Game Client` communicates with `Game Host` through Helicopter server using WebSocket API provided.
### WebSocket API
#### Create Game
```
ws://:/api/create-game/?gameId=&sessionId=`
```Where:
- `gameId` is the id of the game from game config - stored on Helicopter server.
- `sessionId` is an arbitrary unique string which identifies the given game session.#### Join Game
```
ws://:/api/join-game/?gameId=&sessionId=`
```Where:
- `gameId` is the id of the game from game config - stored on Helicopter server.
- `sessionId` is an identifier of the game session created by the `Game Host`.#### Messaging
Helicopter server is using `JSON` for messaging.
All messages have the same structure (both incoming and outgoing):
```json
{
"code": integer,
"ocid": string or null,
"payload": content type depends on message code
}
```Where:
- `code` - operation/message code.
- `ocid` - Operation Correlation ID - used to correlate operation and an error message.
- `payload` - message payload##### Message Codes
Legend:
- :arrow_left: - incoming
- :arrow_right: - outgoing
- `H` - Game Host - can send this message
- `C` - Game Client - can send this message
- `HC` - both Game Host and a Game Client can send this message|Code|Direction|Peer Role|Description|Payload Type|
|:---:|:---:|:---:|:---:|:---:|
|0|:arrow_left:|`HC`|**Hello Message**
Once connected client will receive this message providing client with its `peerId` and its role (`isHost` - `true` or `false`) |object: `{"peerId": integer, "isHost": boolean}`|
|1|:arrow_left:|`HC`|**Ping**
Once received peer MUST respond with the proper Pong message | `integer` |
|2|:arrow_right:|`HC`|**Pong**
Peer responds with Pong message to server's Ping. Peer MUST include the same value it received in Ping to the Pong payload| `integer` |
|3|:arrow_left:|`HC`|**Error Message**
See Error-Codes for error messages|object: `{"code": integer, "message": string}`|
|5|:arrow_left:|`HC`|**Incoming Message**
Incoming Message from other peer|object: `{"peerId": integer, "data": string}`|
|6|:arrow_right:|`HC`|**Broadcast**
Peer broadcasts message to all other peers|`string`|
|7|:arrow_right:|`HC`|**Direct Message**
Peer sends message to another peer or to a group of peers.|object: `{"peerIds": [integer, ...], "data": string}`|
|8|:arrow_right:|`HC`|**Outgoing Synchronized Event**
Synchronized event will be broadcasted to ALL peers, including the sender of this event. All peers are guaranteed to receive synchronized events in the same order except for cases where peer's messages were discarded due to poor connection (message queue overflow).|`string`|
|9|:arrow_left:|`HC`|**Incoming Synchronized Event**|object: `{"eventId": integer, "peerId": integer, "data": string}`|
|101|:arrow_left:|H|**Client Joined Game**
Game Host receives this message when a new client joined the game. Payload is the `peerId` of new client.| `integer`|
|102|:arrow_left:|H|**Client Left Game**
Game Host receives this message when client disconnects from the game session. Payload is the `peerId` of new client.|`integer`|
|200|:arrow_right:|H|**Kick Client**
Game Host can kick client or a group of clients from game session.|list: `[integer, ...]`|
|300|:arrow_left:|C|**Kicked**
Game Client kicked from the game session.|`null`|
|400|:arrow_right:|C|**Message To Host**
Message from Game Client to Game Host.|`string`|