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


C# IChannelHandlerContext.CloseAsync方法代码示例

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


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

示例1: ContinueScenarioExecution

        void ContinueScenarioExecution(IChannelHandlerContext context)
        {
            if (!this.testScenario.MoveNext())
            {
                context.CloseAsync()
                    .ContinueWith(
                        t => this.completion.TrySetException(t.Exception),
                        TaskContinuationOptions.OnlyOnFaulted | TaskContinuationOptions.ExecuteSynchronously);
                this.completion.TryComplete();
                return;
            }
            foreach (object message in this.testScenario.Current.SendMessages)
            {
                context.WriteAsync(message)
                    .ContinueWith(
                        t => this.completion.TrySetException(t.Exception),
                        TaskContinuationOptions.OnlyOnFaulted | TaskContinuationOptions.ExecuteSynchronously);
            }

            context.Flush();
        }
开发者ID:l1183479157,项目名称:DotNetty,代码行数:21,代码来源:TestScenarioRunner.cs

示例2: ContinueScenarioExecution

        void ContinueScenarioExecution(IChannelHandlerContext context)
        {
            if (!this.testScenario.MoveNext())
            {
                context.CloseAsync()
                    .ContinueWith(
                        t => this.completion.TrySetException(t.Exception),
                        TaskContinuationOptions.OnlyOnFaulted | TaskContinuationOptions.ExecuteSynchronously);
                this.completion.TryComplete();
                return;
            }

            TestScenarioStep currentStep = this.testScenario.Current;

            if (currentStep.Delay > TimeSpan.Zero)
            {
                context.Channel.EventLoop.Schedule((ctx, state) => this.ExecuteStep((IChannelHandlerContext)ctx, (TestScenarioStep)state), context, currentStep, currentStep.Delay);
            }
            else
            {
                this.ExecuteStep(context, currentStep);
            }
        }
开发者ID:nberdy,项目名称:azure-iot-protocol-gateway,代码行数:23,代码来源:TestScenarioRunner.cs

示例3: CloseAsync

 public virtual Task CloseAsync(IChannelHandlerContext context) => context.CloseAsync();
开发者ID:RabbitTeam,项目名称:DotNetty,代码行数:1,代码来源:ChannelHandlerAdapter.cs

示例4: NotifyHandshakeFailure

 public static void NotifyHandshakeFailure(IChannelHandlerContext ctx, Exception cause)
 {
     // We have may haven written some parts of data before an exception was thrown so ensure we always flush.
     // See https://github.com/netty/netty/issues/3900#issuecomment-172481830
     ctx.Flush();
     ctx.FireUserEventTriggered(new TlsHandshakeCompletionEvent(cause));
     ctx.CloseAsync();
 }
开发者ID:RabbitTeam,项目名称:DotNetty,代码行数:8,代码来源:TlsUtils.cs

示例5: ExceptionCaught

 public override void ExceptionCaught(IChannelHandlerContext context, Exception exception)
 {
     Console.WriteLine("Exception: " + exception);
     context.CloseAsync();
 }
开发者ID:l1183479157,项目名称:DotNetty,代码行数:5,代码来源:EchoServerHandler.cs

示例6: ExceptionCaught

 public override void ExceptionCaught(IChannelHandlerContext context, Exception exception)
 {
     this.completion.TrySetException(exception);
     context.CloseAsync();
 }
开发者ID:nberdy,项目名称:azure-iot-protocol-gateway,代码行数:5,代码来源:TestScenarioRunner.cs

示例7: ChannelRead

 public override void ChannelRead(IChannelHandlerContext context, object message)
 {
     _event.Signal();
     context.CloseAsync();
 }
开发者ID:helios-io,项目名称:helios,代码行数:5,代码来源:LocalChannelTest.cs

示例8: ExceptionCaught

 //---------------------------------------------------------------------
 public override void ExceptionCaught(IChannelHandlerContext context, Exception exception)
 {
     context.CloseAsync();
 }
开发者ID:yinlei,项目名称:GF.Orleans,代码行数:5,代码来源:ClientHandler.cs

示例9: Shutdown

        async void Shutdown(IChannelHandlerContext context)
        {
            if (this.IsInState(StateFlags.Closed))
            {
                return;
            }

            try
            {
                this.stateFlags |= StateFlags.Closed; // "or" not to interfere with ongoing logic which has to honor Closed state when it's right time to do (case by case)

                this.CloseIotHubConnection();
                await context.CloseAsync();
            }
            catch
            {
                // ignored
            }
        }
