Пример #1
0
        public override IEnumerator RunJob()
        {
            Debug.Log("*************************** CoroutineJobListJobs ***************************");

            SDKJobsRequest r = new SDKJobsRequest();

            r.token = this.token;
            r.bank  = this.bank;
            string jsonString = JsonUtility.ToJson(r);

            using (UnityWebRequest request = UnityWebRequest.Put(string.Format(Endpoint.URL_FORMAT, this.server, Endpoint.LIST_JOBS), jsonString))
            {
                request.method          = UnityWebRequest.kHttpVerbPOST;
                request.useHttpContinue = false;
                request.SetRequestHeader("Content-Type", "application/json");
                request.SetRequestHeader("Accept", "application/json");
                yield return(request.SendWebRequest());

                if (request.isNetworkError || request.isHttpError)
                {
                    Debug.LogError(request.error);
                }
                else if (request.responseCode == (long)HttpStatusCode.OK)
                {
                    SDKJobsResult result = JsonUtility.FromJson <SDKJobsResult>(request.downloadHandler.text);

                    if (result.error == "none" && result.count > 0)
                    {
                        this.visualizeManager.SetSelectSlotData(result.jobs, activeMaps);
                    }
                }
            }
        }
Пример #2
0
        public override IEnumerator RunJob()
        {
            Debug.Log("*************************** CoroutineJobListJobs ***************************");

            BaseMapper     mapper = host as BaseMapper;
            SDKJobsRequest r      = this.useGPS ? new SDKGeoJobsRequest() : new SDKJobsRequest();

            r.token = mapper.token;
            r.bank  = mapper.currentBank;

            if (this.useGPS)
            {
                SDKGeoJobsRequest gr = r as SDKGeoJobsRequest;
                gr.latitude  = this.latitude;
                gr.longitude = this.longitude;
                gr.radius    = this.radius;
            }

            string jsonString = JsonUtility.ToJson(r);
            string endpoint   = this.useGPS ? Endpoint.LIST_GEOJOBS : Endpoint.LIST_JOBS;

            using (UnityWebRequest request = UnityWebRequest.Put(string.Format(Endpoint.URL_FORMAT, mapper.server, endpoint), jsonString))
            {
                request.method          = UnityWebRequest.kHttpVerbPOST;
                request.useHttpContinue = false;
                request.SetRequestHeader("Content-Type", "application/json");
                request.SetRequestHeader("Accept", "application/json");
                yield return(request.SendWebRequest());

                if (request.isNetworkError || request.isHttpError)
                {
                    Debug.LogError(request.error);
                }
                else if (request.responseCode == (long)HttpStatusCode.OK)
                {
                    SDKJobsResult result = JsonUtility.FromJson <SDKJobsResult>(request.downloadHandler.text);
                    if (result.error == "none")
                    {
                        mapper.visualizeManager.SetSelectSlotData(result.jobs, activeMaps);
                    }
                }
            }
        }
        public override IEnumerator RunJob()
        {
            SDKJobsRequest r = new SDKJobsRequest();

            r.token = this.token;
            r.bank  = this.bank;
            string jsonString = JsonUtility.ToJson(r);

            using (UnityWebRequest request = UnityWebRequest.Put(string.Format(Endpoint.URL_FORMAT, this.server, Endpoint.LIST_JOBS), jsonString))
            {
                request.method          = UnityWebRequest.kHttpVerbPOST;
                request.useHttpContinue = false;
                request.SetRequestHeader("Content-Type", "application/json");
                request.SetRequestHeader("Accept", "application/json");
                yield return(request.SendWebRequest());

                if (request.isNetworkError || request.isHttpError)
                {
                    Debug.LogError(request.error);
                }
                else if (request.responseCode == (long)HttpStatusCode.OK)
                {
                    SDKJobsResult result = JsonUtility.FromJson <SDKJobsResult>(request.downloadHandler.text);

                    if (result.error == "none" && result.count > 0)
                    {
                        List <string> names = new List <string>();

                        foreach (SDKJob job in result.jobs)
                        {
                            if (job.status == "done")
                            {
                                maps.Add(job);
                                names.Add(job.name);
                            }
                        }

                        dropdown.AddOptions(names);
                    }
                }
            }
        }