public override void UserEventTriggered(IChannelHandlerContext context, object evt) { //用户断开连接事件。。包括超时。客户端主动断开 if (evt is ClientDisconnectEvent) { var eventState = evt as ClientDisconnectEvent; var child = eventState.Channel; channelGroup.Remove(child); } else { context.FireUserEventTriggered(evt); } }
//channel.Pipeline.DisconnectAsync(超时)会触发inactive和unregistered。。。 //客户端主动关闭(代码调用closeasync)的时候也会触发inactive和unregistered public override void ChannelInactive(IChannelHandlerContext context) { base.ChannelInactive(context); channelGroup.Remove(context.Channel); }