コード例 #1
0
ファイル: MessageCenter.cs プロジェクト: iwiniwin/LastBattle
 public void SendCompleteBaseInfo(byte[] nickName, int headId, byte sex)
 {
     GCToCS.CompleteInfo msg = new GCToCS.CompleteInfo
     {
         nickname = System.Text.Encoding.UTF8.GetString(nickName),
         headid   = headId,
         sex      = sex,
     };
     NetworkManager.Instance.SendMsg(msg, (int)msg.msgnum);
 }
コード例 #2
0
        private ErrorCode OnMsgToGstoCsfromGcAskComleteUserInfo(CSGSInfo csgsInfo, uint gcNetID, byte[] data, int offset, int size)
        {
            CSUser csUser = this.GetUser(csgsInfo, gcNetID);

            if (null == csUser)
            {
                Logger.Error($"could not find user({csgsInfo.m_n32NSID})");
                return(ErrorCode.NullUser);
            }

            csUser.ResetPingTimer();
            ErrorCode errorCode = ErrorCode.Success;

            do
            {
                GCToCS.CompleteInfo completeInfo = new GCToCS.CompleteInfo();
                completeInfo.MergeFrom(data, offset, size);

                if (string.IsNullOrEmpty(completeInfo.Nickname))
                {
                    errorCode = ErrorCode.NickNameNotAllowed;
                    break;
                }
                //长度是否合法
                if (completeInfo.Nickname.Length > Consts.DEFAULT_NICK_NAME_LEN)
                {
                    errorCode = ErrorCode.NickNameNotAllowed;
                    break;
                }
                //昵称是否合法
                if (CS.instance.csCfg.CheckInvalidWorld(completeInfo.Nickname))
                {
                    errorCode = ErrorCode.NickNameNotAllowed;
                    break;
                }
                //是否和ai昵称冲突
                if (CS.instance.csCfg.CheckAIRobotName(completeInfo.Nickname))
                {
                    errorCode = ErrorCode.NickNameCollision;
                    break;
                }
                //是否存在相同昵称
                if (this.allNickNameSet.Contains(completeInfo.Nickname))
                {
                    errorCode = ErrorCode.NickNameCollision;
                    break;
                }

                csUser.userDbData.ChangeUserDbData(UserDBDataType.Sex, completeInfo.Sex);
                csUser.userDbData.ChangeUserDbData(UserDBDataType.HeaderId, completeInfo.Headid);
                this.ChangeUserNickName(csUser, completeInfo.Nickname);

                csUser.SynUser_UserBaseInfo();
                csUser.PostCSNotice();

                //todo
                //DBPosterUpdateUser( csUser );//存盘//

                string log = $"{csUser.userDbData.szUserName}{LOG_SIGN}{completeInfo.Headid}{completeInfo.Nickname}";
                //todo
                //CSSGameLogMgr::GetInstance().AddGameLog( eLog_HeadUse, mystream.str(), 0 );
            } while (false);

            if (ErrorCode.Success != errorCode)
            {
                this.PostMsgToGCAskReturn(csgsInfo, gcNetID, ( int )GCToCS.MsgNum.EMsgToGstoCsfromGcAskComleteUserInfo, errorCode);
            }

            return(errorCode);
        }