Ejemplo n.º 1
0
        private void SendPacket(Packet packet)
        {
            if (packet.RequiresAcknowledgement())
            {
                pendingPackets.Add(packet);
            }
            long timestamp = NetTime.Now();

            byte[] data = packet.Encode(timestamp);

            if (Compression)
            {
                data = Compress.Deflate(data);
            }

            Stats.RecordSend(data.Length, timestamp);
            SendData(data);
        }
Ejemplo n.º 2
0
        private List <Payload> RecievePacket(byte[] data)
        {
            if (Compression)
            {
                data = Compress.Enflate(data);
            }

            long   timestamp = NetTime.Now();
            Packet packet    = Packet.Decode(data, timestamp);

            Stats.RecordReceive(data.Length, timestamp, packet.DecodingError);

            if (packet.RequiresAcknowledgement())
            {
                packetAcknowledgementQueue.Add(packet.PacketID);
            }

            return(packet.Payloads);
        }