瀏覽代碼

RTC 流程

DGJ 1 年之前
父節點
當前提交
e161efa1cf

+ 49 - 10
Assets/Game/ShowSupport/ShowRtc.prefab

@@ -455,6 +455,18 @@ MonoBehaviour:
           m_StringArgument: 
           m_BoolArgument: 0
         m_CallState: 2
+      - m_Target: {fileID: 3651108695874027832}
+        m_TargetAssemblyTypeName: SupportControl, Assembly-CSharp
+        m_MethodName: ApplyingForAssistance
+        m_Mode: 1
+        m_Arguments:
+          m_ObjectArgument: {fileID: 0}
+          m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
+          m_IntArgument: 0
+          m_FloatArgument: 0
+          m_StringArgument: 
+          m_BoolArgument: 0
+        m_CallState: 2
 --- !u!1 &1048561204019580574
 GameObject:
   m_ObjectHideFlags: 0
@@ -736,6 +748,18 @@ MonoBehaviour:
           m_StringArgument: 
           m_BoolArgument: 1
         m_CallState: 2
+      - m_Target: {fileID: 3651108695874027832}
+        m_TargetAssemblyTypeName: SupportControl, Assembly-CSharp
+        m_MethodName: LeaveRoom
+        m_Mode: 1
+        m_Arguments:
+          m_ObjectArgument: {fileID: 0}
+          m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
+          m_IntArgument: 0
+          m_FloatArgument: 0
+          m_StringArgument: 
+          m_BoolArgument: 1
+        m_CallState: 2
 --- !u!1 &1260289656693648063
 GameObject:
   m_ObjectHideFlags: 0
@@ -906,9 +930,9 @@ RectTransform:
   m_Father: {fileID: 372168226550290580}
   m_RootOrder: 2
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
-  m_AnchorMin: {x: 0, y: 0}
-  m_AnchorMax: {x: 0, y: 0}
-  m_AnchoredPosition: {x: 0, y: 0}
+  m_AnchorMin: {x: 0, y: 1}
+  m_AnchorMax: {x: 0, y: 1}
+  m_AnchoredPosition: {x: 1034.8295, y: -420}
   m_SizeDelta: {x: 1600, y: 144}
   m_Pivot: {x: 0.5, y: 0.5}
 --- !u!222 &2467664462275900261
@@ -1495,9 +1519,9 @@ RectTransform:
   m_Father: {fileID: 372168226550290580}
   m_RootOrder: 1
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
-  m_AnchorMin: {x: 0, y: 0}
-  m_AnchorMax: {x: 0, y: 0}
-  m_AnchoredPosition: {x: 0, y: 0}
+  m_AnchorMin: {x: 0, y: 1}
+  m_AnchorMax: {x: 0, y: 1}
+  m_AnchoredPosition: {x: 1034.8295, y: -246}
   m_SizeDelta: {x: 1600, y: 144}
   m_Pivot: {x: 0.5, y: 0.5}
 --- !u!222 &2792716997211558038
@@ -1940,6 +1964,7 @@ GameObject:
   - component: {fileID: 4028811318945949249}
   - component: {fileID: 869262423935497920}
   - component: {fileID: 6153650413569930801}
+  - component: {fileID: 1547342242773887768}
   m_Layer: 5
   m_Name: AllotPanel
   m_TagString: Untagged
@@ -2007,6 +2032,20 @@ MonoBehaviour:
   m_FillOrigin: 0
   m_UseSpriteMesh: 0
   m_PixelsPerUnitMultiplier: 1
+--- !u!114 &1547342242773887768
+MonoBehaviour:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 4654481251258314939}
+  m_Enabled: 1
+  m_EditorHideFlags: 0
+  m_Script: {fileID: 11500000, guid: 9b7826857ed5c9d439a6afc1b4465135, type: 3}
+  m_Name: 
+  m_EditorClassIdentifier: 
+  global: 1
+  allotText: {fileID: 3942195777747290161}
 --- !u!1 &4659326849150563262
 GameObject:
   m_ObjectHideFlags: 0
@@ -2568,9 +2607,9 @@ RectTransform:
   m_Father: {fileID: 372168226550290580}
   m_RootOrder: 0
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
-  m_AnchorMin: {x: 0, y: 0}
-  m_AnchorMax: {x: 0, y: 0}
-  m_AnchoredPosition: {x: 0, y: 0}
+  m_AnchorMin: {x: 0, y: 1}
+  m_AnchorMax: {x: 0, y: 1}
+  m_AnchoredPosition: {x: 1034.8295, y: -72}
   m_SizeDelta: {x: 1600, y: 144}
   m_Pivot: {x: 0.5, y: 0.5}
 --- !u!222 &1586159309132858650
@@ -2654,7 +2693,7 @@ GameObject:
   - component: {fileID: 2218335572122340914}
   - component: {fileID: 2774602144777026914}
   m_Layer: 5
-  m_Name: Call_Btn (1)
+  m_Name: Clear_Btn
   m_TagString: Untagged
   m_Icon: {fileID: 0}
   m_NavMeshLayer: 0

