/// <summary> /// Cancels all ongoing games and informs the UI that we're disconnected. Sets the <see cref="LoggedIn"/> flag. /// This does not send any information to the server and should only be called in response to a connection issue /// or when the server logs us out. /// </summary> /// <param name="reason">The reason.</param> internal void LogoutAndDisconnect(string reason) { bool disconnectionIsNotRedundant = this.LoggedIn || this.LoggingIn; this.LoggedIn = false; if (disconnectionIsNotRedundant) { this.Events.RaiseDisconnection(reason); } foreach (var game in this.Data.Games.ToList()) { GamePlayer whoDisconnected = game.Controller.Players.FirstOrDefault(pl => pl.Info.Name == this.Username); game.Controller.EndGame(GameEndInformation.CreateDisconnection(whoDisconnected, game.Controller.Players)); } this.Data.UnjoinEverything(); }
private void IgsConnector_Disconnected(object sender, System.EventArgs e) { var us = Players.FirstOrDefault(pl => pl.IsLocal); this.EndGame(GameEndInformation.CreateDisconnection(us, Players)); }