public static void SendPacketToClient(byte[] packet, int length) { lock ( _clientSendLock ) { while (DateTime.Now < _nextPacketRecvTime) { Thread.Sleep(1); } InternalPacketReceivedEvent?.Invoke(packet, length); _sendToClient?.Invoke(ref packet, ref length); _nextPacketRecvTime = DateTime.Now + PACKET_RECV_DELAY; } }
public static void SendPacketToClient(byte[] packet, int length) { try { lock ( _clientSendLock ) { while (DateTime.Now < _nextPacketRecvTime) { Thread.Sleep(1); } InternalPacketReceivedEvent?.Invoke(packet, length); _sendToClient?.Invoke(ref packet, ref length); _nextPacketRecvTime = DateTime.Now + PACKET_RECV_DELAY; } } catch (ThreadInterruptedException) { // Macro was interupted whilst we were waiting... } }
public static void SendPacketToClient(byte[] packet, int length) { InternalPacketReceivedEvent?.Invoke(packet, length); _sendToClient?.Invoke(ref packet, ref length); }