JoinedServerGameMode
A class in Root.Township, the global namespace.
Client game mode for joining a game server: connects with retries, loads the server's scene and tells the server it's ready to spawn. Goes back to the main menu if it fails.
- Listed in Global namespace: I to L
- Inherits or implements
JoinServerGameModeBase
Constructors
| Member | What it is |
|---|---|
JoinedServerGameMode(GameServerInfo server) | Creates a JoinedServerGameMode from server. |
Fields
5 private and internal fields
| Member | What it is |
|---|---|
private bool isDeepLink | Set when the join came from a deep link. |
private const int JoinRetries | 24 connection attempts. |
private const int JoinRetryDelayMs | 5000 ms between connection attempts. |
private const int LostConnectionDelayMs | 2000 ms wait after losing the connection before leaving. |
private readonly GameServerInfo server | The server being joined. |
Methods
| Member | What it is |
|---|---|
override async Task<bool> ActivateAsync() | Shows the loading scene and tries to connect. On failure, returns to the main menu and returns false. |
static JoinedServerGameMode CreateDeeplinkJoinGameMode(GameServerInfo server) | Makes the mode for a deep link join, which shows a deep link error message if joining fails. |
override void OnStartSucceeded() | Starts listening for the connection dropping. |
override async Task StopModeAsync(string reason) | Fades to black, disconnects from the server and shuts down networking. |
5 private and internal methods
| Member | What it is |
|---|---|
private async Task<JoinResult> ConnectToServer() | Tries to connect up to 24 times, 5 seconds apart. Stops early on a failure that can't be recovered. |
private async Task<JoinResult> LoadGameScene(JoinResult result) | Loads the server's scene, sets up the client scene and sends ClientIsReadyToSpawn. |
private static async void LostConnection(Connection connection) | Shows "Lost connection to server", waits 2 seconds, then stops the current game mode. |
private async Task ReturnToMainMenuOnFailure(JoinResult result) | Logs the error, loads the main menu, shows the error and shuts down networking. |
private static async Task SetupLoadingScene() | Creates the loading scene and fades the screen back in. |