示例#1
0
 private bool IsDataspinReady(DataspinRequestMethod req)
 {
     if (Application.internetReachability != NetworkReachability.NotReachable)
     {
         if (!isSessionInProgress || sessionId == null)
         {
             DataspinError(new Error("There is no session active. Before " + req.ToString() + " call Dataspin.StartSession before that!", req));
             return(false);
         }
         else
         {
             if (uid == null)
             {
                 DataspinError(new Error("Uid is null! Before " + req.ToString() + " call Dataspin.GetUid first!", req));
                 return(false);
             }
             else
             {
                 return(true);
             }
         }
     }
     else
     {
         DataspinError(new Error("There is no internet connection!", req));
         return(false);
     }
 }
示例#2
0
    private void BeginRequest(string url, HttpRequestMethod httpMethod, DataspinRequestMethod dataspinMethod, Dictionary <string, string> extraData = null)
    {
        //Debug.Log("Starting DataspinWebRequest, Type: "+dataspinMethod.ToString() + ", URL: "+url);

        HTTP_Method     = httpMethod;
        Dataspin_Method = dataspinMethod;
        this.url        = url;
        www             = null;

        switch (httpMethod)
        {
        case HttpRequestMethod.HttpMethod_Post:
            WWWForm form = new WWWForm();
            if (extraData != null)
            {
                foreach (KeyValuePair <string, string> item in extraData)
                {
                    string itemKey   = item.Key;
                    string itemValue = item.Value;

                    form.AddField(itemKey, itemValue);
                    www = new WWW(URL, form);
                }
            }
            break;

        default:
            www = new WWW(URL);
            break;
        }
        Dataspin.Instance.StartChildCoroutine(Connector());
    }
示例#3
0
 public Error(string json, DataspinRequestMethod _method)
 {
     method = _method;
     try {
         InitializeErrorFromJson(json);
     }
     catch {
         message = json;
     }
 }
 //Determine whether request should be put on backlog
 public bool ShouldPutMethodOnBacklog(DataspinRequestMethod method)
 {
     for (int i = 0; i < backLogMethods.Count; i++)
     {
         if (method == backLogMethods[i])
         {
             return(true);
         }
     }
     return(false);
 }
        public DataspinWebRequest(DataspinRequestMethod dataspinMethod, HttpRequestMethod httpMethod, Dictionary <string, object> postData = null, int taskPid = 0, string specialUrl = "-")
        {
            this.postData       = postData;
            this.dataspinMethod = dataspinMethod;
            this.httpMethod     = httpMethod;
            this.taskPid        = taskPid;      //If 0 then its not backlog task
            if (specialUrl == "-")
            {
                this.url = DataspinManager.Instance.CurrentConfiguration.GetMethodCorrespondingURL(dataspinMethod);
            }
            else
            {
                this.url = specialUrl;
            }

            UpdateWWW();

            if (specialUrl == "-")
            {
                Fire();
            }
        }
示例#6
0
    //Better than previous one.
    public DataspinWebRequest(Dictionary <string, object> dictionary, HttpRequestMethod httpMethod, DataspinRequestMethod dataspinMethod, Dictionary <string, string> extraData = null)
    {
        jsonDict = dictionary;
        if (extraData != null)
        {
            this.extraData = extraData;
        }
        if ((string)jsonDict["uid"] == null || (string)jsonDict["uid"] == "" || ((string)jsonDict["uid"]).Length < 1)
        {
            Debug.Log("DataspinWebRequest without UID detected, probably from tape. Adding UID from this session.");
            jsonDict["uid"] = Dataspin.Instance.Uid;
        }
        string encryptedData = Dataspin.CreateEncryptedData(jsonDict);
        string url           = Dataspin.Instance.CurrentConfiguration.BaseURL + encryptedData;

        BeginRequest(url, httpMethod, dataspinMethod, extraData);
    }
示例#7
0
 public DataspinWebRequest(string url, HttpRequestMethod httpMethod, DataspinRequestMethod dataspinMethod, Dictionary <string, string> extraData = null)
 {
     BeginRequest(url, httpMethod, dataspinMethod, extraData);
 }