Пример #1
0
        /// <summary>
        /// 读写超时通知
        /// </summary>
        /// <param name="ctx"></param>
        /// <param name="evt"></param>
        public override void UserEventTriggered(IChannelHandlerContext ctx, object evt)
        {
            base.UserEventTriggered(ctx, evt);
            if (evt is IdleStateEvent)
            {
                var eventState = evt as IdleStateEvent;
                if (eventState != null)
                {
                    switch (eventState.State)
                    {
                    // 长时间未读取到数据,则发送心跳数据
                    case IdleState.ReaderIdle:
                        ClientEventHandler.SendPingMsg(ctx);
                        break;

                    case IdleState.WriterIdle:
                        break;

                    case IdleState.AllIdle:
                        break;
                    }
                }
            }
        }
 /// <summary>
 /// 读写超时通知
 /// </summary>
 /// <param name="ctx"></param>
 /// <param name="evt"></param>
 public override void UserEventTriggered(IChannelHandlerContext ctx, object evt)
 {
     base.UserEventTriggered(ctx, evt);
     ClientEventHandler.SendPingMsg(ctx);
 }