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


C# IChannelHandlerContext类代码示例

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


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

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

示例2: ChannelActive

        //---------------------------------------------------------------------
        public override void ChannelActive(IChannelHandlerContext context)
        {
            var session = (GatewaySession)this.factory.createRpcSession(null);
            mapSession[context] = session;

            session.ChannelActive(context);
        }
开发者ID:yinlei,项目名称:GF.Orleans,代码行数:8,代码来源:GatewayChannelHandler.cs

示例3: HandleUpstream

        /// <summary>
        /// Process data that was received from the channel.
        /// </summary>
        /// <param name="ctx">Context which is used for the currently processed channel</param>
        /// <param name="e">Event being processed.</param>
        public void HandleUpstream(IChannelHandlerContext ctx, IChannelEvent e)
        {
            if (e is ConnectedEvent)
            {
                ctx.State = new Context();
            }
            if (e is ClosedEvent)
            {
                Reset();
            }
            else if (e is MessageEvent)
            {
                _context = ctx.State.As<Context>();
                _context._buffer = e.As<MessageEvent>().Message.As<BufferSlice>();
                _context._reader.Assign(_context._buffer);
                while (_context._parserMethod()) ;

                if (_context._isComplete)
                {
                    e.As<MessageEvent>().Message = _context._message;
                    OnComplete(ctx, e);
                }
                return;
            }

            ctx.SendUpstream(e);
        }
开发者ID:jmptrader,项目名称:griffin,代码行数:32,代码来源:Decoder.cs

示例4: ChannelRead

        public override void ChannelRead(IChannelHandlerContext context, object message)
        {
            var buffer = message as IByteBuffer;
            if (buffer != null)
            {
                int stringLength = buffer.ReadByte();
                var b = new byte[stringLength];
                buffer.ReadBytes(b, 0, b.Length);
                string instanceId = Encoding.UTF8.GetString(b);

                stringLength = buffer.ReadByte();
                b = new byte[stringLength];
                buffer.ReadBytes(b, 0, b.Length);
                string messageType = Encoding.UTF8.GetString(b);

                this.parent.SetInstanceIdChannel(instanceId, context.Channel);

                if (!this.clientConnectedInvoked)
                {
                    this.clientConnectedAction?.Invoke(instanceId, context.Channel.Id.AsShortText());
                    this.clientConnectedInvoked = true;
                }

                Task.Run(() =>
                {
                    this.dataReceivedAction(instanceId, context.Channel.Id.AsShortText(), messageType, buffer.ToArray());
                });
            }
        }
开发者ID:HakanL,项目名称:animatroller,代码行数:29,代码来源:NettyServerHandler.cs

示例5: ChannelActive

        //---------------------------------------------------------------------
        public async void ChannelActive(IChannelHandlerContext context)
        {
            this.context = context;
            listener.GatewaySession = this;

            await this.listener.OnSessionCreate();
        }
开发者ID:CragonGame,项目名称:GameCloud.Orleans,代码行数:8,代码来源:GatewaySession.cs

示例6: ChannelRead

 public override void ChannelRead(IChannelHandlerContext context, object message)
 {
     var buffer = (IByteBuffer)message;
     var data = buffer.ToArray();
     var transportMessage = _serializer.Deserialize<byte[], TransportMessage>(data);
     context.FireChannelRead(transportMessage);
 }
开发者ID:xiongeee,项目名称:Rpc,代码行数:7,代码来源:TransportMessageChannelHandlerAdapter.cs

示例7: HandleMessage

        protected override void HandleMessage(IChannelHandlerContext ctx, MessageEvent e)
        {
            var msg = (Message) e.Message;
            string contentType = msg.Headers["Content-Type"];

            var reader = new StreamReader(msg.Body);
            string body = reader.ReadToEnd();
            msg.Body.Position = 0;

            switch (contentType)
            {
                case "auth/request":
                    SendCommand("auth", _password);
                    break;
                case "command/reply":
                    {
                        Command cmd;
                        if (!_commands.TryPop(out cmd))
                            throw new InvalidOperationException(
                                "Failed to find a command for the recieved command/reply");
                        OnCommand(cmd, msg);
                    }

                    break;
                case "text/event-plain":
                    ParseEvent(msg.Body);
                    break;
                default:
                    break;
            }
        }
开发者ID:jmptrader,项目名称:griffin,代码行数:31,代码来源:ClientHandler.cs

示例8: ChannelInactive

 public override void ChannelInactive(IChannelHandlerContext context)
 {
     if (!WrappedTransport.ConnectionGroup.TryRemove(context.Channel))
     {
         Log.Warning("Unable to ADD channel [{0}->{1}](Id={2}) to connection group. May not shut down cleanly.",
             context.Channel.LocalAddress, context.Channel.RemoteAddress, context.Channel.Id);
     }
 }
开发者ID:Micha-kun,项目名称:akka.net,代码行数:8,代码来源:HeliosHelpers.cs

示例9: ChannelActive

        public override void ChannelActive(IChannelHandlerContext context)
        {
            log.Info($"Channel {context.Channel.Id.AsShortText()} connected");

            this.clientConnectedInvoked = false;

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

示例10: ChannelRead

 public override void ChannelRead(IChannelHandlerContext context, object message)
 {
     Received.Add((IByteBuf) message);
     if (++_actualReadCount == _expectedReadCount)
     {
         _readFinished.Set();
     }
 }
开发者ID:helios-io,项目名称:helios,代码行数:8,代码来源:TcpSocketChannelAndReactorCompatSpecs.cs

示例11: HandleDownstream

 /// <summary>
 /// Handle the data that is going to be sent to the remote end point
 /// </summary>
 /// <param name="ctx">Context information</param>
 /// <param name="e">Chennel event.</param>
 public void HandleDownstream(IChannelHandlerContext ctx, IChannelEvent e)
 {
     if (e is CloseEvent && _timer != null)
     {
         _timer.Dispose();
         _timer = null;
     }
 }
开发者ID:jmptrader,项目名称:griffin,代码行数:13,代码来源:AutoReconnector.cs

示例12: ChannelRead

 public override void ChannelRead(IChannelHandlerContext context, object message)
 {
     if (message is int)
     {
         State = State.ReceiveMessages((int) message);
         Logger.Debug("[Client-Read] Received: {0}", message);
     }
 }
开发者ID:helios-io,项目名称:helios,代码行数:8,代码来源:TcpClientSocketStateHandler.cs

示例13: ChannelRead

 public override void ChannelRead(IChannelHandlerContext context, object message)
 {
     ReferenceCountUtil.Release(message);
     if (++this.actualReads == this.expectedReads)
     {
         this.signal.Signal();
     }
 }
开发者ID:RabbitTeam,项目名称:DotNetty,代码行数:8,代码来源:ReadFinishedHandler.cs

示例14: Decode

 protected internal sealed override void Decode(IChannelHandlerContext context, IByteBuffer input, List<object> output)
 {
     object decode = this.Decode(context, input);
     if (decode != null)
     {
         output.Add(decode);
     }
 }
开发者ID:RabbitTeam,项目名称:DotNetty,代码行数:8,代码来源:LineBasedFrameDecoder.cs

示例15: PendingWriteQueue

        public PendingWriteQueue(IChannelHandlerContext ctx)
        {
            Contract.Requires(ctx != null);

            this.ctx = ctx;
            this.buffer = ctx.Channel.Unsafe.OutboundBuffer;
            this.estimatorHandle = ctx.Channel.Configuration.MessageSizeEstimator.NewHandle();
        }
开发者ID:l1183479157,项目名称:DotNetty,代码行数:8,代码来源:PendingWriteQueue.cs


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