/// <summary> /// Does as the name implies. Disconnects the BoggleConnection, hides the current window, shows the summary. /// </summary> /// <param name="conn"></param> private void EndTheGame(BoggleConnection conn) { Summary summary = new Summary(conn.Summary, name, oppName, P1ScoreBox.Text, P2ScoreBox.Text, conn.Ip); conn.Disconnect(); this.Hide(); summary.ShowDialog(); }
/// <summary> /// Called when one of the players terminates or becomes disconnected in the middle of the game /// </summary> /// <param name="conn"></param> private void TerminateTheGame(BoggleConnection conn, String reason) { DialogResult result = MessageBox.Show(reason + " disconnected. Play again?", "Game Terminated", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation); if (result == DialogResult.Yes) { this.Dispose(); this.Hide(); Prompt replay = new Prompt(name, conn.Ip); replay.ShowDialog(); conn.Disconnect(); } else { conn.Disconnect(); this.Close(); } }
public void run() { BoggleServer.BoggleServer server = new BoggleServer.BoggleServer(1, "..\\..\\customDic.txt", BoardLetters); BoggleConnection P1conn = new BoggleConnection("localhost", "p1"); P1conn.GameTerminated += p1terminated; P1conn.Connect(); BoggleConnection P2conn = new BoggleConnection("localhost", "p2"); P2conn.GameTerminated += p2terminated; P2conn.Connect(); Thread.Sleep(100); P1conn.Disconnect(); Thread.Sleep(1000); Assert.AreEqual(false, p1ReceivedTERMINATED); Assert.AreEqual(true, p2ReceivedTERMINATED); server.Close(); }
/// <summary> /// Event handler for when player chooses to exit the application /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ExitApplication(object sender, FormClosingEventArgs e) { Debug.WriteLine("Form closing event fired."); conn.Disconnect(); Application.Exit(); }