Esempio n. 1
0
 //昵称是否可用,可用返回true,不可用返回false
 internal CheckNicknameResult CheckNickname(string accoountKey, string nickname)
 {
     lock (m_Lock) {
         CheckNicknameResult ret = CheckNicknameResult.Error;
         //验证昵称是否合法
         if (VerifyNickname(nickname))
         {
             RevertAccountNicknames(accoountKey);
             NicknameInfo wrap;
             //验证昵称是否已存在
             if (!m_UsedNicknames.TryGetValue(nickname, out wrap))
             {
                 if (!m_UnusedNicknames.TryRemove(nickname, out wrap))
                 {
                     wrap          = new NicknameInfo();
                     wrap.Nickname = nickname;
                     wrap.UserGuid = 1;
                 }
                 m_UsedNicknames.TryAdd(nickname, wrap);
                 ret = CheckNicknameResult.Success;
             }
             else
             {
                 ret = CheckNicknameResult.AlreadyUsed;
             }
         }
         return(ret);
     }
 }
Esempio n. 2
0
        internal void UpdateUsedNickname(string nickname, ulong userGuid)
        {
            NicknameInfo wrap = new NicknameInfo();

            wrap.Nickname = nickname;
            wrap.UserGuid = userGuid;
            m_UsedNicknames.AddOrUpdate(nickname, wrap, (n, g) => { g.UserGuid = userGuid; return(g); });
        }
Esempio n. 3
0
        //返还账号申请的昵称
        internal void RevertAccountNicknames(string accountId)
        {
            List <string> abortNicknameList = null;

            if (m_AccountReqNicknames.TryGetValue(accountId, out abortNicknameList))
            {
                foreach (string nickname in abortNicknameList)
                {
                    NicknameInfo wrap;
                    if (!m_UsedNicknames.TryRemove(nickname, out wrap))
                    {
                        wrap          = new NicknameInfo();
                        wrap.Nickname = nickname;
                    }
                    wrap.UserGuid = 0;
                    m_UnusedNicknames.AddOrUpdate(nickname, wrap, (g, u) => { u.UserGuid = 0; return(u); });
                }
                m_AccountReqNicknames.TryRemove(accountId, out abortNicknameList);
            }
        }
Esempio n. 4
0
        //创建昵称数据
        internal void CreateData()
        {
            string prefix = "Temp_";
            int    index  = 0;

            while (true)
            {
                string       name = string.Format("{0}{1}", prefix, index);
                NicknameInfo data;
                if (!m_UnusedNicknames.TryGetValue(name, out data))
                {
                    data          = new NicknameInfo();
                    data.Nickname = name;
                    data.UserGuid = 0;
                    m_UnusedNicknames.TryAdd(name, data);
                    index++;
                }
                if (index >= c_NumberForCreate)
                {
                    break;
                }
            }
        }
Esempio n. 5
0
 //初始化昵称数据,程序启动时从数据库中加载
 internal void InitNicknameData(List <TableNicknameInfo> nicknameList)
 {
     if (nicknameList.Count > 0)
     {
         foreach (var dataNickname in nicknameList)
         {
             NicknameInfo wrap = new NicknameInfo();
             wrap.FromProto(dataNickname);
             if (dataNickname.UserGuid > 0)
             {
                 m_UsedNicknames.TryAdd(dataNickname.Nickname, wrap);
             }
             else
             {
                 m_UnusedNicknames.TryAdd(dataNickname.Nickname, wrap);
             }
         }
     }
     else
     {
         CreateData();
     }
     //m_IsDataLoaded = true;
 }
 //昵称是否可用,可用返回true,不可用返回false
 internal CheckNicknameResult CheckNickname(string accoountKey, string nickname)
 {
     lock (m_Lock) {
     CheckNicknameResult ret = CheckNicknameResult.Error;
     //验证昵称是否合法
     if (VerifyNickname(nickname)) {
       RevertAccountNicknames(accoountKey);
       NicknameInfo wrap;
       //验证昵称是否已存在
       if (!m_UsedNicknames.TryGetValue(nickname, out wrap)) {
     if (!m_UnusedNicknames.TryRemove(nickname, out wrap)) {
       wrap = new NicknameInfo();
       wrap.Nickname = nickname;
       wrap.UserGuid = 1;
     }
     m_UsedNicknames.TryAdd(nickname, wrap);
     ret = CheckNicknameResult.Success;
       } else {
     ret = CheckNicknameResult.AlreadyUsed;
       }
     }
     return ret;
       }
 }
 //创建昵称数据
 internal void CreateData()
 {
     string prefix = "Temp_";
       int index = 0;
       while (true) {
     string name = string.Format("{0}{1}", prefix, index);
     NicknameInfo data;
     if (!m_UnusedNicknames.TryGetValue(name, out data)) {
       data = new NicknameInfo();
       data.Nickname = name;
       data.UserGuid = 0;
       m_UnusedNicknames.TryAdd(name, data);
       index++;
     }
     if (index >= c_NumberForCreate) {
       break;
     }
       }
 }
 internal void UpdateUsedNickname(string nickname, ulong userGuid)
 {
     NicknameInfo wrap = new NicknameInfo();
       wrap.Nickname = nickname;
       wrap.UserGuid = userGuid;
       m_UsedNicknames.AddOrUpdate(nickname, wrap, (n, g) => { g.UserGuid = userGuid; return g; });
 }
 //返还账号申请的昵称
 internal void RevertAccountNicknames(string accountId)
 {
     List<string> abortNicknameList = null;
       if (m_AccountReqNicknames.TryGetValue(accountId, out abortNicknameList)) {
     foreach (string nickname in abortNicknameList) {
       NicknameInfo wrap;
       if (!m_UsedNicknames.TryRemove(nickname, out wrap)) {
     wrap = new NicknameInfo();
     wrap.Nickname = nickname;
       }
       wrap.UserGuid = 0;
       m_UnusedNicknames.AddOrUpdate(nickname, wrap, (g, u) => { u.UserGuid = 0; return u; });
     }
     m_AccountReqNicknames.TryRemove(accountId, out abortNicknameList);
       }
 }
 //初始化昵称数据,程序启动时从数据库中加载
 internal void InitNicknameData(List<TableNicknameInfo> nicknameList)
 {
     if (nicknameList.Count > 0) {
     foreach (var dataNickname in nicknameList) {
       NicknameInfo wrap = new NicknameInfo();
       wrap.FromProto(dataNickname);
       if (dataNickname.UserGuid > 0) {
     m_UsedNicknames.TryAdd(dataNickname.Nickname, wrap);
       } else {
     m_UnusedNicknames.TryAdd(dataNickname.Nickname, wrap);
       }
     }
       } else {
     CreateData();
       }
       //m_IsDataLoaded = true;
 }