Example #1
0
        public override void HandleEncapsulatedPacket(EncapsulatedPacket packet)
        {
            base.HandleEncapsulatedPacket(packet);

            if (packet.Reliability.IsUnreliable())
            {
                HandleConnectedPacket(packet);
            }
            else if (packet.Reliability.IsReliable())
            {
                if (packet.MessageIndex < StartMessageWindow ||
                    packet.MessageIndex > EndMessageWindow || MessageWindow.ContainsKey(packet.MessageIndex))
                {
                    return;
                }

                MessageWindow.TryAdd(packet.MessageIndex, true);
                if (packet.MessageIndex == StartMessageWindow)
                {
                    for (; MessageWindow.ContainsKey(StartMessageWindow); ++StartMessageWindow)
                    {
                        MessageWindow.TryRemove(StartMessageWindow, out bool v);

                        ++EndMessageWindow;
                    }
                }

                if (packet.Split)
                {
                    HandleSplitEncapsulatedPacket(packet);
                    return;
                }

                HandleConnectedPacket(packet);
            }
        }