예제 #1
0
    public Playtomic_Response GetResponse(string name)
    {
        if (Responses.ContainsKey(name))
        {
            return(Responses[name]);
        }

        return(Playtomic_Response.GeneralError("No response found"));
    }
예제 #2
0
    public static Playtomic_Response Process(WWW www)
    {
        if (www == null)
        {
            return(Playtomic_Response.GeneralError(1));
        }

        if (www.error != null)
        {
            return(Playtomic_Response.GeneralError(www.error));
        }

        if (string.IsNullOrEmpty(www.text))
        {
            return(Playtomic_Response.Error(1));
        }

        var results = (Hashtable)Playtomic_JSON.JsonDecode(www.text);

        if (!results.ContainsKey("Status") || !results.ContainsKey("ErrorCode"))
        {
            return(Playtomic_Response.GeneralError(1));
        }

        var response = new Playtomic_Response();

        response.Success   = ((int)(double)results["Status"] == 1);
        response.ErrorCode = (int)(double)results["ErrorCode"];

        if (response.Success && results.ContainsKey("Data"))
        {
            if (results["Data"] is Hashtable)
            {
                response.JSON = (Hashtable)results["Data"];
            }

            if (results["Data"] is ArrayList)
            {
                response.ARRAY = (ArrayList)results["Data"];
            }
        }

        return(response);
    }