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.
- Listed in Global namespace: I to L
Constructors
| Member | What it is |
|---|---|
JoinServerPipeline(GameServerInfo server, ISocket socket) | Creates a JoinServerPipeline from server and socket. |
Fields
9 private and internal fields
| Member | What it is |
|---|---|
private ConnectionInfo connectionInfo | Address and port from the API. Swapped for the local or loopback address when the server is on your own public IP. |
private bool isDisplayingPrerequisiteMessages | Whether prerequisite messages are being shown yet. |
private bool isDoingPrerequisites | Whether the server has accepted and is still running prerequisites. |
private JoinedServerInfo joinedInfo | Joined server info from the server's first accepted response. |
private ServerJoinResult joinResult | The API's join result, with the connection info and an optional join token. |
private string lastPrerequisiteMessage | The most recent server status message. |
private static Logger logger | Class logger. |
private ISocket socket | The socket used to open the connection. |
private TaskCompletionSource<JoinResult> waitForServerResponse | Completed with the final join result by whichever handler finishes first. |
Properties
| Member | What 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
| Member | What 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
| Member | What 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: