Beispiel #1
0
 public void StateChange(StateChange state)
 {
     if (state.IpAddress.Equals("") && state.State == 1)
     {
         Task.Run(() =>
         {
         });
     }
 }
        public override void ChannelActive(IChannelHandlerContext context)
        {
            base.ChannelActive(context);
            //使用键值对,记住所有连接
            ServerConn.ServersDic.AddOrUpdate(HelperClasss.GetAddress(context.Channel.RemoteAddress), context, (k, v) => context);
            //根据IP判定状态 使用事件触发
            StateChange stateChange = new StateChange()
            {
                State     = 1,
                IpAddress = HelperClasss.GetAddress(context.Channel.RemoteAddress),
            };

            EventBusUtil._eventBus.Post(stateChange);
        }