Exemple #1
0
        internal void OnPacketSent(double Time, NetPacket Packet)
        {
            WreckUtils.IncSeq(ref LocalSeq);

            Packet.TimeSent  = TimeSent = Time;
            Packet.PacketNum = LocalSeq;
        }
Exemple #2
0
        public void SendPacket(NetPacket Packet, NetWreckClient Cli)
        {
            byte[] Arr = ByteArrayPool.Rent(MaxDataSize);
            Cli.OnPacketSent(Timestamp(), Packet);

            int Len = WreckUtils.Serialize(Packet, Arr, MaxDataSize);

            SendRaw(Arr, Len, Cli);
            ByteArrayPool.Return(Arr);
        }
Exemple #3
0
        internal bool OnPacketReceived(double Time, NetPacket Packet)
        {
            if (!WreckUtils.SeqGreater(Packet.PacketNum, RemoteSeq))
            {
                return(false);
            }

            RemoteSeq    = Packet.PacketNum;
            TimeReceived = Time;
            return(true);
        }
Exemple #4
0
        bool ReceivePacket(ref IPEndPoint Sender, out NetPacket Packet)
        {
            if (ReceiveRaw(ref Sender, out byte[] Raw))
            {
                Packet = AllocPacket();
                WreckUtils.Deserialize(Raw, ref Packet);

                if (!Packet.IsValid())
                {
                    DebugPrint("Dropping invalid packet");

                    FreePacket(Packet);
                    Packet = null;
                    return(false);
                }

                return(true);
            }

            Packet = null;
            return(false);
        }