Beispiel #1
0
    IEnumerator ISendIndicationToUsers(int[] UserIds, string Indication, string message)
    {
        var encoding = new System.Text.UTF8Encoding();


        Dictionary <string, string> postHeader = new Dictionary <string, string> ();
        var jsonElement = new Simple_JSON.JSONClass();

//		{
//			"data_type": "save",
//			"players": [{"id" : 10}, { "id" : 11}],
//			"message":"hkjsflkasd alksndflaksd alsjkdaksd asd",
//			"message_type":"test"
//		}
        jsonElement ["data_type"] = "save";

        var jsonarray = new Simple_JSON.JSONArray();

        foreach (int id in UserIds)
        {
            var jsonItem = new Simple_JSON.JSONClass();
            jsonItem ["id"] = id.ToString();

            jsonarray.Add(jsonItem);
        }

        jsonElement ["players"]      = jsonarray;
        jsonElement ["message"]      = message;
        jsonElement ["message_type"] = Indication;

        postHeader.Add("Content-Type", "application/json");
        postHeader.Add("Content-Length", jsonElement.Count.ToString());

        WWW www = new WWW(PinekixUrls.IndicationUrl, encoding.GetBytes(jsonElement.ToString()), postHeader);

//		print ("jsonDtat is ==>> " + jsonElement.ToString ());
        yield return(www);

        if (www.error == null)
        {
            Simple_JSON.JSONNode _jsnode = Simple_JSON.JSON.Parse(www.text);
            if (_jsnode ["description"].ToString().Contains("Data has following") || _jsnode ["status"].ToString().Contains("200"))
            {
            }
            else
            {
            }
        }
        else
        {
        }
    }
Beispiel #2
0
    public IEnumerator IDeleteIndication(int IndicationId)
    {
        var encoding = new System.Text.UTF8Encoding();


        Dictionary <string, string> postHeader = new Dictionary <string, string> ();
        var jsonElement = new Simple_JSON.JSONClass();


        jsonElement ["data_type"]     = "delete";
        jsonElement ["player_id"]     = PlayerPrefs.GetInt("PlayerId").ToString();
        jsonElement ["indication_id"] = IndicationId.ToString();

        postHeader.Add("Content-Type", "application/json");
        postHeader.Add("Content-Length", jsonElement.Count.ToString());

        WWW www = new WWW(PinekixUrls.IndicationUrl, encoding.GetBytes(jsonElement.ToString()), postHeader);

//		print ("jsonDtat is ==>> " + jsonElement.ToString ());
        yield return(www);

        //		{"status":"200","description":"Data has following.",
        //		"data":[
        //		{"player_id":"10","message":"hkjsflkasd alksndflaksd alsjkdaksd asd","message_type":"test"},
        //		{"player_id":"10","message":"hkjsflkasd alksndflaksd alsjkdaksd asd","message_type":"test"}
        //		]
        //	}

        if (www.error == null)
        {
            Simple_JSON.JSONNode _jsnode = Simple_JSON.JSON.Parse(www.text);
            if (_jsnode ["description"].ToString().Contains("Data has following") || _jsnode ["status"].ToString().Contains("200"))
            {
            }
            else
            {
            }
        }
        else
        {
        }
    }
    public IEnumerator SendCharacterData()
    {
        var encoding = new System.Text.UTF8Encoding();

        Dictionary <string, string> postHeader = new Dictionary <string, string> ();

        //      customchar.player_id = PlayerPrefs.GetInt ("PlayerId");
        //      customchar.gender = (int)GameManager.GetGender ();
        var json = new Simple_JSON.JSONClass();

        json ["player_id"] = PlayerPrefs.GetInt("PlayerId").ToString();
        json["gender"]     = ((int)GameManager.GetGender()).ToString();


        json ["skin_tone"] = PlayerPrefs.GetInt("SkinToneColor").ToString();
        json ["eyes"]      = GetCustomizationPerCategory("Eyes");
        json ["nose"]      = GetCustomizationPerCategory("Nose");
        json ["lips"]      = GetCustomizationPerCategory("Lips");
        json ["ears"]      = GetCustomizationPerCategory("Ears");
        json ["hair"]      = GetCustomizationPerCategory("Hairs");
        json ["shoes"]     = GetCustomizationPerCategory("Shoes");
        json ["clothing"]  = "";
        //        {
        //            "player_id": "1",
        //            "gender": "1",
        //            "skin_tone": "1",
        //            "eyes": "1",
        //            "nose": "1",
        //            "lips": "1",
        //            "ears": "1",
        //            "hair": "1",
        //            "shoes": "1",
        //            "clothing": "1"
        //        }


        postHeader.Add("Content-Type", "application/json");
        postHeader.Add("Content-Length", json.Count.ToString());

        WWW www = new WWW("http://pinekix.ignivastaging.com/players/insertcustomcharacter", encoding.GetBytes(json.ToString()), postHeader);

        print("jsonDtat is ==>> " + json);
        yield return(www);

        if (www.error == null)
        {
            Simple_JSON.JSONNode _jsnode = Simple_JSON.JSON.Parse(www.text);
            print("www.text ==>> " + www.text);
            print("_jsnode ==>> " + _jsnode.ToString());
            if (_jsnode ["description"].ToString().Contains("inserted") || _jsnode ["status"].ToString().Contains("200"))
            {
                print("Success");
                yield return(true);
            }
            else
            {
                print("error" + www.error);
                yield return(false);
            }
        }
        else
        {
            yield return(false);
        }
    }
Beispiel #4
0
    IEnumerator GetIndications(bool IsAnyScreenOpen)
    {
        Indications.Clear();
        var encoding = new System.Text.UTF8Encoding();


        Dictionary <string, string> postHeader = new Dictionary <string, string> ();
        var jsonElement = new Simple_JSON.JSONClass();

//		{
//			"data_type": "view",
//			"player_id": 10
        //		}

        jsonElement ["data_type"] = "view";
        jsonElement ["player_id"] = PlayerPrefs.GetInt("PlayerId").ToString();

        postHeader.Add("Content-Type", "application/json");
        postHeader.Add("Content-Length", jsonElement.Count.ToString());

        WWW www = new WWW(PinekixUrls.IndicationUrl, encoding.GetBytes(jsonElement.ToString()), postHeader);

//		print ("jsonDtat is ==>> " + jsonElement.ToString ());
        yield return(www);

//		{"status":"200","description":"Data has following.",
//		"data":[
//		{"player_id":"10","message":"hkjsflkasd alksndflaksd alsjkdaksd asd","message_type":"test"},
//		{"player_id":"10","message":"hkjsflkasd alksndflaksd alsjkdaksd asd","message_type":"test"}
//		]
//	}

        if (www.error == null)
        {
            Simple_JSON.JSONNode _jsnode = Simple_JSON.JSON.Parse(www.text);
            if (_jsnode ["description"].ToString().Contains("Data has following") || _jsnode ["status"].ToString().Contains("200"))
            {
                for (int i = 0; i < _jsnode ["data"].Count; i++)
                {
                    var data = _jsnode ["data"] [i];
                    var id   = 0;
                    int.TryParse(data ["indication_id"], out id);

                    var eventId = 0;
                    int.TryParse(data ["message"], out eventId);

                    Indications.Add(new Indication(id, data ["message_type"], eventId));
                }
            }
            else
            {
            }
        }
        else
        {
        }
        if (!IsAnyScreenOpen)
        {
            InItIndications();
        }
    }