Ejemplo n.º 1
0
        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
        }
Ejemplo n.º 2
0
 public void send(object sender, EventArgs e)
 {
     //broadcast connected players and current games periodically
     network.broadcastUDP(message.sendPlayers());
     network.broadcastUDP(message.sendGames());
 }