+ 42 - 3
Assets/Game/ShowSupport/SupportControl.cs

@@ -3,6 +3,9 @@ using UnityEngine.UI;
 using Blue;
 using TMPro;
 using UnityEngine.Events;
+using Newtonsoft.Json;
+using LitJson;
+using Newtonsoft.Json.Linq;
 
 public class SupportControl : AbstractController
 {
@@ -55,6 +58,32 @@ public class SupportControl : AbstractController
             UserList_Text.color = Color.white;
             ShowRtcHistory_Text.color = colorBlue;
         });
+
+        this.RegisterEvent<JoinRoomSuccessEvent>(JoinRoomSuccess).UnRegisterWhenGameObjectDestroyed(gameObject);
+    }
+
+    private void  JoinRoomSuccess(JoinRoomSuccessEvent e)
+    {
+
+        Debug.Log("DGJ   =====>  JoinRoomSuccess");
+        RTCRoomInfo mRTCRoomInfo = JsonConvert.DeserializeObject<RTCRoomInfo>(e.rtcRoomInfo);
+
+        JsonData data = new JsonData();
+        data["roomId"] = mRTCRoomInfo.roomId;
+        data["questionCategory"] = (int)Question;
+
+        HttpTool.Instance.SendHttp(HttpActionLang.apply, data.ToJson(), message =>
+        {
+            Debug.Log("DGJ ===> "+ HttpActionLang.apply+"   "+ message);
+            JObject jobject = JObject.Parse(message);
+            if (jobject["code"].ToString() == "200" && !string.IsNullOrWhiteSpace(jobject["data"].ToString()))
+            {
+              
+            }
+        });
+
+        ScenesManager.Instance.showWindow(ScenesManager.SceneType.ShowRoom);
+        ShowRoom.Instance.gotoWindow(ScenesManager.SceneType.RoomMain);
     }
     public void showRTC()
     {
@@ -87,6 +116,16 @@ public class SupportControl : AbstractController
         //ShowRTC.Instance.gotoWindow(ScenesManager.SceneType.ShowRTCHistory);
     }
 
+    public void ApplyingForAssistance()
+    {
+        this.GetService<IRTCService>().CreatRoom();
+    }
+
+    public void LeaveRoom()
+    {
+        this.GetService<IRTCService>().LeaveRoom();
+    }
+
     /// <summary>
     ///  选择问题
     /// </summary>
@@ -123,7 +162,7 @@ public class SupportControl : AbstractController
 
 public enum QuestionEnum
 {
-    NetWork,
-    Host,
-    Storage
+    NetWork =1,
+    Host=2,
+    Storage=3
 }

+ 2 - 0
Assets/HttpActionLang.cs

@@ -15,5 +15,7 @@ public class HttpActionLang : Singleton<HttpActionLang>
 
     public const string userinfo = "/mr-endustry/v1/user/info";
 
+    public const string apply = "/mr-endustry/v1/assistance/apply";
+
     public string mqttSocket ="";
 }

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

@@ -126,7 +126,7 @@ public class MQTTManager : MonoSingleton<MQTTManager>
               
                 break;
 
-            case "noexpert": // 无专家
+            case "noExpert": // 无专家
 
                 UICallManager.Instance.EventNoExpert();
                 break;

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

@@ -0,0 +1,15 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+using TMPro;
+
+public class AllotPanel : MonoSingleton<AllotPanel>
+{
+
+    public TMP_Text allotText;
+
+    public void SetAllotText( string msg)
+    {
+        allotText.text = msg;
+    }
+}

+ 11 - 0
Assets/Scripts/UI/AllotPanel.cs.meta

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

+ 32 - 3
Assets/Scripts/UICallManager.cs

@@ -41,9 +41,14 @@ public class UICallManager : MonoSingleton<UICallManager>,IController
         DispatcherBase.KeyUpDelegateRegister(AnyUp);
         OnTrackFound += OnTrackfound;
         OnTrackLast += OnTracklast;
-      //  MachineRoomInit("");
-       // MachineRoomInit();
-       
+        OnInvite += Oninvite;
+        OnTimeOut += OntimeOut;
+        OnNoExpert += OnnoExpert;
+
+    
+        //  MachineRoomInit("");
+        // MachineRoomInit();
+
     }
 
     public void OnTrackfound(DataItem item)
@@ -75,6 +80,30 @@ public class UICallManager : MonoSingleton<UICallManager>,IController
         OnNoExpert?.Invoke();
     }
 
+    public void Oninvite(string control ,string roomId)
+    {
+        this.GetService<IRTCService>().JoinRoom(roomId);
+    }
+
+    public void OntimeOut()
+    {
+        // 退出房间
+        this.GetService<IRTCService>().LeaveRoom();
+
+        // 改文字UI
+     //   AllotPanel.Instance.SetAllotText("");
+    }
+
+
+    public void OnnoExpert()
+    {
+        // 退出房间
+        this.GetService<IRTCService>().LeaveRoom();
+
+        // 改文字UI
+     //   AllotPanel.Instance.SetAllotText("");
+    }
+
     /// <summary>
     ///  设置MQTT房间ID
     /// </summary>