コード例 #1
0
        //删除用户
        public bool DeleteUserItem(IClientUserItem pIClientUserItem)
        {
            //查找用户
            CClientUserItem pUserItemActive = null;

            for (int i = 0, l = (int)m_UserItemActive.Count; i < l; i++)
            {
                pUserItemActive = m_UserItemActive[i];
                if (pIClientUserItem == pUserItemActive)
                {
                    //删除用户
                    m_UserItemActive.RemoveAt(i);
                    //m_UserItemActive.erase(m_UserItemActive.begin() + i);
                    addPool(pUserItemActive);

                    //删除通知
                    if (m_pIUserManagerSink != null)
                    {
                        m_pIUserManagerSink.OnUserItemDelete(pUserItemActive);
                    }

                    //设置数据
                    pUserItemActive.m_cbCompanion = SocketDefines.CP_NORMAL;
                    pUserItemActive.m_UserInfo    = new tagUserInfo();
                    pUserItemActive.m_UserInfo.Init();
                    //zeromemory(&pUserItemActive.m_UserInfo, sizeof(tagUserInfo));
                    return(true);
                }
            }

            //错误断言
            Debug.Assert(false, "DeleteUserItem failed");

            return(false);
        }
コード例 #2
0
        void addPool(CClientUserItem pIClientUserItem)
        {
            if (m_PoolItem.Contains(pIClientUserItem))
            {
                return;
            }

            m_PoolItem.Add(pIClientUserItem);
        }
コード例 #3
0
 //查找用户
 public IClientUserItem SearchUserByNickName(byte[] pszNickName)
 {
     //用户搜索
     for (int i = 0, l = (int)m_UserItemActive.Count; i < l; i++)
     {
         CClientUserItem pClientUserItem = m_UserItemActive[i];
         byte[]          pszTempNickName = pClientUserItem.GetNickName();
         if (pszNickName == pszTempNickName)
         {
             return(pClientUserItem);
         }
     }
     return(null);
 }
コード例 #4
0
        //查找用户
        public IClientUserItem SearchUserByGameID(uint dwGameID)
        {
            //用户搜索
            for (int i = 0, l = (int)m_UserItemActive.Count; i < l; i++)
            {
                CClientUserItem pClientUserItem = m_UserItemActive[i];
                if (pClientUserItem.m_UserInfo.dwGameID == dwGameID)
                {
                    return(pClientUserItem);
                }
            }

            return(null);
        }
コード例 #5
0
        CClientUserItem getPool()
        {
            CClientUserItem pClient = null;

            if (m_PoolItem.Count > 0)
            {
                pClient = m_PoolItem.Last();
                m_PoolItem.RemoveAt(m_PoolItem.Count - 1);
                return(pClient);
            }
            pClient = new CClientUserItem();
            m_UserItemActive.Add(pClient);
            return(pClient);
        }
コード例 #6
0
        //增加用户
        public IClientUserItem ActiveUserItem(tagUserInfo UserInfo, tagCustomFaceInfo CustomFaceInfo)
        {
            //变量定义
            CClientUserItem pClientUserItem = (CClientUserItem)SearchUserByUserID(UserInfo.dwUserID);

            if (pClientUserItem == null)
            {
                pClientUserItem = new CClientUserItem();
                if (pClientUserItem == null)
                {
                    return(null);
                }

                //插入用户
                m_UserItemActive.Add(pClientUserItem);
            }


            pClientUserItem.m_szUserNote[0] = 0;
            pClientUserItem.m_cbCompanion   = SocketDefines.CP_NORMAL;

            //设置数据
            pClientUserItem.m_UserInfo       = UserInfo;
            pClientUserItem.m_CustomFaceInfo = CustomFaceInfo;
            //memcpy(&pClientUserItem.m_UserInfo, &UserInfo, sizeof(UserInfo));
            //memcpy(&pClientUserItem.m_CustomFaceInfo, &CustomFaceInfo, sizeof(CustomFaceInfo));

            //更新通知

            if (m_pIUserManagerSink != null)
            {
                m_pIUserManagerSink.OnUserItemAcitve(pClientUserItem);
            }


            return(pClientUserItem);
        }