|
| 1 | +# A WebSocket signaling server/client for WebRTC. |
| 2 | + |
| 3 | +This demo is devided in 4 parts: |
| 4 | + |
| 5 | +- The `server` folder contains the signaling server implementation written in GDScript (so it can be run by a game server running Godot) |
| 6 | +- The `server_node` folder contains the signaling server implementation written in Node.js (if you don't plan to run a game server but only match-making). |
| 7 | +- The `client` part contains the client implementation in GDScript. |
| 8 | + - Itself divided into raw protocol and `WebRTCMultiplayer` handling. |
| 9 | +- The `demo` contains a small app that uses it. |
| 10 | + |
| 11 | +**NOTE**: You must extract the [latest version](https://github.com/godotengine/webrtc-native/releases) of the WebRTC GDNative plugin in the project folder to run from desktop. |
| 12 | + |
| 13 | +## Protocol |
| 14 | + |
| 15 | +The protocol is text based, and composed by a command and possibly multiple payload arguments, each separated by a new line. |
| 16 | + |
| 17 | +Messages without payload must still end with a newline and are the following: |
| 18 | +- `J: ` (or `J: <ROOM>`), must be sent by client immediately after connection to get a lobby assigned or join a known one. |
| 19 | + This messages is also sent by server back to the client to notify assigned lobby, or simply a successful join. |
| 20 | +- `I: <ID>`, sent by server to identify the client when it joins a room. |
| 21 | +- `N: <ID>`, sent by server to notify new peers in the same lobby. |
| 22 | +- `D: <ID>`, sent by server to notify when a peer in the same lobby disconnects. |
| 23 | +- `S: `, sent by client to seal the lobby (only the client that created it is allowed to seal a lobby). |
| 24 | + |
| 25 | +When a lobby is sealed, no new client will be able to join, and the lobby will be destroyed (and clients disconnected) after 10 seconds. |
| 26 | + |
| 27 | +Messages with payload (used to transfer WebRTC parameters) are: |
| 28 | +- `O: <ID>`, used to send an offer. |
| 29 | +- `A: <ID>`, used to send an answer. |
| 30 | +- `C: <ID>`, used to send a candidate. |
| 31 | + |
| 32 | +When sending the parameter, a client will set `<ID>` as the destination peer, the server will replace it with the id of the sending peer, and rely it to the proper destination. |
0 commit comments