saltysystems / overworld

Open source framework for scalable multiplayer games.
Mozilla Public License 2.0
20 stars 3 forks source link

Session remix #38

Closed cmdrk closed 1 month ago

cmdrk commented 2 months ago

This commit massively revamps session handling such that sessions are a separate process and everything refers to them by ID. Approximately following this workflow I mapped out:

Connection:
1. Client connects, Enet or WebSocket handler sets the a unique ClientID in
   their internal state and registers it with gproc
2. Client sends a session_request message with possible reconnect token
3. Request message gets routed to the RPCs in ow_session and either starts
   a new server or reconnects it to an existing session

Joining a zone:
1. Client asks to join zone through a JOIN message
2. Server accepts the client (or validates).
3. Server updates the client's session with the current zone

Disconnection:
1. The enet or websocket connection suddenly closes and sends a state
   update to the session
2. The session server sets a timeout and sends a message to itself after N seconds
3. The session server checks if its still in disconnected state, and terminates if so.
4. If the zone disconnection state is set to 'soft', the zone behaviour will have the 
    implementor run the disconnect handler
5. Otherwise, if the disconnection type is hard, the zone behaviour runs the part 
    handler immediately 

Parting a zone:
1. When the player leaves the zone, the part handler is run.