Exemplo n.º 1
0
        /// <summary>
        /// 发送手机验证码
        /// </summary>
        public void OnSendAuthCodeClick()
        {
#if UNITY_EDITOR
            if (m_currentTimerTime == 0)
            {
                m2s_addmessagesession msg = new m2s_addmessagesession();
                msg.name        = m_userNameField.text.Trim();
                msg.messagetype = "1";
                M2SInfo m2sInfo = new M2SInfo(msg, MsgSuccessAuthCode, MsgFailure);
                GameEntry.WebRequestToServerComponent.SendJsonMsg(m2sInfo);
            }
#else
            if (m_currentTimerTime == 0)
            {
                if (m_userNameField.text.Trim().Length != 11)
                {
                    return;
                }
                m2s_addmessagesession msg = new m2s_addmessagesession();
                msg.name        = m_userNameField.text.Trim();
                msg.messagetype = "1";
                M2SInfo m2sInfo = new M2SInfo(msg, MsgSuccessAuthCode, MsgFailure);
                GameEntry.WebRequestToServerComponent.SendJsonMsg(m2sInfo);
            }
#endif
        }
Exemplo n.º 2
0
        /// <summary>
        ///游客登录
        /// </summary>
        public void VisitorLogin()
        {
            m2s_logintourist msg  = new m2s_logintourist();
            M2SInfo          info = new M2SInfo(msg, success, fail);

            GameEntry.WebRequestToServerComponent.SendJsonMsg(info);
        }
        /// <summary>
        /// 发送消息到服务端
        /// </summary>
        /// <param name="m2s"></param>
        public void SendJsonMsg(M2SInfo m2s)
        {
            if (gameOver)
            {
                return;
            }
            m2s.msg.uid = userid;
            m2s.msg.rid = roleid;
            string url = GameServerUrl + m2s.msg.msgName;

            if (userid == "")//鉴权服务器
            {
                m2s.msg.session = ausession;
                url             = GetGameLoginServerUrl() + m2s.msg.msgName;
            }
            else//游戏服务器
            {
                m2s.msg.session = session;
                url             = GameServerUrl + m2s.msg.msgName;
            }

            //if (!m2s.ignoreConnectStatue)
            //{
            //    GameEntry.UI.OpenUIForm(UIFormId.ConnectForm);
            //}


            byte[] jsonDataPost = Utility.Json.ToJsonData(m2s.msg);
            GameEntry.WebRequest.AddWebRequest(url, jsonDataPost, m2s);
        }
Exemplo n.º 4
0
        void GetUserBag()
        {
            m2s_getacticlebyuid msg = new m2s_getacticlebyuid();

            M2SInfo m2sInfo = new M2SInfo(msg, GetUserBagSuccess, WebRequestFail);

            GameEntry.WebRequestToServerComponent.SendJsonMsg(m2sInfo);
        }
Exemplo n.º 5
0
        /// <summary>
        /// 更新分数
        /// </summary>
        public void UpdateRankData()
        {
            m2s_getranklistbyuidbtid msg = new m2s_getranklistbyuidbtid();

            msg.num = "10";
            M2SInfo m2sInfo = new M2SInfo(msg, UpdateRankDataSuccess, WebRequestFail);

            GameEntry.WebRequestToServerComponent.SendJsonMsg(m2sInfo);
        }
        //获取高尔夫信息
        void GetServerRewardMap()
        {
            m2s_getgolfislands msg = new m2s_getgolfislands();

            msg.mid = GameEntry.GameData.ShopName.ToString();
            M2SInfo m2sInfo = new M2SInfo(msg, GetServerRewardMapSuccess, MsgFailureLogin);

            GameEntry.WebRequestToServerComponent.SendJsonMsg(m2sInfo);
        }
Exemplo n.º 7
0
        void AddGoods(int goodsId)
        {
            m2s_exchangeshop msg = new m2s_exchangeshop();

            msg.shopid = goodsId;
            M2SInfo m2sInfo = new M2SInfo(msg, AddGoodsSuccess, WebRequestFail);

            GameEntry.WebRequestToServerComponent.SendJsonMsg(m2sInfo);
        }
Exemplo n.º 8
0
        /// <summary>
        /// 上传分数
        /// </summary>
        public void UploadRankData()
        {
            m2s_updateranking msg = new m2s_updateranking();

            msg.score = GameEntry.GameData.totalScore.ToString();
            M2SInfo m2sInfo = new M2SInfo(msg, UploadRankDataSuccess, WebRequestFail);

            GameEntry.WebRequestToServerComponent.SendJsonMsg(m2sInfo);
        }
