Bladeren bron

RTC 流程优化

DGJ 1 jaar geleden
bovenliggende
commit
a763f5bedb

+ 3 - 2
Assets/Game/Blue/Controller/Item/DeviceInfo_Item.cs

@@ -58,7 +58,8 @@ namespace GHZLangChao
 
             string jsondata = JsonConvert.SerializeObject(data);
 
-            HttpLangChaoTool.Instance.Post(HttpLangChaoAction.bladeServer, jsondata, BladeServerCallBack);
+            StartCoroutine(HttpTool.Instance.SendHttp(HttpActionLang.bladeServer, jsondata, BladeServerCallBack));
+           // HttpLangChaoTool.Instance.Post(HttpLangChaoAction.bladeServer, jsondata, BladeServerCallBack);
 
            
            // item.gameObject.SetActive(false);
@@ -92,7 +93,7 @@ namespace GHZLangChao
             }
             else
             {
-                Debug.LogError(" 请求刀片机详情参数出错 !!! " + HttpLangChaoAction.bladeServer);
+                Debug.LogError(" 请求刀片机详情参数出错 !!! " + HttpActionLang.bladeServer);
             }
 
         }

+ 17 - 0
Assets/HttpActionLang.cs

@@ -21,5 +21,22 @@ public class HttpActionLang : Singleton<HttpActionLang>
 
     public const string inspection_step = "/cmcc-endustry/v1/inspection/step"; // 机房巡检步骤上报
 
+    /// <summary>
+    /// 获取刀片机详细信息
+    /// </summary>
+    public const string bladeServer = "/cmcc-endustry/v1/inspection/item";
+    /// <summary>
+    /// 获取机房信息
+    /// </summary>
+    public const string sceneInit = "/cmcc-endustry/v1/inspection/cabinet";
+    /// <summary>
+    /// 修改机柜信息
+    /// </summary>
+    public const string updateCabinet = "/cmcc-endustry/v1/inspection/updateCabinet";
+    /// <summary>
+    /// 修改场景TagData
+    /// </summary>
+    public const string updateTag = "/cmcc-endustry/v1/inspection/updateScene";
+
     public string mqttSocket ="";
 }

+ 4 - 0
Assets/LangChaoRTC/Remote/ShowRoom/RoomInvite/Prefab/MsgItem.prefab

@@ -709,6 +709,10 @@ PrefabInstance:
       propertyPath: m_fontSize
       value: 45
       objectReference: {fileID: 0}
+    - target: {fileID: 412570834748894171, guid: 8159e16c99a3d9548b98bc48e0a86dda, type: 3}
+      propertyPath: m_margin.z
+      value: -456.1032
+      objectReference: {fileID: 0}
     - target: {fileID: 412570834748894171, guid: 8159e16c99a3d9548b98bc48e0a86dda, type: 3}
       propertyPath: m_fontSizeBase
       value: 45

+ 6 - 6
Assets/LangChaoRTC/Remote/ShowRoom/RoomMain.prefab

@@ -1491,7 +1491,7 @@ GameObject:
   m_Icon: {fileID: 0}
   m_NavMeshLayer: 0
   m_StaticEditorFlags: 0
-  m_IsActive: 1
+  m_IsActive: 0
 --- !u!224 &2241088651301450027
 RectTransform:
   m_ObjectHideFlags: 0
@@ -1606,7 +1606,7 @@ MonoBehaviour:
           m_IntArgument: 0
           m_FloatArgument: 0
           m_StringArgument: 
-          m_BoolArgument: 0
+          m_BoolArgument: 1
         m_CallState: 2
 --- !u!1 &2241088651333374834
 GameObject:
@@ -1702,7 +1702,7 @@ GameObject:
   m_Icon: {fileID: 0}
   m_NavMeshLayer: 0
   m_StaticEditorFlags: 0
-  m_IsActive: 1
+  m_IsActive: 0
 --- !u!224 &2241088651403055103
 RectTransform:
   m_ObjectHideFlags: 0
@@ -1817,7 +1817,7 @@ MonoBehaviour:
           m_IntArgument: 0
           m_FloatArgument: 0
           m_StringArgument: 
-          m_BoolArgument: 0
+          m_BoolArgument: 1
         m_CallState: 2
 --- !u!1 &2241088651471683787
 GameObject:
@@ -1952,7 +1952,7 @@ MonoBehaviour:
           m_IntArgument: 0
           m_FloatArgument: 0
           m_StringArgument: 
-          m_BoolArgument: 1
+          m_BoolArgument: 0
         m_CallState: 2
 --- !u!1 &2241088651505987571
 GameObject:
@@ -3111,7 +3111,7 @@ MonoBehaviour:
           m_IntArgument: 0
           m_FloatArgument: 0
           m_StringArgument: 
-          m_BoolArgument: 1
+          m_BoolArgument: 0
         m_CallState: 2
 --- !u!1 &2316171003018402862
 GameObject:

+ 2 - 2
Assets/Scripts/Data/DataItem.cs

@@ -175,7 +175,7 @@ public class DataItem : MonoBehaviour
             string data = JsonConvert.SerializeObject(updateData);
             machineParameters.offsetPos = offsetPos;
 
