/// <summary>Sends data to the client via TCP.</summary> /// <param name="_packet">The packet to send.</param> public void SendData(Packet _packet) { try { if (socket != null) { stream.BeginWrite(_packet.ToArray(), 0, _packet.Length(), null, null); // Send data to server } } catch (Exception _ex) { Console.WriteLine($"Error sending data to server via TCP: {_ex}"); } }
public void SendData(Packet _packet) { try { _packet.InsertInt(Client.myId); if (socket != null) { socket.BeginSend(_packet.ToArray(), _packet.Length(), null, null); } } catch (Exception _ex) { Console.WriteLine($"Error sending data to server via UDP: {_ex}"); } }
/// <summary>Sends data to the client via UDP.</summary> /// <param name="_packet">The packet to send.</param> public void SendData(Packet _packet) { try { _packet.InsertGuid(Get.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) { Console.WriteLine($"Error sending data to server via UDP: {_ex}"); } }
public void SendData(Packet packet) { try { packet.InsertInt(instance.myId); if (socket != null) { socket.BeginSend(packet.ToArray(), packet.Length(), null, null); } } catch (Exception e) { Debug.LogError($"Error sending data to server via UDP: {e}"); } }
/// <summary>Sends data to the server via UDP.</summary> /// <param name="_packet">The packet to send.</param> public void SendData(Packet packet) { try { packet.InsertInt(Client.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) { Console.WriteLine($"Error sending data to server via UDP: {ex}"); } }