Exemplo n.º 9
0
        /// <summary>
        /// 改名
        /// </summary>
        void ChangeUserName()
        {
            m2s_updatenickname msg = new m2s_updatenickname();

            msg.nickname = GameEntry.GameData.WxName;
            M2SInfo m2sInfo = new M2SInfo(msg, ChangeUserNameSuccess, WebRequestFail);

            GameEntry.WebRequestToServerComponent.SendJsonMsg(m2sInfo);
        }
Exemplo n.º 10
0
        //击球点
        void GetKickoffPosition(int gmid)
        {
            m2s_getkickoffposition msg = new m2s_getkickoffposition();

            msg.mid  = GameEntry.GameData.ShopName.ToString();
            msg.gmid = gmid;
            M2SInfo m2sInfo = new M2SInfo(msg, GetKickoffPositionSuccess, MsgFailureLogin);

            GameEntry.WebRequestToServerComponent.SendJsonMsg(m2sInfo);
        }
Exemplo n.º 11
0
        //设备信息
        void GetGolfMachine()
        {
            m2s_getgolfmachine msg = new m2s_getgolfmachine();

            msg.mid  = GameEntry.GameData.ShopName.ToString();
            msg.name = GameEntry.GameData.boxName;
            M2SInfo m2sInfo = new M2SInfo(msg, GetGolfMachineSuccess, MsgFailureLogin);

            GameEntry.WebRequestToServerComponent.SendJsonMsg(m2sInfo);
        }
Exemplo n.º 12
0
        /// <summary>
        /// 获取用户信息
        /// </summary>
        /// <param name="auid"></param>
        void GetUserInfo()
        {
            m2s_getuserinfo msg = new m2s_getuserinfo();

            msg.auid    = GameEntry.WebRequestToServerComponent.auid;
            msg.session = GameEntry.WebRequestToServerComponent.session;
            M2SInfo m2sInfo = new M2SInfo(msg, GetUserInfoSuccess, MsgFailureLogin);

            GameEntry.WebRequestToServerComponent.SendJsonMsg(m2sInfo);
        }
        /// <summary>
        /// 接收服务端的返回消息
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnWebRequestSuccess(object sender, GameEventArgs e)
        {
            WebRequestSuccessEventArgs ne = (WebRequestSuccessEventArgs)e;
            M2SInfo msgBase = ne.UserData as M2SInfo;

            if (msgBase == null)
            {
                return;
            }
            //if (!msgBase.ignoreConnectStatue)
            //{
            //    if (connectForm != null)
            //    {
            //        if (connectForm.isActiveAndEnabled)
            //        {
            //            connectForm.CloseConnectForm(true);
            //        }
            //        closeConnectFormFailure = false;
            //    }
            //    else
            //    {
            //        closeConnectFormFailure = true;
            //    }
            //}


            string responseJson = Utility.Converter.GetString(ne.GetWebResponseBytes());

            Debug.Log("服务器返回消息:\n" + responseJson);
            //JsonData data = JsonMapper.ToObject(responseJson);
            if (ne.UserData != null)
            {
                JsonData res = JsonMapper.ToObject(responseJson);
                //string resultCode = "0";
                //if (res.Inst_Object.Keys.Contains("respVo"))
                //    resultCode = res["respVo"]["resultCode"].ToString();
                //else if(res.Inst_Object.Keys.Contains("resultCode"))
                //    resultCode = res["resultCode"].ToString();
                //if (resultCode == "-8")
                //{
                //    Debug.Log("session error,please restart game!");
                //    gameOver = true;
                //    GameEntry.UI.OpenDialog(new DialogParams()
                //    {
                //        Mode = 1,
                //        Title = GameEntry.Localization.GetString("WebRequestToServer.SessionTip"),
                //        Message = GameEntry.Localization.GetString("WebRequestToServer.SessionError"),
                //        OnClickConfirm = delegate (object userData) { UnityGameFramework.Runtime.GameEntry.Shutdown(UnityGameFramework.Runtime.ShutdownType.Quit); },
                //    });
                //}
                msgBase.msg.MsgAnalysis(res, msgBase.SuccessAction);
                return;
            }
        }
Exemplo n.º 14
0
        void GetQRCodeUrl()
        {
            m2s_getgolfmachine msg = new m2s_getgolfmachine();

            msg.mid  = GameEntry.GameData.ShopName.ToString();
            msg.name = GameEntry.GameData.boxName;
            M2SInfo m2sInfo = new M2SInfo(msg, GetQRCodeUrlSuccess, MsgFailureLogin);

            byte[] jsonDataPost = Utility.Json.ToJsonData(m2sInfo.msg);
            GameEntry.WebRequest.AddWebRequest("http://47.100.175.248:6077/" + msg.msgName, jsonDataPost, m2sInfo);
        }