-            HttpLangChaoTool.Instance.Post(HttpLangChaoAction.updateCabinet, data, UpdateCabinetCallBack);
+            HttpTool.Instance.Post(HttpActionLang.updateCabinet, data, UpdateCabinetCallBack);
         }
            
 
@@ -194,7 +194,7 @@ public class DataItem : MonoBehaviour
         }
         else
         {
-            Debug.LogError(" 更新机柜参数出错 !!! " + HttpLangChaoAction.updateCabinet);
+            Debug.LogError(" 更新机柜参数出错 !!! " + HttpActionLang.updateCabinet);
         }
     }
 }

+ 4 - 4
Assets/Scripts/Managers/MachineRoomManager.cs

@@ -229,7 +229,7 @@ public class MachineRoomManager : MonoSingleton<MachineRoomManager>
     private void Start()
     {
         Init();
-        HttpLangChaoTool.Instance.Post(HttpLangChaoAction.sceneInit, "", SceneInitCallBack);
+        HttpTool.Instance.Post(HttpActionLang.sceneInit, "", SceneInitCallBack);
         //Init();
 
       
@@ -258,7 +258,7 @@ public class MachineRoomManager : MonoSingleton<MachineRoomManager>
         }
         else
         {
-            Debug.LogError(" 请求场景参数出错 !!! " + HttpLangChaoAction.sceneInit);
+            Debug.LogError(" 请求场景参数出错 !!! " + HttpActionLang.sceneInit);
         }
     }
 
@@ -706,7 +706,7 @@ public class MachineRoomManager : MonoSingleton<MachineRoomManager>
             tagData.listTagData = data.listTagData;
             string jsonDate = JsonConvert.SerializeObject(tagData);
             Debug.Log(jsonDate);
-            HttpLangChaoTool.Instance.Post(HttpLangChaoAction.updateTag, jsonDate, UpdateTagCallBack);
+            HttpTool.Instance.Post(HttpActionLang.updateTag, jsonDate, UpdateTagCallBack);
 
             selectTOldPos = Vector3.zero;
             selectTOldRot = Vector3.zero;
@@ -732,7 +732,7 @@ public class MachineRoomManager : MonoSingleton<MachineRoomManager>
         }
         else
         {
-            Debug.LogError(" 更新场景Tag参数出错 !!! " + HttpLangChaoAction.updateCabinet);
+            Debug.LogError(" 更新场景Tag参数出错 !!! " + HttpActionLang.updateCabinet);
         }
     }
 

+ 0 - 27
Assets/Scripts/Net/HttpLangChaoAction.cs

@@ -1,27 +0,0 @@
-using SC.XR.Unity;
-using System.Collections;
-using System.Collections.Generic;
-using UnityEngine;
-
-public class HttpLangChaoAction : Singleton<HttpLangChaoAction>
-{
-
-    public const string url = "https://api-fat1.ghz-tech.com/mr-navigator/v1";
-
-    /// <summary>
-    /// 获取刀片机详细信息
-    /// </summary>
-    public const string bladeServer = "/inspection/item";
-    /// <summary>
-    /// 获取机房信息
-    /// </summary>
-    public const string sceneInit = "/inspection/cabinet";
-    /// <summary>
-    /// 修改机柜信息
-    /// </summary>
-    public const string updateCabinet = "/inspection/updateCabinet";
-    /// <summary>
-    /// 修改场景TagData
-    /// </summary>
-    public const string updateTag = "/inspection/updateScene";
-}

+ 0 - 11
Assets/Scripts/Net/HttpLangChaoAction.cs.meta

@@ -1,11 +0,0 @@
-fileFormatVersion: 2
-guid: 141b159c3eecc8640a3ede9fe76e462d
-MonoImporter:
-  externalObjects: {}
-  serializedVersion: 2
-  defaultReferences: []
-  executionOrder: 0
-  icon: {instanceID: 0}
-  userData: 
-  assetBundleName: 
-  assetBundleVariant: 

+ 0 - 95
Assets/Scripts/Net/HttpLangChaoTool.cs

