diff --git a/Packages/vr.teachr.webcommunication/Runtime/Scripts/CoachRtc.cs b/Packages/vr.teachr.webcommunication/Runtime/Scripts/CoachRtc.cs index 38929c886f5d4a5d4e7714ec3030c367258ce319..8ad02282ab378bd1206e79be4aa37d6ec9a52af9 100644 --- a/Packages/vr.teachr.webcommunication/Runtime/Scripts/CoachRtc.cs +++ b/Packages/vr.teachr.webcommunication/Runtime/Scripts/CoachRtc.cs @@ -25,9 +25,8 @@ namespace TeachR.WebCommunication private static readonly List<Msg> InboundStack = new(); public static bool Active { get; private set; } - private static UnityEvent configurationEvent; - private static UnityEvent dataCollectionEvent; - private static UnityEvent speechtoolEvent; + //private static UnityEvent configurationEvent; + //private static UnityEvent speechtoolEvent; public static Action<List<ScriptInfo>> OnScriptInfoListChanged; @@ -55,7 +54,8 @@ namespace TeachR.WebCommunication WebsocketDelegateHooks.OnFixedUpdate += RunEventLoop; RegisterFunctionCheckResultHandler(HandleFunctionCheckResult); RegisterScriptInfoListHandler(HandleScriptInfoListRequest); - RegisterDataCollectionHandler(HandleManageScriptInfo); + RegisterScriptInfoHandler(HandleScriptInfoUpdate); + RegisterDataCollectionHandler(HandleDataCollectionParameter); EventLogger.Instance.OnScriptInfoListChanged += HandleScriptInfoListEntryChanged; return Task.CompletedTask; @@ -92,14 +92,19 @@ namespace TeachR.WebCommunication Persistent.On("requestScriptInfoList", handler); } - private static void RegisterDataCollectionHandler(Action<JsonMsg> handler) + private static void RegisterScriptInfoHandler(Action<JsonMsg> handler) { Persistent.On("manageScriptInfo", handler); } + private static void RegisterDataCollectionHandler(Action<JsonMsg> handler) + { + Persistent.On("dataCollectionParameters", handler); + } + private static void HandleFunctionCheckResult(JsonMsg msg) { - Debug.Log($"Function check result received: {msg.content} DoTo: Do something with this information"); + Debug.Log($"[Debug] Function check result received: {msg.content} DoTo: Do something with this information"); } private static void HandleScriptInfoListRequest(JsonMsg msg) @@ -109,7 +114,19 @@ namespace TeachR.WebCommunication EventLogger.Instance.AddEventListenerAfterConnection(); } - private static void HandleManageScriptInfo(JsonMsg msg) + private static void HandleDataCollectionParameter(JsonMsg msg) + { + var data = msg.GetValue<Dictionary<string, object>>(); + + string name = data["logfileName"].ToString(); + bool selectAll = Convert.ToBoolean(data["autoselectAll"]); + + EventLogger.Instance.measurementName = name; + EventLogger.Instance.autoSelectAllScripts = selectAll; + } + + + private static void HandleScriptInfoUpdate(JsonMsg msg) { var data = msg.GetValue<Dictionary<string, object>>(); @@ -119,9 +136,7 @@ namespace TeachR.WebCommunication foreach (var scriptInfo in EventLogger.Instance.scriptInfoList) { if (scriptInfo.scriptAlias == scriptAlias) - { scriptInfo.SetLogValueByWebsite(logValue); - } } } @@ -129,7 +144,6 @@ namespace TeachR.WebCommunication { var info = scriptInfo.GetScriptInfoAsJson(); Send("updateScriptInfoEntry", info); - Debug.Log($"[DATA] update script Info entry: {info}"); } /// <summary> @@ -194,20 +208,10 @@ namespace TeachR.WebCommunication { Debug.Log($"[DEBUG] received configuration parameters: {arg2}"); } - else if (arg1.Equals("dataCollectionParameters")) - { - Debug.Log($"[DATA] received data collection parameters: {arg2}"); - //var parameters = JsonUtility.FromJson<DataCollectionParameters>(arg2); - //EventLogger.Instance.UpdateDataCollectionParameters(parameters); - } else if (arg1.Equals("speechtoolParameters")) { Debug.Log($"[DEBUG] received speechtool parameters: {arg2}"); } - //else if (arg1.Equals("requestScriptInfoList")) - //{ - // Debug.Log($"[DEBUG] received requestScriptInfoList : {arg2}"); - //} } private static void RunEventLoop()