Наследование: DynamicVCPDU
        /// <summary>
        /// Expect a DVC Close PDU
        /// </summary>
        /// <param name="timeout">Time out</param>
        /// <param name="channelId">Channel ID</param>
        /// <param name="transportType">Transport Type</param>
        /// <returns></returns>
        private CloseDvcPdu ExpectDVCClosePDU(TimeSpan timeout, uint channelId, DynamicVC_TransportType transportType)
        {
            DateTime endTime = DateTime.Now + timeout;

            while (DateTime.Now < endTime)
            {
                if (unprocessedDVCPacketBuffer.Count > 0)
                {
                    lock (unprocessedDVCPacketBuffer)
                    {
                        for (int i = 0; i < unprocessedDVCPacketBuffer.Count; i++)
                        {
                            if (transportType == unprocessedDVCPacketBuffer[i].TransportType &&
                                unprocessedDVCPacketBuffer[i].PDU is CloseDvcPdu &&
                                (unprocessedDVCPacketBuffer[i].PDU as CloseDvcPdu).ChannelId == channelId)
                            {
                                CloseDvcPdu pdu = unprocessedDVCPacketBuffer[i].PDU as CloseDvcPdu;
                                unprocessedDVCPacketBuffer.RemoveAt(i);
                                return(pdu);
                            }
                        }
                    }
                }

                Thread.Sleep(this.waitInterval);
            }
            return(null);
        }
Пример #2
0
        /// <summary>
        /// Close a channel after received a Close DVC PDU
        /// </summary>
        /// <param name="pdu"></param>
        private void CloseChannel(CloseDvcPdu pdu)
        {
            if (!channelDicbyId.ContainsKey(pdu.ChannelId))
            {
                throw new InvalidOperationException("The channel has not been created, channel id:" + pdu.ChannelId);
            }
            DynamicVirtualChannel channel = channelDicbyId[pdu.ChannelId];

            channelDicbyId.Remove(channel.ChannelId);
            channel.IsActive = false;
        }
        /// <summary>
        /// Send DVC Close PDU
        /// </summary>
        /// <param name="channelId">Channel Id</param>
        /// <param name="transportType">Transport Type</param>
        private void SendDVCClosePDU(uint channelId, DynamicVC_TransportType transportType)
        {
            CloseDvcPdu pdu = pduBuilder.CreateCloseDvcPdu(channelId);

            this.Send(pdu, transportType);
        }
        /// <summary>
        /// Close a channel after received a Close DVC PDU
        /// </summary>
        /// <param name="pdu"></param>
        private void CloseChannel(CloseDvcPdu pdu)
        {
            if (!channelDicbyId.ContainsKey(pdu.ChannelId))
            {
                throw new InvalidOperationException("The channel has not been created, channel id:" + pdu.ChannelId);
            }
            DynamicVirtualChannel channel = channelDicbyId[pdu.ChannelId];

            channelDicbyId.Remove(channel.ChannelId);
            channel.IsActive = false;
        }