/// <summary> /// Send data to client (with packet_id && payload) /// </summary> public void SendData ( byte packet_id, byte[] data, ulong guid = 0, PacketPriority priority = PacketPriority.IMMEDIATE_PRIORITY, PacketReliability reliability = PacketReliability.RELIABLE, NetChannel channel = NetChannel.NET_EVENTS ) { server_peer?.BeginWrite(packet_id); server_peer?.WriteBytes(data); if (guid != 0) { server_peer?.SendToClient(guid, priority, reliability, channel); } }
/// <summary> /// Send data to server /// </summary> public void SendData ( byte packet_id, byte[] data, PacketPriority priority = PacketPriority.IMMEDIATE_PRIORITY, PacketReliability reliability = PacketReliability.RELIABLE, NetChannel channel = NetChannel.NET_EVENTS ) { if (IsConnected) { client_peer?.BeginWrite(packet_id); client_peer?.WriteBytes(data); client_peer?.SendToServer(priority, reliability, channel); } else { if (RakNet_Peer.debugLevel >= RakDebugLevel.Low) { Debug.LogError("[Client] Is not connected!"); } } }