Ejemplo n.º 1
0
        ////////////////////////////////////// 响应 ////////////////////////////////////
        private void LoginResponse(bool send, DecodeRspResult res, Action <ResponseEvent> callback)
        {
            if (send)
            {
                UserStatus.SetStatus(UserStatus.StatusType.Logout);
            }

            var rsp = (LoginRsp)res.Body;
            var eve = new ResponseEvent(res.RspWrap1.ErrCode, res.RspWrap1.ErrMsg, res.RspWrap1.Seq, rsp);

            Debugger.Log("LoginResponse {0}", eve);

            NetClient.HandleSuccess(eve.Code, () => {
                if (eve.Code == ErrCode.EcOk)
                {
                    RequestHeader.AuthKey  = rsp.Token;
                    RequestHeader.PlayerId = rsp.PlayerId;
                    var messageData        = rsp;

                    // 更新状态
                    UserStatus.SetStatus(UserStatus.StatusType.Login);

                    // 设置 PlayerInfo
                    if (string.IsNullOrEmpty(GamePlayerInfo.GetInfo().Id))
                    {
                        GamePlayerInfo.SetInfo(messageData.PlayerId);
                    }
                }
            });
            UserStatus.SetErrCode(eve.Code, eve.Msg);
            callback?.Invoke(eve);
        }