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


C# IChannelHandlerContext.Flush方法代码示例

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


在下文中一共展示了IChannelHandlerContext.Flush方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: Flush

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

示例3: 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

示例4: ChannelReadComplete

 public override void ChannelReadComplete(IChannelHandlerContext context)
 {
     context.Flush();
 }
开发者ID:l1183479157,项目名称:DotNetty,代码行数:4,代码来源:EchoServerHandler.cs

示例5: ExecuteStep

        void ExecuteStep(IChannelHandlerContext context, TestScenarioStep currentStep)
        {
            if (!context.Channel.Open)
            {
                // todo: dispose scheduled work in case of channel closure instead?
                return;
            }

            Task lastTask = null;
            object lastMessage = null;
            foreach (object message in currentStep.Messages)
            {
                lastMessage = message;
                var writeTimeoutCts = new CancellationTokenSource();
                Task task = context.WriteAsync(message);
                object timeoutExcMessage = message;
                context.Channel.EventLoop.Schedule(
                    () => this.completion.TrySetException(new TimeoutException(string.Format("Sending of message did not complete in time: {0}", timeoutExcMessage))),
                    this.sendTimeout,
                    writeTimeoutCts.Token);
                task.ContinueWith(
                    t => writeTimeoutCts.Cancel(),
                    TaskContinuationOptions.OnlyOnRanToCompletion | TaskContinuationOptions.ExecuteSynchronously);
                task.OnFault(t => this.completion.TrySetException(t.Exception));

                lastTask = task;
            }

            if (currentStep.WaitForFeedback)
            {
                if (this.responseTimeout > TimeSpan.Zero)
                {
                    this.responseTimeoutCts = new CancellationTokenSource();
                    if (lastTask == null)
                    {
                        this.ScheduleReadTimeoutCheck(context, null);
                    }
                    else
                    {
                        lastTask.ContinueWith(
                            t => this.ScheduleReadTimeoutCheck(context, lastMessage),
                            TaskContinuationOptions.OnlyOnRanToCompletion | TaskContinuationOptions.ExecuteSynchronously);
                    }
                }
            }

            context.Flush();

            if (!currentStep.WaitForFeedback)
            {
                context.Channel.EventLoop.Execute(
                    ctx => this.ContinueScenarioExecution((IChannelHandlerContext)ctx),
                    context);
            }
        }
开发者ID:nberdy,项目名称:azure-iot-protocol-gateway,代码行数:55,代码来源:TestScenarioRunner.cs

示例6: Flush

 public void Flush(IChannelHandlerContext context)
 {
     context.Flush();
 }
开发者ID:dalong123,项目名称:DotNetty,代码行数:4,代码来源:ChannelHandlerAdapter.cs

示例7: ProcessPendingSubscriptionChanges

        async void ProcessPendingSubscriptionChanges(IChannelHandlerContext context)
        {
            try
            {
                do
                {
                    ISessionState newState = this.sessionState.Copy();
                    Queue<Packet> queue = this.SubscriptionChangeQueue;
                    var acks = new List<Packet>(queue.Count);
                    foreach (Packet packet in queue) // todo: if can queue be null here, don't force creation
                    {
                        switch (packet.PacketType)
                        {
                            case PacketType.SUBSCRIBE:
                                acks.Add(Util.AddSubscriptions(newState, (SubscribePacket)packet, this.maxSupportedQosToClient));
                                break;
                            case PacketType.UNSUBSCRIBE:
                                acks.Add(Util.RemoveSubscriptions(newState, (UnsubscribePacket)packet));
                                break;
                            default:
                                throw new ArgumentOutOfRangeException();
                        }
                    }
                    queue.Clear();

                    if (!this.sessionState.IsTransient)
                    {
                        // save updated session state, make it current once successfully set
                        await this.sessionStateManager.SetAsync(this.deviceId, newState);
                    }

                    this.sessionState = newState;

                    // release ACKs

                    var tasks = new List<Task>(acks.Count);
                    foreach (Packet ack in acks)
                    {
                        tasks.Add(context.WriteAsync(ack));
                    }
                    context.Flush();
                    await Task.WhenAll(tasks);
                    PerformanceCounters.PacketsSentPerSecond.IncrementBy(acks.Count);
                }
                while (this.subscriptionChangeQueue.Count > 0);

                this.ResetState(StateFlags.ChangingSubscriptions);
            }
            catch (Exception ex)
            {
                ShutdownOnError(context, "-> UN/SUBSCRIBE", ex);
            }
        }
开发者ID:nberdy,项目名称:azure-iot-protocol-gateway,代码行数:53,代码来源:MqttIotHubAdapter.cs

示例8: Flush

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

示例9: ChannelActive

 public override void ChannelActive(IChannelHandlerContext context)
 {
     // write a large enough blob of data that it has to be split into multiple writes
     var channel = context.Channel;
     _tasks.Enqueue(
         context.WriteAsync(context.Allocator.Buffer().WriteZero(1048576))
             .ContinueWith(tr => channel.CloseAsync(),
                 TaskContinuationOptions.ExecuteSynchronously | TaskContinuationOptions.OnlyOnRanToCompletion)
             .Unwrap());
     _tasks.Enqueue(context.WriteAsync(context.Allocator.Buffer().WriteZero(1048576)));
     context.Flush();
     _tasks.Enqueue(context.WriteAsync(context.Allocator.Buffer().WriteZero(1048576)));
     context.Flush();
 }
开发者ID:helios-io,项目名称:helios,代码行数:14,代码来源:TcpSocketChannelTest.cs

示例10: ReadTimedOut

 /// <summary>
 /// Is called when a read timeout was detected.
 /// </summary>
 /// <param name="context">Context.</param>
 protected virtual void ReadTimedOut(IChannelHandlerContext context)
 {
     if(!this.closed)
     {
         context.FireExceptionCaught(ReadTimeoutException.Instance);
         context.Flush();
         this.closed = true;
     }
 }
开发者ID:RabbitTeam,项目名称:DotNetty,代码行数:13,代码来源:ReadTimeoutHandler.cs


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