开发者ID:tomconte,项目名称:azure-iot-sdks,代码行数:19,代码来源:MqttIotHubAdapter.cs

示例10: Shutdown

        /// <summary>
        ///     Closes channel
        /// </summary>
        /// <param name="context"></param>
        /// <param name="graceful"></param>
        async void Shutdown(IChannelHandlerContext context, bool graceful)
        {
            if (this.IsInState(StateFlags.Closed))
            {
                return;
            }

            try
            {
                this.stateFlags |= StateFlags.Closed; // "or" not to interfere with ongoing logic which has to honor Closed state when it's right time to do (case by case)
                
                PerformanceCounters.ConnectionsCurrent.Decrement();
                
                Queue<Packet> connectQueue = this.connectPendingQueue;
                if (connectQueue != null)
                {
                    while (connectQueue.Count > 0)
                    {
                        Packet packet = connectQueue.Dequeue();
                        ReferenceCountUtil.Release(packet);
                    }
                }

                PublishPacket will = !graceful && this.IsInState(StateFlags.Connected) ? this.willPacket : null;
                if (will != null)
                {
                    // try publishing will message before shutting down IoT Hub connection
                    try
                    {
                        this.publishProcessor.Post(context, will);
                    }
                    catch (Exception ex)
                    {
                        MqttIotHubAdapterEventSource.Log.Warning("Failed sending Will Message.", ex);
                    }
                }

                this.CloseIotHubConnection();
                await context.CloseAsync();
            }
            catch (Exception ex)
            {
                MqttIotHubAdapterEventSource.Log.Warning("Error occurred while shutting down the channel.", ex);
            }
        }
开发者ID:nberdy,项目名称:azure-iot-protocol-gateway,代码行数:50,代码来源:MqttIotHubAdapter.cs

示例11: CloseAsync

 public override Task CloseAsync(IChannelHandlerContext ctx)
 {
     if (this.Logger.IsEnabled(this.InternalLevel))
     {
         this.Logger.Log(this.InternalLevel, this.Format(ctx, "CLOSE"));
     }
     return ctx.CloseAsync();
 }
开发者ID:RabbitTeam,项目名称:DotNetty,代码行数:8,代码来源:LoggingHandler.cs

示例12: ExceptionCaught

 public override void ExceptionCaught(IChannelHandlerContext context, Exception exception)
 {
     base.ExceptionCaught(context, exception);
     NotifyListener(new Disassociated(DisassociateInfo.Unknown));
     context.CloseAsync(); // close the channel
 }
开发者ID:Micha-kun,项目名称:akka.net,代码行数:6,代码来源:HeliosTcpTransport.cs

示例13: ShutdownOnError

 static async void ShutdownOnError(IChannelHandlerContext context, Exception exception)
 {
     var self = (MqttIotHubAdapter)context.Handler;
     if (!self.IsInState(StateFlags.Closed))
     {
         self.stateFlags |= StateFlags.Closed;
         self.subscribeCompletion?.TrySetException(exception);
         self.deviceBoundOneWayProcessor.Abort(exception);
         self.deviceBoundTwoWayProcessor.Abort(exception);
         self.serviceBoundOneWayProcessor.Abort(exception);
         self.serviceBoundTwoWayProcessor.Abort(exception);
         self.onError(exception);
         try
         {
             await context.CloseAsync();
         }
         catch (Exception ex) when (!ex.IsFatal())
         {
             //ignored
         }
     }
 }
开发者ID:pierreca,项目名称:azure-iot-sdks,代码行数:22,代码来源:MqttIotHubAdapter.cs

示例14: ExceptionCaught

        public override void ExceptionCaught(IChannelHandlerContext context, Exception exception)
        {
            if (!(exception is ObjectDisposedException))
                log.Warn($"Exception in NettyServerHandler {context.Channel.Id.AsShortText()}: {exception.Message}");

            context.CloseAsync();
        }
开发者ID:HakanL,项目名称:animatroller,代码行数:7,代码来源:NettyServerHandler.cs

示例15: ExceptionCaught

        public override void ExceptionCaught(IChannelHandlerContext context, Exception exception)
        {
            log.Warn($"Exception in NettyClientHandler: {exception.Message}");

            context.CloseAsync();
        }
开发者ID:HakanL,项目名称:animatroller,代码行数:6,代码来源:NettyClientHandler.cs


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