Skip to main content

ConnectToServerUtility

A static class in Root.Township, Alta.Networking.Servers.

Client: joins a game server. Keeps one client socket and one join attempt at a time, and sets up message handlers once joined.

Fields​

3 private and internal fields
MemberWhat it is
private static JoinServerPipeline joinServerPipelineThe join attempt in progress.
private static readonly Logger loggerLogger for this class.
private static ISocket socketThe client socket.

Methods​

MemberWhat it is
static async Task<JoinResult> ConnectToServer(GameServerInfo server)Creates the client socket if needed, cancels any other join in progress, and runs a JoinServerPipeline to the server.
static void StopCurrentConnectionAttempt()Closes the client socket and cancels the join attempt.
4 private and internal methods
MemberWhat it is
private static void CleanStaticSocket(ISocket obj)Clears the socket and join attempt when the socket is destroyed.
private static void HandleConnectionResultToServer(JoinResult result)On success, raises the client started event and sets up the connection's message handlers.
private static void SerializePause(Connection connection, Stream stream)Writes whether the application is paused; not hooked up here.
private static void SetupConnectionToServer(Connection connection)Sets the handlers for server messages such as spawn, destroy, move, entity sync and ping.