/// <summary> /// 断线 /// </summary> /// <param name="ctx"></param> public void Inactive(LazynetChannelHandlerContext ctx) { var parameters = new object[] { ctx, ctx.Channel.RemoteAddress.ToString() }; var serviceMessage = new LazynetServiceMessage(LazynetMessageType.Normal, ServiceContext.SocketEvent.InactiveEvent, parameters); ServiceContext.Context.RecvMessage(ServiceContext.ID, serviceMessage); }
public void AddSession(LazynetChannelHandlerContext channelHandlerContext) { var session = new LazynetSession() { Context = channelHandlerContext, ID = SnowflakeUtil.Instance().GetString() }; this.SessionGroup.Add(session); }
public LazynetSession Find(LazynetChannelHandlerContext ctx) { foreach (var item in SessionGroup.Values) { if (ctx == item.Context) { return(item); } } return(null); }
public void RemoveSession(LazynetChannelHandlerContext channelHandlerContext) { ServiceContext.RemoveSession(channelHandlerContext); }
public void AddSession(LazynetChannelHandlerContext channelHandlerContext) { ServiceContext.AddSession(channelHandlerContext); }
public void Write(LazynetChannelHandlerContext channelHandlerContext, string msg) { channelHandlerContext?.WriteAsync(msg); }
public void RemoveSession(LazynetChannelHandlerContext channelHandlerContext) { var session = this.SessionGroup.Find(channelHandlerContext); this.SessionGroup.Remove(session); }