Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable candidate exchange via REST + SSE #19

Open
Brutus5000 opened this issue Dec 10, 2023 · 1 comment · May be fixed by #29
Open

Enable candidate exchange via REST + SSE #19

Brutus5000 opened this issue Dec 10, 2023 · 1 comment · May be fixed by #29
Labels
enhancement New feature or request

Comments

@Brutus5000
Copy link
Member

Background information

In order for the ICE protocol to work, the local candidates of an ICE adapter need to be sent to all other users that want to connect.

Currently this is done between lobby server [1] and faf client GpgnetMessage iceMsg [2] [3]. However, this has nothing to do with real Gpgnet protocol (lobby<->game). A better place would be a direct icebreaker<->ice-adapter communication.

Solution

(work in progress)
All ice adapters subscribe to an event stream (SSE) where candidate information is exchanged. (Hint: In a distributed system, these can be across multiple instances). When an ice-adapter tries to join a session, it can subscribe to an event stream (SSE) where remote peer candidates are being published.
Therefore on every connection attempt (might be reconnect too) can post to /game/{gameId}/candidates with the candidates as a payload. This POST triggers the candidates to be sent to all other session peers. This post must be marked with a request id, on which all other ice adapters should send a fresh response to the same request id (potential caching is up to the ice adapters).
All messages on the SSE must be sent via RabbitMQ so all icebreaker instances can forward them to SSE-session attached to this game.

@Brutus5000 Brutus5000 added the enhancement New feature or request label Dec 10, 2023
@fcaps
Copy link

fcaps commented Dec 10, 2023

TL;DR;
To offer new game "styles" like Galactic War, or a new lobby system, we need to remove all features from the lobby-server, that would be redundant. By removing the "Candidate Exchange" and replacing it with a service that could be reused by other lobby-systems, we kinda should go that route.

as an option Xirsys is offering Signaling servers.
How this could work:

  1. lobby-server sending a signal to icebreaker that a game is created (full?)
  2. icebreaker open a channel for a game with the api
  3. icebreaker create a token for every user (public user-id) with this api
  4. icebreaker get the latest signaling host with this
  5. ice-adapter gets the config via some GET call to icebreaker (retry if channels is not created)
  6. ice-adapter doing ice things with the signaling server
# simplified version
LobbyServer will dispatch these events to the client/connector
HostGame
  game-id: uuid/int
  public-user-id: uuid (every time a new one)
  ice-config-host: (icebreaker url with user identification)
  players: [list of public uuids]

JoinGame
  game-id: uuid/int
  public-user-id: uuid (every time a new one)
  ice-config-host: (icebreaker url with user identification )
  players: [list of public uuids]


LobbyServer will dispatch these events to the icebreaker
CreateChannel
  game-id: uuid/int
  players: [list of public uuids]

IceBreaker GET /config/{token}/{public user uuid}
Response:
{
  signaling-websocket-host: {{URL from xirsys with token}}
}

There are some questions about security, garbage collection (delete channels after some time) and how long a token should be valid, but nothing that is impossible to implement.

Downside is the complexity shift to the ice breaker (needs to know all game + users) needs persistence (redis?) to store tokens and games, and also needs to make some more requests to xirsys.

The ICE Adapter also has to make adjustments on how to talk to the signaling server, but also nothing to complicated.

PS: don't really know what is better, own server vs xirsys, both having pros/cons

Brutus5000 added a commit that referenced this issue Jan 19, 2024
Brutus5000 added a commit that referenced this issue Jan 19, 2024
Brutus5000 added a commit that referenced this issue Jul 1, 2024
@Brutus5000 Brutus5000 linked a pull request Jul 1, 2024 that will close this issue
Brutus5000 added a commit that referenced this issue Nov 25, 2024
Brutus5000 added a commit that referenced this issue Nov 25, 2024
Brutus5000 added a commit that referenced this issue Nov 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
2 participants