Skip to main content

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.

Constructors​

MemberWhat it is
ServerPlayerConnectionHandlerOld(ServerHandler server)Creates a ServerPlayerConnectionHandlerOld from server.

Fields​

MemberWhat it is
Func<Connection, Task<bool>> UserPrequisitesAsync check run after a join is accepted; if it returns false the player is refused.
2 private and internal fields
MemberWhat it is
private static Logger loggerLogger for join checks.
private ServerHandler serverThe ServerHandler that owns it.

Events​

MemberWhat it is
event Action<Connection, PlayerMode, PlatformTarget> UserJoinedRaised when a player passes all checks and prerequisites, with their mode and platform.
event Action<Connection> UserLeftRaised after an accepted player disconnects.

Methods​

MemberWhat 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
MemberWhat 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: