|
@@ -0,0 +1,65 @@
|
|
|
+using System.Collections;
|
|
|
+using UnityEngine;
|
|
|
+using Blue;
|
|
|
+using UnityEngine.Networking;
|
|
|
+using Newtonsoft.Json;
|
|
|
+using System.Text;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+public interface IImmersalLocationService : IService
|
|
|
+{
|
|
|
+ void Set(int id,int projectId,bool location);
|
|
|
+}
|
|
|
+
|
|
|
+public class ImmersalLocationService : IImmersalLocationService
|
|
|
+{
|
|
|
+ private string userInfoSetUrl;
|
|
|
+ public void OnInit()
|
|
|
+ {
|
|
|
+ userInfoSetUrl = "https://api-fat3.ghz-tech.com/mr-navigator/v1/viewpoint/locationPoint";
|
|
|
+ }
|
|
|
+
|
|
|
+ public void Set(int id,int projectId,bool location)
|
|
|
+ {
|
|
|
+ CoroutineSystem.Instance.StartCoroutine(SetRequest(id,projectId,location));
|
|
|
+ }
|
|
|
+
|
|
|
+ private IEnumerator SetRequest(int id,int projectId,bool location)
|
|
|
+ {
|
|
|
+
|
|
|
+ using (UnityWebRequest webRequest = new UnityWebRequest(userInfoSetUrl, "POST"))
|
|
|
+ {
|
|
|
+ ImmersalLoaction ImmersalLoaction = new ImmersalLoaction();
|
|
|
+ ImmersalLoaction.id = id;
|
|
|
+ ImmersalLoaction.projectId = projectId;
|
|
|
+ ImmersalLoaction.location = location;
|
|
|
+ string jsonData = JsonConvert.SerializeObject(ImmersalLoaction);
|
|
|
+ Debug.LogError("JsonData"+jsonData);
|
|
|
+ byte[] bodyRaw = Encoding.UTF8.GetBytes(jsonData);
|
|
|
+
|
|
|
+ webRequest.uploadHandler = (UploadHandler)new UploadHandlerRaw(bodyRaw);
|
|
|
+ webRequest.downloadHandler = new DownloadHandlerBuffer();
|
|
|
+
|
|
|
+ webRequest.SetRequestHeader("Content-Type", "application/json;charset=utf-8");
|
|
|
+ webRequest.SetRequestHeader("authorization", HttpTool.Instance.Token);
|
|
|
+
|
|
|
+ yield return webRequest.SendWebRequest();
|
|
|
+
|
|
|
+ if (webRequest.result== UnityWebRequest.Result.ProtocolError || webRequest.result == UnityWebRequest.Result.ConnectionError)
|
|
|
+ Debug.LogError("UnityWebRequest Error:"+webRequest.downloadHandler.text);
|
|
|
+ else
|
|
|
+ {
|
|
|
+ Debug.LogError("Immersal上传:"+webRequest.downloadHandler.text);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+public class ImmersalLoaction
|
|
|
+{
|
|
|
+ public int id{ get; set; }
|
|
|
+ public int projectId{ get; set; }
|
|
|
+ public bool location{ get; set; }
|
|
|
+}
|