public void BeginWritePacket() { if (_receiving) { Debug.LogWarning(GetType() + " unable to write packet! He is received!"); return; } begin_write = true; peer?.BeginWrite(); Write(packet_id); }
/// <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!"); } } }
/// <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); } }