示例#1
0
        internal static void SendToClient(Packet p)
        {
            var len  = (int)p.Length;
            var pack = p.Compile();

            _sendToClient?.Invoke(ref pack, ref len);
        }
示例#2
0
        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;
            }
        }
示例#3
0
        public static void SendPacketToServer(byte[] packet, int length)
        {
            lock ( _serverSendLock )
            {
                while (DateTime.Now < _nextPacketSendTime)
                {
                    Thread.Sleep(1);
                }

                InternalPacketSentEvent?.Invoke(packet, length);

                _sendToServer?.Invoke(ref packet, ref length);

                _nextPacketSendTime = DateTime.Now + PACKET_SEND_DELAY;
            }
        }
示例#4
0
        public static void SendPacketToServer(byte[] packet, int length)
        {
            lock ( _serverSendLock )
            {
                while (DateTime.Now < _nextPacketSendTime)
                {
                    Thread.Sleep(1);
                }

                InternalPacketSentEvent?.Invoke(packet, length);

                PacketWaitEntries?.CheckWait(packet, PacketDirection.Outgoing, true);

                _sendToServer?.Invoke(ref packet, ref length);

                _nextPacketSendTime = DateTime.Now + PACKET_SEND_DELAY;
            }
        }
示例#5
0
        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...
            }
        }
示例#6
0
        public static void SendPacketToClient(byte[] packet, int length)
        {
            InternalPacketReceivedEvent?.Invoke(packet, length);

            _sendToClient?.Invoke(ref packet, ref length);
        }
示例#7
0
        public static void SendPacketToServer(byte[] packet, int length)
        {
            InternalPacketSentEvent?.Invoke(packet, length);

            _sendToServer?.Invoke(ref packet, ref length);
        }
示例#8
0
        internal static void SendToClient(Packet p)
        {
            var len = p.Length;

            _sendToClient?.Invoke(p.Compile(), (int)len);
        }