コード例 #1
0
        private void HandleSequencePacket(ISequencePacket packet)
        {
            if (!_activeSequenceSessions.ContainsKey(packet.SeqGuid))
            {
                Debug.Print("Received sequence packet without a session");
                return;
            }

            _activeSequenceSessions[packet.SeqGuid].Add(packet);
        }
コード例 #2
0
ファイル: Peer.cs プロジェクト: lidd1224856175/uNet2
        private void HandleSequencePacket(ISequencePacket packet)
        {
            if (!_activeSequenceSessions.ContainsKey(packet.SeqGuid))
            {
                //TODO: exception
                Debug.Print("Received sequence packet without an active session");
                return;
            }

            lock (_lockObj)
            {
                _activeSequenceSessions[packet.SeqGuid].Sequence.Add(packet);
                _activeSequenceSessions[packet.SeqGuid].CurrentReceivedSize += packet.SeqSize;
            }
            var seqSession = _activeSequenceSessions[packet.SeqGuid];

            if (seqSession.IsOperation)
            {
                HostChannel.ActiveSocketOperations[seqSession.OperationGuid].SequenceFragmentReceived(
                    new SequenceFragmentInfo(packet.SeqGuid, seqSession.SessionStart,
                                             seqSession.InitPacket.FullSequenceSize,
                                             packet.SeqSize, seqSession.CurrentReceivedSize, seqSession.InitPacket.PartsCount, packet.SeqIdx));
            }
            else
            {
                OnSequenceFragmentReceived.Raise(this,
                                                 new SequenceEventArgs(packet.SeqGuid, seqSession.SessionStart,
                                                                       seqSession.InitPacket.FullSequenceSize, packet.SeqSize,
                                                                       seqSession.CurrentReceivedSize,
                                                                       seqSession.InitPacket.PartsCount, packet.SeqIdx, this));
            }
            if (packet.IsLast)
            {
                var fullPacketBuff = SequenceHandler.AssembleSequence(_activeSequenceSessions[packet.SeqGuid].Sequence);
                OnRawPacketReceived.Raise(this, new RawServerPacketEventArgs(fullPacketBuff, this));
                lock (_lockObj)
                    _activeSequenceSessions.Remove(packet.SeqGuid);
            }
        }