Esempio n. 1
0
        /// <summary>
        /// 关闭某个socket对应的角色连接
        /// </summary>
        /// <param name="s"></param>
        public void ForceCloseSocket(TMSKSocket s)
        {
            //删除延迟关闭的TMSKSocket信息
            DelayForceClosingMgr.RemoveDelaySocket(s);

            //将接收的缓冲删除
            lock (dictInPackets)
            {
                if (dictInPackets.ContainsKey(s))
                {
                    TCPInPacket tcpInPacket = dictInPackets[s];
                    tcpInPacketPool.Push(tcpInPacket); //缓冲回收
                    dictInPackets.Remove(s);
                }
            }

            //删除客户端信息
            GameClient gameClient = GameManager.ClientMgr.FindClient(s);

            if (null != gameClient)
            {
                //客户端离线
                GameManager.ClientMgr.Logout(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, gameClient);
                gameClient = null;
            }

            string userID = GameManager.OnlineUserSession.FindUserID(s);

            //添加到在线回话中
            GameManager.OnlineUserSession.RemoveSession(s);

            //删除用户名称
            GameManager.OnlineUserSession.RemoveUserName(s);

            //删除用户是否成人标志
            GameManager.OnlineUserSession.RemoveUserAdult(s);

            //注销UserID, 放到最后,但是获取userID放前边
            if ("" != userID)
            {
                Global.RegisterUserIDToDBServer(userID, 0);
            }

            //已经关闭之后再调用一次
            Global._SendBufferManager.Remove(s);

            //通知主窗口显示连接数
            //RootWindow.Dispatcher.BeginInvoke((MethodInvoker)delegate
            //{
            //    // 通知界面修改连接数
            //    RootWindow.textBlock1.Text = string.Format("{0}/{1}", GameManager.ClientMgr.GetClientCount(), socketListener.ConnectedSocketsCount);
            //});
        }
Esempio n. 2
0
        public void ForceCloseSocket(TMSKSocket s)
        {
            DelayForceClosingMgr.RemoveDelaySocket(s);
            lock (this.dictInPackets)
            {
                if (this.dictInPackets.ContainsKey(s))
                {
                    TCPInPacket tcpInPacket = this.dictInPackets[s];
                    this.tcpInPacketPool.Push(tcpInPacket);
                    this.dictInPackets.Remove(s);
                }
            }
            bool       bIsExistClient = false;
            GameClient gameClient     = GameManager.ClientMgr.FindClient(s);

            if (null != gameClient)
            {
                GameManager.ClientMgr.Logout(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, gameClient);
                bIsExistClient = true;
            }
            string userID = GameManager.OnlineUserSession.FindUserID(s);

            GameManager.OnlineUserSession.RemoveSession(s);
            GameManager.OnlineUserSession.RemoveUserName(s);
            GameManager.OnlineUserSession.RemoveUserAdult(s);
            if (!string.IsNullOrEmpty(userID))
            {
                Global.RegisterUserIDToDBServer(userID, 0, s.ServerId, ref s.session.LastLogoutServerTicks);
            }
            GameManager.loginWaitLogic.RemoveWait(userID);
            if (!bIsExistClient)
            {
                GameManager.loginWaitLogic.RemoveAllow(userID);
            }
            Global._SendBufferManager.Remove(s);
        }