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

            _sendToClient?.Invoke(ref pack, ref len);
        }
Exemple #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;
            }
        }
Exemple #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;
            }
        }
Exemple #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;
            }
        }
Exemple #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...
            }
        }
Exemple #6
0
        public static void SendPacketToClient(byte[] packet, int length)
        {
            InternalPacketReceivedEvent?.Invoke(packet, length);

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

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

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