Skip to content

Commit

Permalink
Add sequence diagram for client connection flow
Browse files Browse the repository at this point in the history
  • Loading branch information
PJB3005 committed Oct 13, 2024
1 parent 65dacc5 commit e744fbe
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ Robust Toolbox
- [ECS](en/robust-toolbox/ecs.md)
- [Netcode]()
- [Net Entities](en/robust-toolbox/netcode/net-entities.md)
- [Connection Sequence](en/robust-toolbox/netcode/connection-sequence.md)
- [Potentially Visible Set]()
- [Coordinate Systems](en/robust-toolbox/coordinate-systems.md)
- [Transform]()
Expand Down
68 changes: 68 additions & 0 deletions src/en/robust-toolbox/netcode/connection-sequence.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# RobustToolbox Connection Sequence

This is a complete sequence of what steps get taken when a client connects in RobustToolbox (and to some extent, Space Station 14). This is an incredibly involved and messy system that evolved over multiple years, and has many moving parts and sets of state. Oof.

## Basic overview

```mermaid
sequenceDiagram
participant C as Client
participant S as Server
C->>S: Lidgren Connection Attempt
S->>C: Lidgren Connection Approval
rect
Note over C,S: Initial handshake
C->>S: MsgLoginStart
Note left of S: Server decides to auth or not
opt Authentication
S->>C: MsgEncryptionRequest
create participant A as Auth Server
C->>A: POST /api/session/join
C->>S: MsgEncryptionResponse
%% I'd use <<->> but my Trilium doesn't have Mermaid v11.0.0 yet.
destroy A
S->A: GET /api/session/hasJoined
end
Note over S: Connecting event is raised,<br/>content can deny connection if desired
S->>C: MsgLoginSuccess
Note over C,S: Both sides enable encryption if necessary
Note over C,S: Both sides create NetChannel
end
S->>C: MsgStringTableEntries
rect
Note over C,S: Serializer handshake
S->>C: MsgMapStrServerHandshake
C->>S: MsgMapStrClientHandshake
opt Client needs strings
S->>C: MsgMapStrStrings
C->>S: MsgMapStrClientHandshake
end
end
Note over S,C: NetManager.Connected event<br/>Non-handshake messages are now allowed
C-->>S: MsgConVars
C-->>S: MsgConCmdReg
par PlayerManager.NewSession
Note over S: Server-side player session gets created,<br/>PlayerStatusChanged gets ran for first time
S->>C: MsgSyncTimeBase
Note over S: NetConfigurationManager.SyncConnectingClient
S->>C: MsgConVars
Note over C: Client-side player session gets created
C->>S: MsgPlayerListReq
and UploadedContentManager
loop Send uploaded resources
S->>C: NetworkResourceUploadMessage
end
loop Send uploaded prototypes
S->>C: GamePrototypeLoadMessage
end
end
Note over S: Player session is set to Connected
S->>C: MsgPlayerList<br/>Contains Connected Status
Note over C: Player session is set to Connected
Note over S: Content sets client session to InGame
S->>C: Starts sending game states
Note over C: Player session is set to InGame
```

0 comments on commit e744fbe

Please sign in to comment.