@@ -1,95 +0,0 @@
-using Newtonsoft.Json.Linq;
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Text;
-using UnityEngine;
-using UnityEngine.Networking;
-
-public class HttpLangChaoTool : MonoSingleton<HttpLangChaoTool>
-{
-    Dictionary<string, string> requestHeader = new Dictionary<string, string>();  //  header
-
-    public void Post(string methodName, string jsonString, Action<string> CallBack)
-    {
-        StartCoroutine(SendHttp(methodName, jsonString, CallBack));
-    }
-
-    public IEnumerator SendHttp(string methodName, string jsonString, Action<string> CallBack, bool isPost = true, bool isCloud = false)
-    {
-        Debug.Log("Start Queue SendHttp " + methodName);
-        string url;
-        if (methodName.Contains("http"))
-        {
-            url = methodName;
-        }
-        else
-        {
-            url = HttpLangChaoAction.url + methodName;
-
-        }
-        Debug.Log("URL:" + url + " isPost  " + isPost);
-        UnityWebRequest webRequest;
-        if (!isPost)
-        {
-            webRequest = UnityWebRequest.Get(url);
-
-        }
-        else
-        {
-            webRequest = new UnityWebRequest(url, "POST");
-        }
-        initHead();
-        using (webRequest)
-        {
-            if (!isPost)
-            {
-                webRequest.downloadHandler = (DownloadHandler)new DownloadHandlerBuffer();
-                foreach (var v in requestHeader)
-                {
-                    webRequest.SetRequestHeader(v.Key, v.Value);
-                }
-            }
-            else
-            {
-                byte[] bodyRaw = Encoding.UTF8.GetBytes(jsonString);
-                webRequest.uploadHandler = (UploadHandler)new UploadHandlerRaw(bodyRaw);
-                webRequest.downloadHandler = (DownloadHandler)new DownloadHandlerBuffer();
-            }
-
-            foreach (var v in requestHeader)
-            {
-                webRequest.SetRequestHeader(v.Key, v.Value);
-            }
-            yield return webRequest.SendWebRequest();
-
-            Debug.Log("CallBack==>" + webRequest.downloadHandler.text);
-            if (webRequest.isHttpError || webRequest.isNetworkError)
-            {
-                Debug.LogError(url + "\n" + webRequest.error + "\n" + webRequest.downloadHandler.text);
-                string error = webRequest.downloadHandler.text;
-                JObject jObject = JObject.Parse(error);
-                CallBack(jObject["message"].ToString());
-            }
-            else
-            {
-                //Debug.Log(webRequest.downloadHandler.text);
-                var mes = webRequest.downloadHandler.text;
-
-                CallBack(mes);
-            }
-        }
-
-    }
-
-    public void initHead()
-    {
-        requestHeader.Clear();
-        //if (UserInfo.Instance.Token != "" && UserInfo.Instance.Token != null)
-        //{
-        //    requestHeader.Add("x-token", UserInfo.Instance.Token);
-        //    requestHeader.Add("authorization", UserInfo.Instance.Token);
-        //}
-        requestHeader.Add("Content-Type", "application/json");
-    }
-}

+ 0 - 11
Assets/Scripts/Net/HttpLangChaoTool.cs.meta

@@ -1,11 +0,0 @@
-fileFormatVersion: 2
-guid: 9eb2c1120b825d14dbaf47b974de7085
-MonoImporter:
-  externalObjects: {}
-  serializedVersion: 2
-  defaultReferences: []
-  executionOrder: 0
-  icon: {instanceID: 0}
-  userData: 
-  assetBundleName: 
-  assetBundleVariant: 

+ 9 - 4
Assets/Scripts/RTC/LiveRTCRoomMain.cs

@@ -35,6 +35,11 @@ public class LiveRTCRoomMain : MonoSingleton<LiveRTCRoomMain>,IController
 
             rtcRawImage.texture = RTCRoomManager.Instance.expertView.VideoView;
         }
+        else
+        {
+            if (rtcRawImage.gameObject.activeSelf)
+                rtcRawImage.gameObject.SetActive(false);
+        }
           
     }
     private void OnInit()
@@ -54,16 +59,16 @@ public class LiveRTCRoomMain : MonoSingleton<LiveRTCRoomMain>,IController
 
     public void SetAudio(bool state)
     {
-       
-        GHZRtcManager.Instance.OnWebCam(state);
+
+        GHZRtcManager.Instance.OnMicrophone(state);
         audioCloseBtn.gameObject.SetActive(!state);
         audioOpenBtn.gameObject.SetActive(state);
     }
 
     public void SetVideo(bool state)
     {
-        GHZRtcManager.Instance.OnMicrophone(state);
-
+       
+        GHZRtcManager.Instance.OnWebCam(state);
         videoCloseBtn.gameObject.SetActive(!state);
         videoOpenBtn.gameObject.SetActive(state);
     }

+ 1 - 1
Assets/Scripts/RTC/OnWebSocketMsg.cs

@@ -67,7 +67,7 @@ public class OnWebSocketMsg : MonoSingleton<OnWebSocketMsg>
 
                     }
 
-                    if(obj2["roleId"].ToString()=="3")
+                    if(obj2["roleId"].ToString()=="1")
                     {
                         RTCRoomManager.Instance.UserJoined(UserEnum.Conterl, obj2);
                     }

+ 3 - 0
Assets/Scripts/RTC/RTCRoomManager.cs

@@ -37,6 +37,8 @@ public class RTCRoomManager : MonoSingleton<RTCRoomManager>, IController
             GHZRtcManager.Instance.isRoom = false;
             OnLocalUserJoined();
         }
+
+       
     }
 
     private void CreatRoomSuccess(RTCCreatRoomSuccessEvent e)
@@ -163,6 +165,7 @@ public class RTCRoomManager : MonoSingleton<RTCRoomManager>, IController
         if(expertData!=null&& participant.identity == expertData["name"].ToString() )
         {
             UserOffline(UserEnum.Expert);
+            
 
         }else if(controlData!=null && participant.identity == controlData["name"].ToString())
         {