胡佳骏 1 year ago
parent
commit
d4b2c17ae3
1 changed files with 12 additions and 9 deletions
  1. 12 9
      Samples~/SDK/GatewayHttp.cs

+ 12 - 9
Samples~/SDK/GatewayHttp.cs

@@ -15,18 +15,21 @@ public class GatewayHttp : MonoBehaviour
     // Start is called before the first frame update
     void Start()
     {
-        
+
         Debug.Log("Start Queue SendHttp Start" + Application.version);
-        Dictionary<string,string> data = new Dictionary<string, string>();
+        Dictionary<string, string> data = new Dictionary<string, string>();
         data.Add("username", username);
         data.Add("password", password);
-        StartCoroutine(SendHttp("nacos/v1/auth/users/login", data,(string json)=> {
+        StartCoroutine(SendHttp("nacos/v1/auth/users/login", data, (string json) => {
 
             Debug.Log(json);
             JsonData jdata = JsonMapper.ToObject(json);
             Dictionary<string, string> data = new Dictionary<string, string>();
-            data.Add("dataId",Application.version);
-            data.Add("group", Application.productName);
+            string pname = Application.productName.Replace(" ", "");
+            data.Add("dataId", Application.version);
+            data.Add("group", pname);
+            Debug.Log("login==>" + pname);
+            Debug.Log("login==>" + Application.version);
             data.Add("accessToken", jdata["accessToken"].ToString());
             StartCoroutine(SendHttp("nacos/v1/cs/configs", data, (string json) =>
             {
@@ -41,7 +44,7 @@ public class GatewayHttp : MonoBehaviour
                 HttpSDKAction.Instance.officeSocket = backData["unity"]["url"][pt]["officeSocket"].ToString();
                 HttpSDKAction.Instance.pointCloudUrl = backData["unity"]["url"][pt]["pointCloud"].ToString();
                 HttpSDKAction.Instance.roomSocket = backData["unity"]["url"][pt]["roomSocket"].ToString();
-            },false));
+            }, false));
 
 
         }));
@@ -82,17 +85,17 @@ public class GatewayHttp : MonoBehaviour
         requestHeader.Add("Content-Type", "application/x-www-form-urlencoded");
     }
 
-    public IEnumerator SendHttp(string methodName, Dictionary<string, string> fromDic, Action<string> CallBack,bool isPost=true)
+    public IEnumerator SendHttp(string methodName, Dictionary<string, string> fromDic, Action<string> CallBack, bool isPost = true)
     {
         Debug.Log("Start Queue SendHttp " + methodName);
-        string url = baseUrl+ methodName;
+        string url = baseUrl + methodName;
         UnityWebRequest webRequest;
         if (!isPost)
         {
             url += "?";
             foreach (var item in fromDic)
             {
-                url+= item.Key +"="+item.Value+ "&";
+                url += item.Key + "=" + item.Value + "&";
             }
 
             webRequest = UnityWebRequest.Get(url);