コード例 #1
0
 public static void SendUDPData(IPEndPoint clientEndPoint, Packet p)
 {
     try
     {
         if (clientEndPoint != null)
         {
             udpListener.BeginSend(p.ToArray(), p.Length(), clientEndPoint, null, null);
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine($"Error sending data via udp: {ex}");
     }
 }
コード例 #2
0
 public static void SendUDPData(IPEndPoint clientEndPoint, Packet packet)
 {
     try
     {
         if (clientEndPoint != null)
         {
             udpListener.BeginSend(packet.ToArray(), packet.Length(), clientEndPoint, null, null);
         }
     }
     catch (Exception e)
     {
         Console.WriteLine($"Error on sending data to client end point {clientEndPoint}, {e}");
     }
 }
コード例 #3
0
 /// <summary>Sends a packet to the specified endpoint via UDP.</summary>
 /// <param name="_clientEndPoint">The endpoint to send the packet to.</param>
 /// <param name="_packet">The packet to send.</param>
 public static void SendUDPData(IPEndPoint _clientEndPoint, Packet _packed)
 {
     try
     {
         if (_clientEndPoint != null)
         {
             udpListener.BeginSend(_packed.ToArray(), _packed.Length(), _clientEndPoint, null, null);
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine($"Error sending data to {_clientEndPoint} via UDP: {ex}");
     }
 }
コード例 #4
0
 public static void SendUDPData(IPEndPoint endPoint, Packet packet)
 {
     try
     {
         if (endPoint != null)
         {
             udpListener.BeginSend(packet.ToArray(), packet.Length(), endPoint, null, null);
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine($"Error sending data to {endPoint} via UDP: {ex}");
     }
 }
コード例 #5
0
ファイル: Client.cs プロジェクト: Stroby241/GrappleGame
 /// <summary>Sends data to the client via UDP.</summary>
 /// <param name="packet">The packet to send.</param>
 public void SendData(Packet packet)
 {
     try
     {
         packet.InsertInt(instance.myId); // Insert the client's ID at the start of the packet
         if (socket != null)
         {
             socket.BeginSend(packet.ToArray(), packet.Length(), null, null);
         }
     }
     catch (Exception ex)
     {
         Debug.Log($"Error sending data to server via UDP: {ex}");
     }
 }