Ejemplo n.º 1
0
        /// <summary>
        /// 查询玩家数据的回调函数
        /// 把数据库的所有玩家数据取回内存
        /// </summary>
        private void SynHandleAllAccountCallback(GBuffer buffer)
        {
            DBToCS.QueryAllAccount msg = new DBToCS.QueryAllAccount();
            msg.MergeFrom(buffer.GetBuffer(), 0, ( int )buffer.length);

            for (int i = 0; i < msg.Account.Count; ++i)
            {
                DBToCS.QueryAllAccount.Types.Account pAccount = msg.Account[i];
                //取回所有昵称
                if (!string.IsNullOrEmpty(pAccount.Nickname))
                {
                    this.allNickNameSet.Add(pAccount.Nickname);
                }

                UserCombineKey userCombineKey;
                userCombineKey.sdkid    = pAccount.Sdkid;
                userCombineKey.username = pAccount.UserName;

                ulong guid = ( ulong )pAccount.Guid;
                //取回所有guid
                this.allUserName2GuidMap.Add(userCombineKey, guid);
                if (this._maxGuid < guid)
                {
                    this._maxGuid = guid;
                }
            }
            this._maxGuid /= GUID_Devide;
            Logger.Log($"load maxguid {this._maxGuid}");
        }
Ejemplo n.º 2
0
 private void CDKThreadBeginCallback()
 {
     this._cdkeyWrapper.SqlExecQuery($"select id,sdk_id,cdkey,user_name from account_user where cs_id={CS.instance.csID};", dataReader =>
     {
         DBToCS.QueryAllAccount queryAllAccount = new DBToCS.QueryAllAccount();
         while (dataReader.Read())
         {
             DBToCS.QueryAllAccount.Types.Account account =
                 new DBToCS.QueryAllAccount.Types.Account
             {
                 Guid     = dataReader.GetInt64("id"),
                 UserName = dataReader.GetString("cdkey"),
                 Nickname = dataReader.IsDBNull(3) ? string.Empty : dataReader.GetString(3),
                 Sdkid    = dataReader.GetInt32("sdk_id")
             };
             queryAllAccount.Account.Add(account);
         }
         if (dataReader.HasRows)
         {
             CS.instance.userMgr.EncodeAndSendToLogicThread(queryAllAccount, ( int )DBToCS.MsgID.EQueryAllAccountCallBack);
         }
         return(ErrorCode.Success);
     });
 }