void ChannelUnregistered(IChannelHandlerContext context) { var id = context.Channel.Id.AsLongText(); Log.Info("ChannelUnregistered: " + id); group.Remove(context.Channel); channelHandlerContexts.TryRemove(id, out IChannelHandlerContext channelHandlerContext); }
//客户端下线断线时 public override void HandlerRemoved(IChannelHandlerContext context) { RecordLogEvent?.Invoke($"客户端{context}下线."); base.HandlerRemoved(context); groups.Remove(context.Channel); //groups.WriteAndFlushAsync($"恭送{context.Channel.RemoteAddress}离开."); //SimpleEventBus.GetDefaultEventBus().Post("下线:" + context, TimeSpan.Zero); }
// The Channel is closed hence the connection is closed public override void ChannelInactive(IChannelHandlerContext ctx) { IChannelGroup g = Group; Logger.Warn("Client disconnected"); // Remove g?.Remove(ctx.Channel); // Send event upstream OnChannelInactive?.Invoke(ctx.Channel); }
//--------------------------------------------------------------------- public override void ChannelInactive(IChannelHandlerContext context) { IChannelGroup g = Gateway.Instance.ChannelGroup; if (g != null) { g.Remove(context.Channel); } if (this.session != null) { this.session.ChannelInactive(context); this.session = null; } }
public override void ChannelInactive(IChannelHandlerContext context) { lock (_mutex) { _channels.Remove(context.Channel); if (_channels.Count == 0) { _worker.Stop(); } } var state = context.Channel.GetAttribute(ChannelAttributes.State).Get(); if (state.ServerId != null) { AuthServer.Instance.ServerManager.Remove(state.ServerId.Value); } base.ChannelInactive(context); }
//--------------------------------------------------------------------- public override void ExceptionCaught(IChannelHandlerContext context, Exception exception) { IChannelGroup g = Gateway.Instance.ChannelGroup; if (g != null) { g.Remove(context.Channel); } if (exception is System.ObjectDisposedException) { // do nothting } else { Console.WriteLine("Exception: \n" + exception); } context.CloseAsync(); }