/// <summary> /// Destroys the session and clears up all used resources. /// </summary> public void Destroy() { if (this.isHoldingUser) { Engine.Game.Users.removeUserSession(this.User.ID); this.leaveRoom(false); this.User = null; this.itemStripHandler.saveHandItems(); this.itemStripHandler.Clear(); this.itemStripHandler = null; } this.gameConnection.Abort(); this.gameConnection = null; }
void Disconnected(ClientMessages reason, string message) { ConnectedEvent.Reset(); Connection.Dispose(); Connection = null; if (!GameClosed) { Invoke(new MethodInvoker(Close)); } string title; switch (reason) { default: title = "Disconnected"; break; case ClientMessages.JoinDenied: title = "Join denied"; break; case ClientMessages.Kicked: title = "Kicked"; break; case ClientMessages.Timeout: title = "Timeout"; break; case ClientMessages.ServerShutdown: title = "Shutdown"; message = "Server was shut down"; break; } MessageBox.Show(message, title, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); }
/// <summary> /// Initializes the Session object. /// </summary> /// <param name="sessionID">The ID this session was assigned to by the Woodpecker.Sessions.sessionManager.</param> /// <param name="gameClient">The System.Net.Sockets.Socket object of the game client that has been accepted by the game connection listener.</param> public Session(uint sessionID, Socket gameClient) { this.ID = sessionID; this.gameConnection = new gameConnection(this, gameClient); }