Exemplo n.º 15
0
        /// <summary>
        /// 向服务器发送注册信息
        /// </summary>
        public void SendRegesitMessage()
        {
            m2s_regist msg = new m2s_regist();

            msg.name    = m_userNameField.text.Trim();
            msg.pwd     = m_passWordField.text.Trim();
            msg.message = m_authCodeField.text.Trim();

            msg.gid = "1";
            M2SInfo m2sInfo = new M2SInfo(msg, MsgSuccessLogin, MsgFailureLogin);

            GameEntry.WebRequestToServerComponent.SendJsonMsg(m2sInfo);
        }
Exemplo n.º 16
0
        /// <summary>
        /// 向服务器发送登录信息
        /// </summary>
        public void SendLoginMessage(string userName, string passWord)
        {
            currentUserName = userName;
            currentPsd      = passWord;
            m_loginConcent.SetActive(true);
            m2s_login msg = new m2s_login();

            msg.name = userName;
            msg.pwd  = passWord;
            msg.gid  = "4";
            M2SInfo m2sInfo = new M2SInfo(msg, MsgSuccessLogin, MsgFailureLogin);

            GameEntry.WebRequestToServerComponent.SendJsonMsg(m2sInfo);
        }
Exemplo n.º 17
0
        void Logout(object obj)
        {
            m2c_fortencentrequest m2c = (m2c_fortencentrequest)obj;

            m2s_deltencentrequest msg = new m2s_deltencentrequest();

            if (MachineId == 0)
            {
                return;
            }
            msg.mid = MachineId;
            M2SInfo m2sInfo = new M2SInfo(msg, LogoutSuccess, MsgFailureLogin);

            GameEntry.WebRequestToServerComponent.SendJsonMsg(m2sInfo);
        }
Exemplo n.º 18
0
        void AddGoods(int goodsId)
        {
            if (goodsId == 0)
            {
                return;
            }

            redPoint.SetActive(true);
            add = true;
            count++;
            m2s_exchangeshop msg = new m2s_exchangeshop();

            msg.shopid = goodsId;
            M2SInfo m2sInfo = new M2SInfo(msg, AddGoodsSuccess, WebRequestFail);

            GameEntry.WebRequestToServerComponent.SendJsonMsg(m2sInfo);
        }
Exemplo n.º 19
0
        void DeleteGoods(int goodsId)
        {
            DetailView.SetActive(true);
            m2s_updateacticlenum msg = new m2s_updateacticlenum();

            msg.id             = 0;//固定传0
            msg.acticle        = new Goods();
            msg.acticle.sid    = goodsId;
            msg.acticle.uid    = GameEntry.WebRequestToServerComponent.userid;
            msg.acticle.num    = -1;         //固定传-1
            msg.acticle.enable = 0;          //固定传0
            QRCode.SetActive(false);
            DetailView.SetActive(false);
            M2SInfo m2sInfo = new M2SInfo(msg, DeleteGoodsSuccess, WebRequestFail);

            GameEntry.WebRequestToServerComponent.SendJsonMsg(m2sInfo);
        }
Exemplo n.º 20
0
        /// <summary>
        /// 连接游戏服务器
        /// </summary>
        void SendChooseServerMessage()
        {
            serverMap m_serverMap = ServerListInfo.ServerDic["7"];

            if (m_serverMap.load == "-1")
            {
                GameEntry.Event.Fire(this, new ShowMessageEventArgs("服务器维护中..."));
                return;
            }

            m2s_getsession msg = new m2s_getsession();

            msg.name      = currentUserName;
            msg.serverid  = m_serverMap.id;
            msg.serverurl = "http://" + m_serverMap.ip + ":" + m_serverMap.port + "/";
            msg.gid       = "4";
            M2SInfo m2sInfo = new M2SInfo(msg, ChooseServerSuccess, MsgFailureLogin);

            GameEntry.WebRequestToServerComponent.SendJsonMsg(m2sInfo);
        }
Exemplo n.º 21
0
        void CheckQRCodeState()
        {
            m2s_fortencentrequest msg = new m2s_fortencentrequest();

            if (MachineId == 0)
            {
                return;
            }
            msg.mid = MachineId;
            M2SInfo m2sInfo;

            if (needLogout)
            {
                m2sInfo = new M2SInfo(msg, Logout, MsgFailureLogin);
            }
            else
            {
                m2sInfo = new M2SInfo(msg, QRCodeLoginSuccess, MsgFailureLogin);
            }

            GameEntry.WebRequestToServerComponent.SendJsonMsg(m2sInfo);
        }