Ejemplo n.º 1
0
    public ResponseVO EnterGameRoom(DartGameUtils.GameMode gameType, string betData)
    {
        form = new WWWForm();
        form.AddField("user_id", GameManager.userInfo.id);
        form.AddField("game_type", ((int)gameType).ToString());
        form.AddField("game_data", betData);

        serverCallURL = "http://182.18.139.143:8282/public/webresources/app/api/v1/game/start";

        StartCoroutine(StartServerCall());

        Debug.Log("Control reached here");
        return(null);
    }
Ejemplo n.º 2
0
    //IEnumerator StartGameCall(DartGameUtils.GameMode gameType, string betData) {
    IEnumerator StartGameCall(DartGameUtils.GameMode gameType, int _betAmount, int _betColour)
    {
        WWWForm form = new WWWForm();

        form.AddField("betAmount", _betAmount);
        form.AddField("gameMode", ((int)gameType));
        form.AddField("betColor", _betColour);

        Debug.Log("betAmount:" + _betAmount);

        //UnityWebRequest www = UnityWebRequest.Post("http://182.18.139.143/WITSCLOUD/DEVELOPMENT/dartweb/index.php/api/createGameRoom", form);
        UnityWebRequest www = UnityWebRequest.Post("https://dartbet.io/index.php/api/createGameRoom", form);

        www.SetRequestHeader("token", GameManager.userToken);
        yield return(www.SendWebRequest());

        if (www.isNetworkError || www.isHttpError)
        {
            Debug.Log(www.error);
        }
        else
        {
            Debug.Log("Form upload complete!");
            StringBuilder sb = new StringBuilder();
            foreach (System.Collections.Generic.KeyValuePair <string, string> dict in www.GetResponseHeaders())
            {
                sb.Append(dict.Key).Append(": \t[").Append(dict.Value).Append("]\n");
            }

            // Print Headers
            Debug.Log(sb.ToString());

            // Print Body
            Debug.Log(www.downloadHandler.text);

            //ResponseVO info = JsonUtility.FromJson<ResponseVO>(www.downloadHandler.text);
            JSONNode jsonNode = SimpleJSON.JSON.Parse(www.downloadHandler.text);
            //info.data = jsonNode["game"].ToString();
            GameManager.currentGameId = jsonNode["gameId"];
            //GameManager.currentGameBetId = jsonNode["game"]["bets"][0];
            if (jsonNode["status"].Value == "Success")
            {
                Destroy(FindObjectOfType <AudioManager>());
                GameSceneManager.LoadScene("GamePlayScene");
            }
        }
    }
Ejemplo n.º 3
0
    public static ResponseVO EnterGameRoom(DartGameUtils.GameMode gameType, string betData)
    {
        string requestString = String.Format("http://182.18.139.143:8282/public/webresources/app/api/v1/game/start?user_id={0}&game_type={1}&game_data={2}", GameManager.userInfo.id, ((int)gameType).ToString(), betData);
        // requestString = "http://182.18.139.143:8282/public/webresources/app/api/v1/game/start?user_id=102452&game_type=1&game_data=[]";
        HttpWebRequest request = (HttpWebRequest)WebRequest.Create(requestString);

        request.Headers.Add("Authorization", "Bearer " + GameManager.userToken);
        // request.Timeout = 9000;
        request.Method = "POST";
        // request.ReadWriteTimeout = 9000;



        HttpWebResponse response     = (HttpWebResponse)request.GetResponse();
        StreamReader    reader       = new StreamReader(response.GetResponseStream());
        string          jsonResponse = reader.ReadToEnd();
        ResponseVO      info         = JsonUtility.FromJson <ResponseVO>(jsonResponse);
        JSONNode        jsonNode     = SimpleJSON.JSON.Parse(jsonResponse);

        info.data = jsonNode["game"].ToString();

        return(info);
    }
Ejemplo n.º 4
0
 public void SetCurrentGameMode(DartGameUtils.GameMode value)
 {
     currentGameMode = value;
 }