Skip to main content

JoinServerPipeline

A class in Root.Township, the global namespace.

Client: one attempt to join a game server. Asks the API for connection info, opens the connection, sends the join request and waits through the server's prerequisites for a JoinResult.

Constructors​

MemberWhat it is
JoinServerPipeline(GameServerInfo server, ISocket socket)Creates a JoinServerPipeline from server and socket.

Fields​

9 private and internal fields
MemberWhat it is
private ConnectionInfo connectionInfoAddress and port from the API. Swapped for the local or loopback address when the server is on your own public IP.
private bool isDisplayingPrerequisiteMessagesWhether prerequisite messages are being shown yet.
private bool isDoingPrerequisitesWhether the server has accepted and is still running prerequisites.
private JoinedServerInfo joinedInfoJoined server info from the server's first accepted response.
private ServerJoinResult joinResultThe API's join result, with the connection info and an optional join token.
private string lastPrerequisiteMessageThe most recent server status message.
private static Logger loggerClass logger.
private ISocket socketThe socket used to open the connection.
private TaskCompletionSource<JoinResult> waitForServerResponseCompleted with the final join result by whichever handler finishes first.

Properties​

MemberWhat it is
Connection ConnectionToServer { get; private set; }The connection being set up. Null until a connect succeeds or after disposal.
GameServerInfo ServerConnectingTo { get; private set; }The server being joined. Its identifier is updated from the API join result.

Methods​

MemberWhat it is
async Task<JoinResult> AttemptToConnectToServer()Runs the whole join: API join check, connect (15 tries, 1s apart), wait for the server's answer, then clear the handlers.
void CancelAttempt()Ends the attempt with a cancelled result and disposes the connection.
8 private and internal methods
MemberWhat it is
private void ConnectionApprovedByServer(Connection connection)Once the socket connects, sends the join request with user ID, token, player mode, platform and version, and sets the response handlers.
private void ConnectionSequence(Connection connection, Stream stream)Handles server status messages during prerequisites, showing them if they last more than 2s.
private void ConnectionToServerFailed(Connection connection)Disconnect before approval: fails the attempt as connection failed at the end of receiving.
private void ConnectionToServerLost(Connection connection)Disconnect after approval: shows a message and fails the attempt as connection lost.
private void DisposeConnection()Disposes and clears ConnectionToServer.
private void HandleServerConnectionResponse(Connection connection, Stream stream)Reads the server's join response: stores joined server info while prerequisites run, succeeds when they finish, or rejects.
private void OnServerRejectedRequest(Connection connection, ConfirmJoinMessage joinMessage)Logs the rejection, fails the attempt with the server's reason and disposes the connection.
private void ShowMessage()Shows the last prerequisite message on the player's message display, or on the loading screen.

Used in​

Members of other types that take, return or hold a JoinServerPipeline: