Browse Source

增加本地超时处理 修改原四个API接口

DGJ 1 year ago
parent
commit
c4ecdf98c4

+ 4 - 0
Assets/Game/ShowSupport/SupportControl.cs

@@ -87,7 +87,11 @@ public class SupportControl : AbstractController
     }
     public void Home()
     {
+        if (allotPanel.gameObject.activeSelf)
+            LeaveRoom();
+        InitPanel(true);
         ScenesManager.Instance.showWindow(ScenesManager.SceneType.ShowChoose);
+
     }
 
     public void Device()

+ 4 - 4
Assets/HttpActionLang.cs

@@ -24,19 +24,19 @@ public class HttpActionLang : Singleton<HttpActionLang>
     /// <summary>
     /// 获取刀片机详细信息
     /// </summary>
-    public const string bladeServer = "/cmcc-endustry/v1/inspection/item";
+    public const string bladeServer = "/mr-navigator/v1/inspection/item";
     /// <summary>
     /// 获取机房信息
     /// </summary>
-    public const string sceneInit = "/cmcc-endustry/v1/inspection/cabinet";
+    public const string sceneInit = "/mr-navigator/v1/inspection/cabinet";
     /// <summary>
     /// 修改机柜信息
     /// </summary>
-    public const string updateCabinet = "/cmcc-endustry/v1/inspection/updateCabinet";
+    public const string updateCabinet = "/mr-navigator/v1/inspection/updateCabinet";
     /// <summary>
     /// 修改场景TagData
     /// </summary>
-    public const string updateTag = "/cmcc-endustry/v1/inspection/updateScene";
+    public const string updateTag = "/mr-navigator/v1/inspection/updateScene";
 
     public string mqttSocket ="";
 }

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

@@ -3711,7 +3711,7 @@ MonoBehaviour:
   m_EditorClassIdentifier: 
   m_Material: {fileID: 0}
   m_Color: {r: 1, g: 1, b: 1, a: 0.60784316}
-  m_RaycastTarget: 0
+  m_RaycastTarget: 1
   m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
   m_Maskable: 1
   m_OnCullStateChanged:

+ 4 - 5
Assets/Scenes/LangChaoDemo2.unity

@@ -5359,7 +5359,7 @@ GameObject:
   m_Icon: {fileID: 0}
   m_NavMeshLayer: 0
   m_StaticEditorFlags: 0
-  m_IsActive: 0
+  m_IsActive: 1
 --- !u!224 &398219260
 RectTransform:
   m_ObjectHideFlags: 0
@@ -5378,7 +5378,7 @@ RectTransform:
   m_LocalEulerAnglesHint: {x: 0, y: 180, z: 0}
   m_AnchorMin: {x: 0.5, y: 0.5}
   m_AnchorMax: {x: 0.5, y: 0.5}
-  m_AnchoredPosition: {x: 84, y: 65.9}
+  m_AnchoredPosition: {x: 428, y: -236}
   m_SizeDelta: {x: 100, y: 100}
   m_Pivot: {x: 0.5, y: 0.5}
 --- !u!114 &398219261
@@ -7683,7 +7683,6 @@ MonoBehaviour:
   m_Script: {fileID: 11500000, guid: 9eb2c1120b825d14dbaf47b974de7085, type: 3}
   m_Name: 
   m_EditorClassIdentifier: 
-  global: 1
 --- !u!4 &583309982
 Transform:
   m_ObjectHideFlags: 0
@@ -8836,7 +8835,7 @@ MonoBehaviour:
   m_Name: 
   m_EditorClassIdentifier: 
   m_Material: {fileID: 0}
-  m_Color: {r: 0.33451498, g: 0.9433962, b: 0, a: 1}
+  m_Color: {r: 0.33451498, g: 0.9433962, b: 0, a: 0.3254902}
   m_RaycastTarget: 1
   m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
   m_Maskable: 1
@@ -8856,7 +8855,7 @@ MonoBehaviour:
     m_HorizontalOverflow: 0
     m_VerticalOverflow: 0
     m_LineSpacing: 1
-  m_Text: 1.0M
+  m_Text: "\u6D4B\u8BD5\u5305"
 --- !u!222 &650042339
 CanvasRenderer:
   m_ObjectHideFlags: 0

+ 1 - 1
Assets/Scripts/MQTT/MQTTManager.cs

@@ -142,7 +142,7 @@ public class MQTTManager : MonoSingleton<MQTTManager>
         switch (obj["action"].ToString())
         {
             case "timeout": // 超时
-                //UICallManager.Instance.EventTimeOut();
+                UICallManager.Instance.EventTimeOut();
                 break;
 
             case "invite": // 邀请

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

@@ -768,9 +768,9 @@ public class MachineRoomManager : MonoSingleton<MachineRoomManager>
     }
     private void OnDisable()
     {
-        PlayerPrefs.SetString("MachineRoomTagData", JsonConvert.SerializeObject(data.listTagData));
-        PlayerPrefs.SetString("MachineRoomCabinetData", JsonConvert.SerializeObject(data.listEquipmentData));
-        PlayerPrefs.SetString("MachineRoomData", JsonConvert.SerializeObject(data));
+        //PlayerPrefs.SetString("MachineRoomTagData", JsonConvert.SerializeObject(data.listTagData));
+        //PlayerPrefs.SetString("MachineRoomCabinetData", JsonConvert.SerializeObject(data.listEquipmentData));
+        //PlayerPrefs.SetString("MachineRoomData", JsonConvert.SerializeObject(data));
        // SaveData();
     }
 }

+ 34 - 12
Assets/Scripts/RTC/OnWebSocketMsg.cs

@@ -53,24 +53,46 @@ public class OnWebSocketMsg : MonoSingleton<OnWebSocketMsg>
 
                     JObject obj2 = JObject.Parse(metadata);
                     Debug.Log("DGJ  ===> roleId  " + obj2["roleId"].ToString());
-                    if (obj2["roleId"].ToString() == "2")
-                    {
-                        string uid = obj["sid"].ToString();
 
-                        if(ScenesManager.Instance.getWindow()== ScenesManager.SceneType.ShowRTC)
+                    string state = obj["state"].ToString();
+
+                    if(state == "DISCONNECTED")
+                    {
+                        if (obj2["roleId"].ToString() == "2")
                         {
-                            ScenesManager.Instance.showWindow(ScenesManager.SceneType.ShowRoom);
-                        }                     
-                        // 专家进入房间  并且当前是在远程协助页面
-                        RTCRoomManager.Instance.ExpertJonin(uid);
-                        RTCRoomManager.Instance.UserJoined(UserEnum.Expert , obj2);
+                            
+                            RTCRoomManager.Instance.UserOffline(UserEnum.Expert);
 
-                    }
+                        }
 
-                    if(obj2["roleId"].ToString()=="1")
+                        if (obj2["roleId"].ToString() == "1")
+                        {
+                            RTCRoomManager.Instance.UserOffline(UserEnum.Conterl);
+                        }
+                    }
+                    else if(state == "ACTIVE")
                     {
-                        RTCRoomManager.Instance.UserJoined(UserEnum.Conterl, obj2);
+                        if (obj2["roleId"].ToString() == "2")
+                        {
+                            string uid = obj["sid"].ToString();
+
+                            if (ScenesManager.Instance.getWindow() == ScenesManager.SceneType.ShowRTC)
+                            {
+                                ScenesManager.Instance.showWindow(ScenesManager.SceneType.ShowRoom);
+                            }
+                            // 专家进入房间  并且当前是在远程协助页面
+                            RTCRoomManager.Instance.ExpertJonin(uid);
+                            RTCRoomManager.Instance.UserJoined(UserEnum.Expert, obj2);
+
+                        }
+
+                        if (obj2["roleId"].ToString() == "1")
+                        {
+                            RTCRoomManager.Instance.UserJoined(UserEnum.Conterl, obj2);
+                        }
                     }
+
+                   
                 }
 
                 break;

+ 14 - 5
Assets/Scripts/RTC/RTCRoomManager.cs

@@ -103,11 +103,12 @@ public class RTCRoomManager : MonoSingleton<RTCRoomManager>, IController
 
     public void UserJoined( UserEnum userEnum , JObject metadata = null)
     {
-        Debug.Log("DGJ ===> " + rtcState);
+       // Debug.Log("DGJ ===> " + rtcState);
         switch (userEnum)
         {
             case UserEnum.Player:
                 rtcState = RTCEnum.Online;
+                Debug.Log(" DGJ ===> UserJoined 自己 ");
                 break;
             case UserEnum.Expert:
                 expertData = metadata;
@@ -129,6 +130,7 @@ public class RTCRoomManager : MonoSingleton<RTCRoomManager>, IController
                     default:
                         break;
                 }
+                Debug.Log(" DGJ ===> UserJoined 专家 ");
                 break;
             case UserEnum.Conterl:
                 controlData = metadata;
@@ -137,14 +139,14 @@ public class RTCRoomManager : MonoSingleton<RTCRoomManager>, IController
                     case RTCEnum.OFF:
 
                     case RTCEnum.Online:
-                        rtcState = RTCEnum.ExpertOnline;
+                        rtcState = RTCEnum.ConterlOnline;
                         break;
                     case RTCEnum.ExpertOnline:
                         rtcState = RTCEnum.ALLOnline;
                       
                         break;
                     case RTCEnum.ConterlOnline:
-                        rtcState = RTCEnum.ExpertOnline;
+                        rtcState = RTCEnum.ConterlOnline;
                         break;
                     case RTCEnum.ALLOnline:
                         Debug.LogError("RTC 房间状态有误 ");
@@ -152,10 +154,12 @@ public class RTCRoomManager : MonoSingleton<RTCRoomManager>, IController
                     default:
                         break;
                 }
+                Debug.Log(" DGJ ===> UserJoined 中控 ");
                 break;
             default:
                 break;
         }
+        Debug.Log("DGJ ===> " + rtcState);
     }
 
     public void UserOffline(string uid)
@@ -165,11 +169,13 @@ public class RTCRoomManager : MonoSingleton<RTCRoomManager>, IController
         if(expertData!=null&& participant.identity == expertData["name"].ToString() )
         {
             UserOffline(UserEnum.Expert);
-            
+            Debug.Log("DGJ ===>  UserOffline  专家 "+ uid);
 
         }else if(controlData!=null && participant.identity == controlData["name"].ToString())
         {
             UserOffline(UserEnum.Conterl);
+
+            Debug.Log("DGJ ===>  UserOffline  中控 " + uid);
         }
 
 
@@ -231,7 +237,7 @@ public class RTCRoomManager : MonoSingleton<RTCRoomManager>, IController
                 break;
         }
 
-        if(rtcState == RTCEnum.Online&& ScenesManager.Instance.getWindow() != ScenesManager.SceneType.ShowRTC)
+        if(rtcState != RTCEnum.OFF&& ScenesManager.Instance.getWindow() != ScenesManager.SceneType.ShowRTC)
         {
             // 退出房间
             LeaveChannel();
@@ -240,8 +246,11 @@ public class RTCRoomManager : MonoSingleton<RTCRoomManager>, IController
 
     public void LeaveChannel()
     {
+        Debug.LogError(" RTCRoomManager  退出房间");
         RTCManager.Instance.LeaveChannel();
+        rtcState = RTCEnum.OFF;
         ClearRoomData();
+       
     }
 
     private void ClearRoomData()

+ 20 - 0
Assets/Scripts/UI/AllotPanel.cs

@@ -8,8 +8,28 @@ public class AllotPanel : MonoSingleton<AllotPanel>
 
     public TMP_Text allotText;
 
+    private float times = 0;
     public void SetAllotText( string msg)
     {
         allotText.text = msg;
     }
+
+    private void OnEnable()
+    {
+        times = 0;
+    }
+    private void Update()
+    {
+        times += Time.deltaTime;
+
+        if(times>120)
+        {
+            times = 0;
+            Debug.LogError("  申请协助超时!!!! ");
+
+            if (RTCRoomManager.Instance.rtcState != RTCEnum.OFF)
+                RTCRoomManager.Instance.LeaveChannel();
+        }
+
+    }
 }