Beispiel #1
0
    void Start()
    {
        tcpNet = NewTcpNet.GetInstance();
        StartCoroutine(ShowLoading());
        Init();
        AddListener();

        //LoginInfo.

        StartCoroutine(
            OnPolling
            (
                LoginInfo.Instance().mylogindata.URL +
                LoginInfo.Instance().mylogindata.hallaliveAPI +
                "user_id=" + LoginInfo.Instance().mylogindata.user_id +
                "&unionuid=" + LoginInfo.Instance().mylogindata.token

            ));
        StartCoroutine(GetHistory(LoginInfo.Instance().mylogindata.URL +
                                  LoginInfo.Instance().mylogindata.winHistory +
                                  "game_id=" + LoginInfo.Instance().mylogindata.choosegame
                                  ));

        StartCoroutine("GetBetNum");
    }
Beispiel #2
0
    IEnumerator OnWebGet2()
    {
        UnityWebRequest www = UnityWebRequest.Get(LoginInfo.Instance().mylogindata.URL +
                                                  "room-end?"
                                                  + "user_id=" + LoginInfo.Instance().mylogindata.user_id
                                                  + "&game_id=" + LoginInfo.Instance().mylogindata.choosegame);

        yield return(www.Send());

        if (www.error == null)
        {
            JsonData jd;
            try
            {
                jd = JsonMapper.ToObject(www.downloadHandler.text);
                if (jd["code"].ToString() == "200")
                {
                    NewTcpNet.IsKick = true;
                    if (NewTcpNet.instance != null)
                    {
                        NewTcpNet.GetInstance().SocketQuit();
                    }
                    DisconnectPanel.GetInstance().Show();
                    DisconnectPanel.GetInstance().Modification("", "长时间未操作,你已被移除房间");
                }
            }
            catch
            {
            }
        }
    }
Beispiel #3
0
    void Start()
    {
        tcp = NewTcpNet.GetInstance();

        StartCoroutine(ShowLoading());

        TableClear();
        Init();
        AddListener();

        StartCoroutine(OnPolling());
        StartCoroutine(GetHistory());
    }
Beispiel #4
0
    // Update is called once per frame
    /// <summary>
    /// 转动转盘
    /// </summary>
    void Update()
    {
        if (LoginData.IsLogin)
        {
            LoginData.OverTime += Time.deltaTime;
            if (LoginData.OverTime >= 3f)
            {
                NewTcpNet.GetInstance().SocketQuit();
                NewTcpNet.GetInstance();
            }
        }



        //JSTime();
    }
Beispiel #5
0
    //可以用来判断连接状态
    private void FixedUpdate()
    {
        if (Input.GetKeyDown(KeyCode.Space))
        {
            NewTcpNet.GetInstance().SocketQuit();
        }

        if (LoginData.IsLogin)
        {
            LoginData.OverTime += Time.deltaTime;
            if (LoginData.OverTime >= 3f)
            {
                NewTcpNet.GetInstance().SocketQuit();
                //OnLogin onLo = new OnLogin("Login", mylogindata.user_id, mylogindata.room_id.ToString(),mylogindata.choosegame.ToString());
                //string str = JsonMapper.ToJson(onLo);

                NewTcpNet.GetInstance();
            }
        }
    }
Beispiel #6
0
    void Start()
    {
        tcpNet = NewTcpNet.GetInstance();

        StartCoroutine(ShowLoading());
        Application.targetFrameRate = 30;
        Init();
        AddListener();


        //初始化信息
        StartCoroutine(Polling
                       (
                           LoginInfo.Instance().mylogindata.URL +
                           LoginInfo.Instance().mylogindata.hallaliveAPI +
                           "user_id=" + LoginInfo.Instance().mylogindata.user_id +
                           "&unionuid=" + LoginInfo.Instance().mylogindata.token/* +
                                                                                 * "&room_id" + LoginInfo.Instance().mylogindata.room_id +
                                                                                 * "&game_id" + LoginInfo.Instance().mylogindata.game_id*/
                       ));
    }
Beispiel #7
0
    private void OnApplicationFocus(bool focus)
    {
        if (focus)
        {
            //uniWebView.OnClose();
            //StartCoroutine(ShowLoading());
            isFirstJoin = false;
            OnLogin onLo = new OnLogin("Login", LoginInfo.Instance().mylogindata.user_id, LoginInfo.Instance().mylogindata.room_id.ToString(), LoginInfo.Instance().mylogindata.choosegame.ToString());
            string  str  = JsonMapper.ToJson(onLo);

            //判断是否断开连接
            //Debug.Log("连接状态:"+tcpNet.GetConnectionStatus());
            if (tcpNet.GetConnectionStatus())
            {
                tcpNet.SendMessage(str);
            }
            else
            {
                tcpNet = NewTcpNet.GetInstance();
            }

            //ClearInfo();

            StartCoroutine(GetHistory(
                               LoginInfo.Instance().mylogindata.URL +
                               LoginInfo.Instance().mylogindata.winHistory +
                               "game_id=" + LoginInfo.Instance().mylogindata.choosegame
                               ));
            StartCoroutine(OnReGet
                           (
                               LoginInfo.Instance().mylogindata.URL +
                               LoginInfo.Instance().mylogindata.newInit +
                               "user_id=" + LoginInfo.Instance().mylogindata.user_id +
                               "&unionuid=" + LoginInfo.Instance().mylogindata.token +
                               "&room_id=" + LoginInfo.Instance().mylogindata.room_id +
                               "&game_id=" + LoginInfo.Instance().mylogindata.choosegame
                           ));
        }
    }
Beispiel #8
0
    /// <summary>
    /// 轮询信息
    /// </summary>
    /// <param name="url"></param>
    /// <returns></returns>
    IEnumerator Polling(string url)
    {
        while (true)
        {
            UnityWebRequest www = UnityWebRequest.Get(url);
            yield return(www.Send());

            if (www.error == null)
            {
                JsonData jd = JsonMapper.ToObject(www.downloadHandler.text);
                if (jd["code"].ToString() == "200")
                {
                    LoginInfo.Instance().mylogindata.ALLScroce = jd["Userinfo"]["quick_credit"].ToString();
                    GoldText.text = LoginInfo.Instance().mylogindata.ALLScroce;
                    if (jd["Userinfo"]["status"].ToString() == "2")
                    {
                        ShowOtherMess(jd["msg"].ToString());
                        yield return(new WaitForSeconds(2f));

                        tcpNet.SocketQuit();
                        SceneManager.LoadScene(0);
                    }
                }
                else
                {
                    ShowOtherMess(jd["msg"].ToString());
                    yield return(new WaitForSeconds(2f));

                    tcpNet = NewTcpNet.GetInstance();
                    SceneManager.LoadScene(0);
                }
            }

            yield return(new WaitForSeconds(4f));
        }
    }