Exemplo n.º 1
0
        void HandleDisconnect(Session session, DisconnectPacket p)
        {
            if (session.State == SessionState.Disconnected)
            {
                log.Info($"already disconnected: id={session.ID}");
                return;
            }

            // 연결 종료는 소켓이 끊어질떄도 있고
            // 유저가 직접 종료시키는 경우도 있다
            // disconnect를 여러번 호출해도 꺠지지 않도록 하자
            // 연결 끊은것을 연결 종료 패킷처럼 다루면
            // 상위 레이어에서의 처리가 간단해진다
            if (session.WorldID != null)
            {
                var leave = new WorldLeavePacket();
                var codec = new PacketCodec();
                var bytes = codec.Encode(leave);
                var pair  = new ReceivedPacket <WorldLeavePacket>(session, bytes);
                HandleWorldLeave(session, pair);
            }

            log.Info($"disconnect: id={session.ID}");
            var disconnect = new DisconnectPacket();

            session.SendLazy(disconnect);

            // 연결 끊어도 된다는 표시 해두기. 언제 끊어도 상관 없어야한다
            NetworkStack.Session.CloseSessionActive(session);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Adds the packet.
        /// </summary>
        /// <param name="packet">The packet.</param>
        /// <returns>true; if the message is completed, otherwise false</returns>
        public bool AddPacket(Packet packet)
        {
            ReceivedPacket p = new ReceivedPacket(packet, BlockCount);

            foreach (var smaller in SelectSubsets(p.Blocks.Count, newLeaves, p.Blocks))
                if (smaller.Blocks.IsProperSubsetOf(p.Blocks))
                    p.Xor(smaller);

            if (p.Blocks.Count == 1)
            {
                newLeaves.Clear();
                newLeaves.Enqueue(p);

                while (newLeaves.Count > 0)
                {
                    var next = newLeaves.Dequeue();
                    if (next.Blocks.Count == 1)
                        SubtractNewLeaf(next, newLeaves);
                }
            }

            AddToList(p);

            return IsComplete;
        }
Exemplo n.º 3
0
        public void AuthenicateUserAsync(FastFoodUser user, Action <bool> completed)
        {
            this.SendPacket(new AuthenicateUserOutgoingPacket(user), (c) =>
            {
                if (c)
                {
                    ReceivedPacket delegate_ = null;
                    delegate_ = delegate(IncomingPacket packet)
                    {
                        AuthenicateUserResponseIncomingPacket auth = packet as AuthenicateUserResponseIncomingPacket;
                        if (auth?.Result ?? false)
                        {
                            user.SetSessionToken(auth.SessionToken);

                            completed?.Invoke(true);
                        }
                        else
                        {
                            completed?.Invoke(false);
                        }

                        this.UnregisterPacketListenerUnsafe(delegate_);
                    };

                    this.RegisterPacketListenerUnsafe(delegate_);
                }
                else
                {
                    completed?.Invoke(false);
                }
            });
        }
Exemplo n.º 4
0
        public AnvizDevice(TcpClient socket)
        {
            DeviceStream = new AnvizStream(socket);
            DeviceStream.ReceivedPacket += (s, e) =>
            {
                switch (e.ResponseCode)
                {
                case 0x7F:
                    DevicePing?.Invoke(this, null);
                    break;

                case 0xDF:
                    ReceivedRecord?.Invoke(this, new Record(e.DATA, 0));
                    break;

                default:
                    ReceivedPacket?.Invoke(this, e);
                    break;
                }
            };
            DeviceStream.DeviceError += (s, e) =>
            {
                DeviceError?.Invoke(this, e);
            };
        }
Exemplo n.º 5
0
        private void OnReceiveSecondary(IAsyncResult ar)
        {
            int size = 0;

            try
            {
                size = secondarySocket.EndReceive(ar);
            }
            catch (ObjectDisposedException)
            {
                // Stop receiving
                return;
            }

            var newPacket = PCapPacket.CreateFromBytes(secondaryByteData, size);

            newPacket.PacketNumber = packetNumber++;
            var diff = DateTime.UtcNow - start;

            newPacket.TimeStampSeconds      = (uint)diff.TotalSeconds;
            newPacket.TimeStampMicroseconds = (uint)((diff.TotalSeconds - (uint)diff.TotalSeconds) * 1000000);
            ReceivedPacket?.Invoke(this, newPacket);

            // Receive again
            try
            {
                secondarySocket.BeginReceive(secondaryByteData, 0, secondaryByteData.Length, SocketFlags.None, new AsyncCallback(OnReceiveSecondary), null);
            }
            catch (ObjectDisposedException)
            {
                // Stop receiving
                return;
            }
        }
    private void ReceivingLoop()
    {
        EndPoint Endp = null;

        while (!Disconnected)
        {
            mData = new byte[1020];
            Debug.Log("Dang doi!");
            int _byteCount = mSocket.ReceiveFrom(mData, ref Endp);
            if (_byteCount > 0)
            {
                InputMemoryBitStream input = new InputMemoryBitStream(mData, _byteCount * 8);
                System.Random        rand  = new System.Random();
                int nextInt = rand.Next(0, 100);
                // Mô phỏng mất gói tin
                if (nextInt >= mSimulatedDropPacket)
                {
                    // Mô phỏng độ trễ
                    float          receivedTime = CurrentTime + mSimulatedLatency;
                    ReceivedPacket packet       = new ReceivedPacket(ref input, Endp, receivedTime);
                    // tránh tranh chấp dữ liệu
                    lock (mPacketQueue)
                    {
                        mPacketQueue.Enqueue(packet);
                    }
                }
            }
        }
        Debug.Log("Disconnected!");
    }
Exemplo n.º 7
0
 private async void ReceiverThreadFunc()
 {
     while (DeviceSocket.Connected && !CancellationTokenSource.IsCancellationRequested)
     {
         Response response = null;
         try
         {
             response = await Response.FromStream(DeviceStream, CancellationTokenSource.Token);
         }
         catch (Exception ex)
         {
             DeviceError?.Invoke(this, ex);
         }
         if (response == null)
         {
             DeviceSocket.Close();
             taskEmitter.TrySetResult(null);
             break;
         }
         if (response.ResponseCode == 0x7F)
         {
             await new PongCommand(response.DeviceID).Send(DeviceStream);
             ReceivedPacket?.Invoke(this, response);
         }
         else if (response.ResponseCode == ResponseCode)
         {
             ResponseCode = 0;
             taskEmitter.TrySetResult(response);
         }
         else
         {
             ReceivedPacket?.Invoke(this, response);
         }
     }
 }
    private void ReceiveFromCallback(IAsyncResult ar)
    {
        try
        {
            EndPoint endp       = (EndPoint)(new IPEndPoint(IPAddress.Any, 0));
            int      _byteCount = mSocket.EndReceiveFrom(ar, ref endp);
            if (_byteCount > 0 && endp != null)
            {
                InputMemoryBitStream input = new InputMemoryBitStream(mData, _byteCount * 8);
                System.Random        rand  = new System.Random();
                int nextInt = rand.Next(0, 100);
                if (nextInt >= mSimulatedDropPacket)
                {
                    // Mô phỏng độ trễ
                    float          receivedTime = CurrentTime + mSimulatedLatency;
                    ReceivedPacket packet       = new ReceivedPacket(ref input, endp, receivedTime);
                    // tránh tranh chấp dữ liệu
                    lock (mPacketQueue)
                    {
                        mPacketQueue.Enqueue(packet);
                    }
                }
            }

            StartReceivingPacket_nonblocking();
        }
        catch (ObjectDisposedException ex)
        {
            Debug.Log("end receive");
            return;
        }
    }
Exemplo n.º 9
0
        private async void Listen()
        {
            while (await _inStream.MoveNext())
            {
                var packet = _inStream.Current;
                // Invoke the event on the main thread
                UnityMainThreadDispatcher.Instance()
                .Enqueue(() =>
                {
                    switch (packet.TypeCase)
                    {
                    case Packet.TypeOneofCase.Authentication:
                        _token = packet.Authentication.ClientToken;
                        // Record.Log($"Received auth {_token}");

                        break;

                    case Packet.TypeOneofCase.CreatePlayer:
                        Record.Log($"Received create player {packet.CreatePlayer}");

                        break;
                    }
                    // Record.Log($"Received {packet}");

                    ReceivedPacket?.Invoke(packet);
                });
            }
        }
Exemplo n.º 10
0
 protected void OnReceivedPacket(T packet)
 {
     if (ReceivedPacket != null)
     {
         PacketEventArgs <T> packetEventArgs = new PacketEventArgs <T>(packet);
         ReceivedPacket.Invoke(this, packetEventArgs);
     }
 }
Exemplo n.º 11
0
        public override bool Receive(ref ReceivedPacket packet)
        {
            if (Recvs.Count > 0)
            {
                packet = Recvs[0];
                Recvs.RemoveAt(0);
                return(true);
            }

            return(false);
        }
Exemplo n.º 12
0
        void HandleWorldLeave(Session session, ReceivedPacket <WorldLeavePacket> received)
        {
            if (session.UserID < 0)
            {
                return;
            }

            var p      = received.Packet;
            var worlds = InstanceWorldManager.Instance;
            var world  = worlds.Get(session.WorldID);

            world.EnqueueRecv(session, received.Data);
        }
Exemplo n.º 13
0
        void EnqueueWorldPacket <TPacket>(ReceivedPacket <TPacket> packet)
            where TPacket : IPacket, new()
        {
            if (packet.Session.UserID < 0)
            {
                return;
            }

            var worlds = InstanceWorldManager.Instance;
            var world  = worlds.Get(packet.Session.WorldID);

            world.EnqueueRecv(packet.Session, packet.Data);
        }
Exemplo n.º 14
0
        public static IReadOnlyList <ICommand> ParseToCommands(ProtocolVersion version, IEnumerable <byte[]> payloads)
        {
            var result = new List <ICommand>();

            foreach (byte[] payload in payloads)
            {
                foreach (ParsedCommandSpec rawCmd in ReceivedPacket.ParseCommands(payload))
                {
                    result.AddIfNotNull(CommandParser.Parse(version, rawCmd));
                }
            }
            return(result);
        }
Exemplo n.º 15
0
        public static ReceivedPacket WaitOnReceive(SockBase sock)
        {
            var receivedPacket = new ReceivedPacket();

            for (int i = 0; i < 1000; ++i)
            {
                if (sock.Receive(ref receivedPacket))
                {
                    return(receivedPacket);
                }
                Thread.Sleep(1);
            }
            return(receivedPacket);
        }
Exemplo n.º 16
0
        public void SecondLevelParsing()
        {
            //SP900018[MECM(95,211,185,189,1,4,9,0,0,64,0,3,14,169,244,125,230,174,0,1,116,236,190,125,218,223,0,1,255,175,160,43,2,28,0,41,2,43,138,2,39,38,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
            Parser.ReceivedPacket packet = new ReceivedPacket
            {
                Data           = "95,211,185,189,1,4,9,0,0,64,0,3,14,169,244,125,230,174,0,1,116,236,190,125,218,223,0,1,255,175,160,43,2,28,0,41,2,43,138,2,39,38,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0",
                ProtocolHeader = "MECM",
                ReceivedOn     = DateTime.UtcNow,
                TerminalId     = "SP111111"
            };

            var pkt = ParsingManager.SecondLevelParser(packet);
            var str = JsonConvert.SerializeObject(pkt, Formatting.Indented);
        }
Exemplo n.º 17
0
 public AnvizDevice(TcpClient socket)
 {
     DeviceStream = new AnvizStream(socket);
     DeviceStream.ReceivedPacket += (s, e) =>
     {
         if (e.ResponseCode == 0x7F)
         {
             DevicePing?.Invoke(this, null);
         }
         else
         {
             ReceivedPacket?.Invoke(this, e);
         }
     };
 }
Exemplo n.º 18
0
        private void SendToListener(ReceivedPacket receivedPacket)
        {
            try
            {
                if (Context != null)
                {
                    Context.TransferText(receivedPacket.ToString());
                }

                ParsingManager.SecondLevelParser(receivedPacket);
            }
            catch (Exception ex)
            {
                LoggingManager.Log(ex);
            }
        }
Exemplo n.º 19
0
        private static List <List <ParsedCommandSpec> > ParseCommands(string filename)
        {
            var res = new List <List <ParsedCommandSpec> >();

            using (var reader = new StreamReader(filename))
            {
                string line;
                while ((line = reader.ReadLine()) != null)
                {
                    var commands = ReceivedPacket.ParseCommands(line.HexToByteArray());
                    res.Add(commands.ToList());
                }
            }

            return(res);
        }
Exemplo n.º 20
0
        public bool Handle(Client client, string packet)
        {
            if (_queuePackets)
            {
                var receivedPacket = new ReceivedPacket
                {
                    Client = client,
                    Packet = packet
                };

                _packets.Enqueue(receivedPacket);
            }
            else
            {
                return(HandlePacket(client, packet));
            }

            return(true);
        }
Exemplo n.º 21
0
        private void ConnectAsyncResult(IAsyncResult ar)
        {
            Action <ConnectionResult> completed = (Action <ConnectionResult>)ar.AsyncState;

            try
            {
                this.Socket.EndConnect(ar);

                this.SendPacket(new RequestServerVersionOutgoingPacket(), (c) =>
                {
                    if (c)
                    {
                        ReceivedPacket delegate_ = null;
                        delegate_ = delegate(IncomingPacket packet)
                        {
                            ServerVersionIncomingPacket serverVersion = packet as ServerVersionIncomingPacket;
                            if (serverVersion?.MagicMatches ?? false)
                            {
                                completed?.Invoke(ConnectionResult.Connected);
                            }
                            else
                            {
                                completed?.Invoke(ConnectionResult.NotAPIServer);
                            }

                            this.UnregisterPacketListenerUnsafe(delegate_);
                        };

                        this.RegisterPacketListenerUnsafe(delegate_);
                    }
                    else
                    {
                        completed?.Invoke(ConnectionResult.FailedToVerify);
                    }
                });

                this.StartListening();
            }
            catch
            {
                completed?.Invoke(ConnectionResult.ConnectionFailed);
            }
        }
        public static Dictionary <string, ICGRC> GetConfiguration(ReceivedPacket packet)
        {
            Dictionary <string, ICGRC> list   = new Dictionary <string, ICGRC>();
            GTGeneralSettings          cgrc00 = new GTGeneralSettings(packet.TerminalId);
            GTSimAndServerSettings     cgrc01 = new GTSimAndServerSettings(packet.TerminalId);
            GTPollingAndGprsSettings   cgrc02 = new GTPollingAndGprsSettings(packet.TerminalId);

            list.Add(nameof(GTGeneralSettings), cgrc00);
            list.Add(nameof(GTSimAndServerSettings), cgrc01);
            list.Add(nameof(GTPollingAndGprsSettings), cgrc02);
            //string raw = "SP333444<CGRC(ID(00,17/01/2021,07:51:07)N(+923333451191,+923468220229,+923333404763,,,,,,,,SR117R00BL01R00,13-Jan-16,16:27:21,+923,internet,,,+923,internet,,,333444,+923333451191,67.23.248.114,30004,SPMX00DT,SPMX01DT,,,,,,,1,15,2,4,30,9600,15,2)L(1000101101000000000001000000000000))\r>";
            string[] strArray = SplitPacket(packet.Data);

            cgrc00.Parse(strArray);
            cgrc01.Parse(strArray);
            cgrc02.Parse(strArray);

            return(list);
        }
Exemplo n.º 23
0
        private bool ParseEnhancedBlock(ProtocolVersion version, EnhancedPacketBlock block)
        {
            byte[] data = block.Data;

            // Perform some basic checks, to ensure data looks like it could be ATEM
            if (data[23] != 17)
            {
                throw new ArgumentOutOfRangeException("Found packet that appears to not be UDP");
            }
            if ((data[36] << 8) + data[37] != 9910 && (data[34] << 8) + data[35] != 9910)
            {
                throw new ArgumentOutOfRangeException("Found packet that has wrong UDP port");
            }

            data = data.Skip(42).ToArray();
            var packet = new ReceivedPacket(data);

            if (!packet.CommandCode.HasFlag(ReceivedPacket.CommandCodeFlags.AckRequest))
            {
                return(false);
            }

            bool failed = false;

            foreach (ParsedCommandSpec cmd in packet.Commands)
            {
                try
                {
                    // Try and parse, just to ensure it was successful
                    CommandParser.ParseUnsafe(version, cmd);
                }
                catch (Exception e)
                {
                    output.WriteLine(e.ToString());
                    failed = true;
                }
            }

            // TODO - parse any macros that were downloaded

            return(failed);
        }
 private void ProcessQueuedPackets()
 {
     lock (mPacketQueue)
     {
         while (mPacketQueue.Count != 0)
         {
             ReceivedPacket packet = mPacketQueue.Peek();
             if (Time.time > packet.GetReceivedTime())
             {
                 InputMemoryBitStream input = packet.GetInputMemoryStream();
                 ProcessPacket(ref input, packet.GetFromAddressEndpoint());
                 mPacketQueue.Dequeue();
             }
             else
             {
                 break;
             }
         }
     }
 }
Exemplo n.º 25
0
        private void HandlePacket(ReceivedPacket packet)
        {
            if (this.InvokeRequired)
            {
                this.Invoke(new MethodInvoker(() => HandlePacket(packet)));
                return;
            }

            string outputFilename = OutputFileTextBox.Text;

            switch (packet.command)
            {
            case 0x00:
                LogToFile(outputFilename, "Packet type 0: " + packet.payload[0].ToString() + " " + packet.payload[1].ToString());
                break;

            case 0x10:
                // Parse read data packet
                break;
            }
        }
Exemplo n.º 26
0
        /// <summary>
        /// Processes the packet stream.
        /// </summary>
        /// <returns>Task.</returns>
        private async Task ProcessPacketStream()
        {
            try
            {
                while (IsConnected && (OutgoingPackets.Count != 0 || TcpClient.Available != 0))
                {
                    while (IsConnected && TcpClient.Available != 0)
                    {
                        ReceivedPacket?.Invoke(this, new PacketEventArgs {
                            Packet = await Packet.ReadFromStreamAsync(TcpClientStream)
                        });

                        IncomingPacketReceieved = true;
                    }


                    if (!IsConnected || !CanSendPacket || OutgoingPackets.Count == 0)
                    {
                        continue;
                    }

                    await OutgoingPackets.Dequeue().WriteToStreamAsync(TcpClientStream);

                    OutgoingPacketCooldown.Restart();
                    IncomingPacketReceieved = false;

                    //// We've successfully sent or recieved data so the keepalive can be pushed back.
                    Keepalive.Reset();
                }
            }
            catch
            {
                // Lost connection with the server
                // No handling is necessary here as the TCPClient will set Connected to false.
                ServerConnectionDropped?.Invoke(this, new ServerConnectionEventArgs {
                    Message = "Connection to the server has been lost.", Status = ServerConnectionStatusEnum.Disconnected, Timestamp = DateTime.Now
                });
            }
        }
Exemplo n.º 27
0
        /// <summary>
        /// Цикл чтения пакетов из соединения
        /// </summary>
        /// <returns></returns>
        public async Task ReadAsync()
        {
            try
            {
                while (true)
                {
                    short bodyLength = await ReadBodyLengthAsync();

                    byte[] body = new byte[bodyLength];
                    await ReadBodyAsync(body, bodyLength);

                    var packet = new Packet(1, body);

                    ReceivedPacket?.Invoke(packet);
                }
            }
            catch (Exception ex)
            {
                logger.Error($"Ошибка при чтении пакета: {ex.Message}");
                //TODO: Тут надо новерно закрывать соединение
            }
        }
Exemplo n.º 28
0
        public void AuthenicatePrivateAPIAsync(string key, string signature, Action <bool> completed)
        {
            this.SendPacket(new RequestPrivateAPIAccessOutgoingPacket(key, signature), (c) =>
            {
                if (c)
                {
                    ReceivedPacket delegate_ = null;
                    delegate_ = delegate(IncomingPacket packet)
                    {
                        completed?.Invoke((packet as PrivateAPIAuthenicationResponseIncomingPacket)?.Result ?? false);

                        this.UnregisterPacketListenerUnsafe(delegate_);
                    };

                    this.RegisterPacketListenerUnsafe(delegate_);
                }
                else
                {
                    completed?.Invoke(false);
                }
            });
        }
Exemplo n.º 29
0
        private async void ReceiverThreadFunc()
        {
            while (!CancellationTokenSource.IsCancellationRequested)
            {
                var response = await Response.FromStream(DeviceStream, CancellationTokenSource.Token);

                if (response == null)
                {
                    DeviceSocket.Close();
                    taskEmitter.TrySetResult(null);
                    break;
                }
                else if (response.ResponseCode == ResponseCode)
                {
                    ResponseCode = 0;
                    taskEmitter.TrySetResult(response);
                }
                else
                {
                    ReceivedPacket?.Invoke(this, response);
                }
            }
        }
Exemplo n.º 30
0
        private byte[] CompileMessage(ReceivedPacket origPacket, byte[] payload)
        {
            byte opcode = (byte)origPacket.CommandCode;
            byte len1   = (byte)((ReceivedPacket.HeaderLength + payload.Length) / 256 | opcode << 3); // opcode 0x08 + length
            byte len2   = (byte)((ReceivedPacket.HeaderLength + payload.Length) % 256);

            byte[] buffer =
            {
                len1, len2,                                                             // Opcode & Length
                (byte)(origPacket.SessionId / 256), (byte)(origPacket.SessionId % 256), // session id
                0x00, 0x00,                                                             // ACKed Pkt Id
                0x00, 0x00,                                                             // Unknown
                0x00, 0x00,                                                             // unknown2
                (byte)(origPacket.PacketId / 256), (byte)(origPacket.PacketId % 256),   // pkt id
            };

            // If no payload, dont append it
            if (payload.Length == 0)
            {
                return(buffer);
            }

            return(buffer.Concat(payload).ToArray());
        }
Exemplo n.º 31
0
        private void StartLogWriter()
        {
            var thread = new Thread(() =>
            {
                while (true)
                {
                    if (!_logQueue.TryDequeue(out LogItem item))
                    {
                        Thread.Sleep(5);
                        continue;
                    }

                    var packet = new ReceivedPacket(item.Payload);
                    if (packet.CommandCode.HasFlag(ReceivedPacket.CommandCodeFlags.AckRequest) &&
                        !packet.CommandCode.HasFlag(ReceivedPacket.CommandCodeFlags.Handshake))
                    {
                        string dirStr = item.IsSend ? "Send" : "Recv";
                        // Handle this further
                        foreach (var rawCmd in packet.Commands)
                        {
                            var cmd = CommandParser.Parse(Version, rawCmd);
                            if (cmd != null)
                            {
                                Log.InfoFormat("{0} {1} {2} ({3})", dirStr, rawCmd.Name, JsonConvert.SerializeObject(cmd), BitConverter.ToString(rawCmd.Body));
                            }
                            else
                            {
                                Log.InfoFormat("{0} unknown {1} {2}", dirStr, rawCmd.Name, BitConverter.ToString(rawCmd.Body));
                            }
                        }
                    }
                }
            });

            thread.Start();
        }
Exemplo n.º 32
0
        private void AddToList(ReceivedPacket packet)
        {
            if (packet.Blocks.Count == 0)
                return;

            HashSet<ReceivedPacket> l;

            if (!packets.TryGetValue(packet.Blocks.Count, out l))
                packets.Add(packet.Blocks.Count, l = new HashSet<ReceivedPacket>());

            l.Add(packet);
        }
Exemplo n.º 33
0
            public void Xor(ReceivedPacket p)
            {
                if (Equals(p))
                    throw new Exception();

                Xor(p.Data);

                foreach (var r in p.Blocks)
                    if (!Blocks.Remove(r))
                        Blocks.Add(r);

                GenerateHash();
            }
Exemplo n.º 34
0
        private void SubtractNewLeaf(ReceivedPacket leaf, Queue<ReceivedPacket> output)
        {
            var supersets = new HashSet<ReceivedPacket>(packets.SelectMany(a => a.Value).Where(a => a.Blocks.IsProperSupersetOf(leaf.Blocks)));

            foreach (var superset in supersets)
            {
                RemoveFromList(superset);
                superset.Xor(leaf);
                AddToList(superset);

                if (superset.Blocks.Count == 1)
                    output.Enqueue(superset);
            }
        }
Exemplo n.º 35
0
        private bool RemoveFromList(ReceivedPacket packet)
        {
            HashSet<ReceivedPacket> l;

            if (packets.TryGetValue(packet.Blocks.Count, out l))
                return l.Remove(packet);

            return false;
        }