当前位置: 首页>>代码示例>>C#>>正文


C# Exchange.Remove方法代码示例

本文整理汇总了C#中Exchange.Remove方法的典型用法代码示例。如果您正苦于以下问题:C# Exchange.Remove方法的具体用法?C# Exchange.Remove怎么用?C# Exchange.Remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Exchange的用法示例。


在下文中一共展示了Exchange.Remove方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ReceiveEmptyMessage

        /// <summary>
        /// If we receive an ACK or RST, we mark the outgoing request or response
        /// as acknowledged or rejected respectively and cancel its retransmission.
        /// </summary>
        public override void ReceiveEmptyMessage(INextLayer nextLayer, Exchange exchange, EmptyMessage message)
        {
            switch (message.Type)
            {
                case MessageType.ACK:
                    if (exchange.Origin == Origin.Local)
                        exchange.CurrentRequest.IsAcknowledged = true;
                    else
                        exchange.CurrentResponse.IsAcknowledged = true;
                    break;
                case MessageType.RST:
                    if (exchange.Origin == Origin.Local)
                        exchange.CurrentRequest.IsRejected = true;
                    else
                        exchange.CurrentResponse.IsRejected = true;
                    break;
                default:
                    if (log.IsWarnEnabled)
                        log.Warn("Empty messgae was not ACK nor RST: " + message);
                    break;
            }

            TransmissionContext ctx = (TransmissionContext)exchange.Remove(TransmissionContextKey);
            if (ctx != null)
                ctx.Cancel();

            base.ReceiveEmptyMessage(nextLayer, exchange, message);
        }
开发者ID:rlusian1,项目名称:CoAP.NET,代码行数:32,代码来源:ReliabilityLayer.cs

示例2: ClearBlockCleanup

 /// <summary>
 /// Clears the clean-up task.
 /// </summary>
 protected void ClearBlockCleanup(Exchange exchange)
 {
     Timer timer = exchange.Remove("BlockCleanupTimer") as Timer;
     if (timer != null)
     {
         try
         {
             timer.Stop();
             timer.Dispose();
         }
         catch (ObjectDisposedException)
         {
             // ignore
         }
     }
 }
开发者ID:vjine,项目名称:CoAP.NET,代码行数:19,代码来源:BlockwiseLayer.cs

示例3: ReceiveResponse

        /// <summary>
        /// When we receive a Confirmable response, we acknowledge it and it also
	    /// counts as acknowledgment for the request. If the response is a duplicate,
        /// we stop it here and do not forward it to the upper layer.
        /// </summary>
        public override void ReceiveResponse(INextLayer nextLayer, Exchange exchange, Response response)
        {
            TransmissionContext ctx = (TransmissionContext)exchange.Remove(TransmissionContextKey);
            if (ctx != null)
            {
                exchange.CurrentRequest.IsAcknowledged = true;
                ctx.Cancel();
            }

            if (response.Type == MessageType.CON && !exchange.Request.IsCancelled)
            {
                if (log.IsDebugEnabled)
                    log.Debug("Response is confirmable, send ACK.");
                EmptyMessage ack = EmptyMessage.NewACK(response);
                SendEmptyMessage(nextLayer, exchange, ack);
            }

            if (response.Duplicate)
            {
                if (log.IsDebugEnabled)
                    log.Debug("Response is duplicate, ignore it.");
            }
            else
            {
                base.ReceiveResponse(nextLayer, exchange, response);
            }
        }
开发者ID:rlusian1,项目名称:CoAP.NET,代码行数:32,代码来源:ReliabilityLayer.cs


注:本文中的Exchange.Remove方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。