Beispiel #1
0
 /// <summary>
 /// Send a packet to all players
 /// </summary>
 private void SendMulticast(NetworkCommand cmd, int int1, int int2, string message)
 {
     try
     {
         // Send back to all clients
         NetworkData backData = new NetworkData(0, cmd, int1, int2, message);
         byte[] d = backData.ToByte();
         multicaster.Send(d, d.Length, remoteIpEP);
     }
     catch { }
 }
Beispiel #2
0
 /// <summary>
 /// Send a packet to only one player
 /// </summary>
 private void SendToOneClient(int playerId, NetworkCommand cmd, int int1, int int2, string message)
 {
     try
     {
         // Send back to all clients, but only the playerId will process it (TODO: may be improved)
         NetworkData backData = new NetworkData(playerId, cmd, int1, int2, message);
         byte[] d = backData.ToByte();
         multicaster.Send(d, d.Length, remoteIpEP);
     }
     catch { }
 }
Beispiel #3
0
 /// <summary>
 /// Send a packet to the server
 /// </summary>
 private void SendPacket(NetworkCommand cmd, int int1, int int2, string message)
 {
     NetworkData data = new NetworkData(LocalPlayerId, cmd, int1, int2, message);
     byte[] packet = data.ToByte();
     client.Send(packet, packet.Length);
 }