Exemplo n.º 1
0
        /// <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);
        }
Exemplo n.º 2
0
        public void AddSession(LazynetChannelHandlerContext channelHandlerContext)
        {
            var session = new LazynetSession()
            {
                Context = channelHandlerContext,
                ID      = SnowflakeUtil.Instance().GetString()
            };

            this.SessionGroup.Add(session);
        }
Exemplo n.º 3
0
 public LazynetSession Find(LazynetChannelHandlerContext ctx)
 {
     foreach (var item in SessionGroup.Values)
     {
         if (ctx == item.Context)
         {
             return(item);
         }
     }
     return(null);
 }
Exemplo n.º 4
0
 public void RemoveSession(LazynetChannelHandlerContext channelHandlerContext)
 {
     ServiceContext.RemoveSession(channelHandlerContext);
 }
Exemplo n.º 5
0
 public void AddSession(LazynetChannelHandlerContext channelHandlerContext)
 {
     ServiceContext.AddSession(channelHandlerContext);
 }
Exemplo n.º 6
0
 public void Write(LazynetChannelHandlerContext channelHandlerContext, string msg)
 {
     channelHandlerContext?.WriteAsync(msg);
 }
Exemplo n.º 7
0
        public void RemoveSession(LazynetChannelHandlerContext channelHandlerContext)
        {
            var session = this.SessionGroup.Find(channelHandlerContext);

            this.SessionGroup.Remove(session);
        }