/// <summary> /// Get updates from the server and decide what to do. /// </summary> /// <param name="update"></param> /// <returns></returns> private String ParseUpdate(String u) { String[] args = u.Split(' '); String update = args[0]; if (update.Equals(StupidServer.UPDATE_GAME_CONNECTION_BROKEN)) { return("Host left game. Please leave and join another game."); } else if (update.Equals(StupidServer.UPDATE_PLAYER_JOINED)) { return("Another player has joined!"); } else if (update.Equals(StupidServer.UPDATE_GAME_HAS_STARTED)) { timer1.Stop(); Matchmaking.AbortFetchThread(); new FrmNewGame(id, Int32.Parse(args[1])).Show(); this.Close(); return(""); } else { return(""); } }
/// <summary> /// Provide functionality to "Start Game" button /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BtnHostStartGame_Click(object sender, EventArgs e) { timer1.Stop(); Matchmaking.AbortFetchThread(); String[] response = Program.GetConnector().StartHostedGame(id); new FrmNewGame(id, Convert.ToInt32(response[1])).Show(); this.Close(); }