public byte[] sendGames() //broadcast message { String temp = "250 "; //initialise temp String if (game.Count > 0) //if games are playing { for (int i = 0; i < game.Count; i++) { if (game[i].active == true) //checking for active games { temp += game[i].playerA + " " + game[i].playerB + " "; } else //remove unactive and notify clients { network.broadcastUDP(generateMessage("255", game[i].playerA, game[i].playerB)); //notify clients game is no longer active game.RemoveAt(i); //remove game bindGames.ResetBindings(false); } } } byte[] data = Encoding.ASCII.GetBytes(temp); //convert to bytes return(data); //return message }
public void send(object sender, EventArgs e) { //broadcast connected players and current games periodically network.broadcastUDP(message.sendPlayers()); network.broadcastUDP(message.sendGames()); }