ServerPlayerConnectionHandlerOld
A class in Root.Township, Alta.Networking.Servers.
Server: checks join requests and accepts or refuses players. Despite the name, ServerHandler still creates and uses it.
- Listed in Networking and servers
- Nested types
ApiServerJoinResult,PlayerJoinResult
Constructors
| Member | What it is |
|---|---|
ServerPlayerConnectionHandlerOld(ServerHandler server) | Creates a ServerPlayerConnectionHandlerOld from server. |
Fields
| Member | What it is |
|---|---|
Func<Connection, Task<bool>> UserPrequisites | Async check run after a join is accepted; if it returns false the player is refused. |
2 private and internal fields
| Member | What it is |
|---|---|
private static Logger logger | Logger for join checks. |
private ServerHandler server | The ServerHandler that owns it. |
Events
| Member | What it is |
|---|---|
event Action<Connection, PlayerMode, PlatformTarget> UserJoined | Raised when a player passes all checks and prerequisites, with their mode and platform. |
event Action<Connection> UserLeft | Raised after an accepted player disconnects. |
Methods
| Member | What it is |
|---|---|
void InitializeConnection(Connection connection) | Registers CheckApproved as the connection's RequestJoin handler. |
static async Task<bool> ValidateConsoleToken(JwtSecurityToken token) | Checks a token has this server's server_id claim and is valid with the API. |
protected virtual async Task<ServerPlayerConnectionHandlerOld.PlayerJoinResult> CheckIfPlayerIsAllowed(Connection connection, int playerId, string tokenString, string clientVersion, PlayerMode playerMode, PlatformTarget platformTarget) | Checks the join token (user, server id, expiry via the API), platform, player limit, version, allow list, duplicates and VR mode. |
protected virtual async Task<ServerPlayerConnectionHandlerOld.PlayerJoinResult> CheckIfPlayerIsAllowedCustom(Connection connection, int playerId, string tokenString, string clientVersion, PlayerMode playerMode, PlatformTarget platformTarget) | Used when the server identifier is -1. Reads the token without checking it with the API, then checks limit, version, allow list and duplicates. |
protected virtual async Task OnUserLeft(Connection connection) | Logs the player leaving; virtual so subclasses can add cleanup. |
5 private and internal methods
| Member | What it is |
|---|---|
private async void CheckApproved(Connection connection, Stream stream) | Handles a RequestJoin message: refuses during server locks, checks the player, runs prerequisites and replies with ConfirmJoinMessage. |
private bool CheckConnectionLimit(Connection connection) | True if there is no player limit or the connection count is within it. |
private async void ConnectionRemoved(Connection connection) | Runs OnUserLeft then raises UserLeft when an accepted connection disconnects. |
private void PlayerAccepted(Connection connection, PlayerMode playerMode, PlatformTarget playerSystem) | Hooks the disconnect handler and raises UserJoined. |
private static async Task PlayerDenied(Connection connection, string errorMessage) | Sends a refusal with the error, waits two seconds and destroys the connection. |
Used in
Members of other types that take, return or hold a ServerPlayerConnectionHandlerOld: