Example #1
0
        public static void EndGame()
        {
            try {
                bool tie, stalemate;
                string winner = GameController.getMaxPlayer(out tie, out stalemate).ToString();

                JsonTextWriter writer = new JsonTextWriter(new System.IO.StringWriter());
                writer.WriteStartObject();
                writer.WriteValue("Game Over");
                writer.WriteValue("Winner");
                writer.WriteValue(winner);
                writer.WriteValue("Tied");
                writer.WriteValue(tie || stalemate);
                writer.WriteEndObject();
                string json = writer.ToString();
                handler.Send(System.Text.Encoding.ASCII.GetBytes(json));

                handler.Shutdown(SocketShutdown.Both);
                handler.Close();
            }
            catch { throw new FormatException(); }
        }