Пример #1
0
        void RunTaskNetStateConnect(NetState netState)
        {
            //  通知业务逻辑有客户端连接上来可以做一些初始化
            //  或者判断是否允许本次连接
            var tempEV = NetStateConnect;

            if (tempEV != null)
            {
                var arg = new NetStateConnectEventArgs
                {
                    NetState     = netState,
                    AllowConnect = true
                };
                tempEV(this, arg);
                if (arg.AllowConnect == false)
                {
                    netState.Dispose();
                    return;
                }
            }
            netState.Serial = netStateId++;

            m_netStateManager.InternalAddNetState(netState.Serial, netState);
            netState.Start();
        }
Пример #2
0
 private void OnNetStateConnect(object sender, NetStateConnectEventArgs e)
 {
     Logs.Info("有人连上服务器拉~ {0}", e.NetState.NetAddress);
     if (WorldEntityManager.OnlinePlayers.Count > 9999)
     {
         //  在这里可以对人数连接上线做限制
         //  e.AllowConnect = false;
     }
 }
Пример #3
0
        void RunTaskNetStateConnect(NetState netState)
        {
            //  通知业务逻辑有客户端连接上来可以做一些初始化
            //  或者判断是否允许本次连接
            var tempEV = NetStateConnect;
            if (tempEV != null)
            {
                var arg = new NetStateConnectEventArgs
                {
                    NetState = netState,
                    AllowConnect = true
                };
                tempEV(this, arg);
                if (arg.AllowConnect == false)
                {
                    netState.Dispose();
                    return;
                }
            }
            netState.Serial = netStateId++;

            m_netStateManager.InternalAddNetState(netState.Serial, netState);
            netState.Start();
        }