Skip to content
Snippets Groups Projects
Commit c4d32c00 authored by scherlit's avatar scherlit
Browse files

Update CoachRtc.cs

- handle incomping parameter values (EventLogger, "selectAll" and "logFileName")
parent d41dbe99
Branches vaMigration
No related tags found
No related merge requests found
...@@ -25,9 +25,8 @@ namespace TeachR.WebCommunication ...@@ -25,9 +25,8 @@ namespace TeachR.WebCommunication
private static readonly List<Msg> InboundStack = new(); private static readonly List<Msg> InboundStack = new();
public static bool Active { get; private set; } public static bool Active { get; private set; }
private static UnityEvent configurationEvent; //private static UnityEvent configurationEvent;
private static UnityEvent dataCollectionEvent; //private static UnityEvent speechtoolEvent;
private static UnityEvent speechtoolEvent;
public static Action<List<ScriptInfo>> OnScriptInfoListChanged; public static Action<List<ScriptInfo>> OnScriptInfoListChanged;
...@@ -55,7 +54,8 @@ namespace TeachR.WebCommunication ...@@ -55,7 +54,8 @@ namespace TeachR.WebCommunication
WebsocketDelegateHooks.OnFixedUpdate += RunEventLoop; WebsocketDelegateHooks.OnFixedUpdate += RunEventLoop;
RegisterFunctionCheckResultHandler(HandleFunctionCheckResult); RegisterFunctionCheckResultHandler(HandleFunctionCheckResult);
RegisterScriptInfoListHandler(HandleScriptInfoListRequest); RegisterScriptInfoListHandler(HandleScriptInfoListRequest);
RegisterDataCollectionHandler(HandleManageScriptInfo); RegisterScriptInfoHandler(HandleScriptInfoUpdate);
RegisterDataCollectionHandler(HandleDataCollectionParameter);
EventLogger.Instance.OnScriptInfoListChanged += HandleScriptInfoListEntryChanged; EventLogger.Instance.OnScriptInfoListChanged += HandleScriptInfoListEntryChanged;
return Task.CompletedTask; return Task.CompletedTask;
...@@ -92,14 +92,19 @@ namespace TeachR.WebCommunication ...@@ -92,14 +92,19 @@ namespace TeachR.WebCommunication
Persistent.On("requestScriptInfoList", handler); Persistent.On("requestScriptInfoList", handler);
} }
private static void RegisterDataCollectionHandler(Action<JsonMsg> handler) private static void RegisterScriptInfoHandler(Action<JsonMsg> handler)
{ {
Persistent.On("manageScriptInfo", handler); Persistent.On("manageScriptInfo", handler);
} }
private static void RegisterDataCollectionHandler(Action<JsonMsg> handler)
{
Persistent.On("dataCollectionParameters", handler);
}
private static void HandleFunctionCheckResult(JsonMsg msg) 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) private static void HandleScriptInfoListRequest(JsonMsg msg)
...@@ -109,7 +114,19 @@ namespace TeachR.WebCommunication ...@@ -109,7 +114,19 @@ namespace TeachR.WebCommunication
EventLogger.Instance.AddEventListenerAfterConnection(); 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>>(); var data = msg.GetValue<Dictionary<string, object>>();
...@@ -119,9 +136,7 @@ namespace TeachR.WebCommunication ...@@ -119,9 +136,7 @@ namespace TeachR.WebCommunication
foreach (var scriptInfo in EventLogger.Instance.scriptInfoList) foreach (var scriptInfo in EventLogger.Instance.scriptInfoList)
{ {
if (scriptInfo.scriptAlias == scriptAlias) if (scriptInfo.scriptAlias == scriptAlias)
{
scriptInfo.SetLogValueByWebsite(logValue); scriptInfo.SetLogValueByWebsite(logValue);
}
} }
} }
...@@ -129,7 +144,6 @@ namespace TeachR.WebCommunication ...@@ -129,7 +144,6 @@ namespace TeachR.WebCommunication
{ {
var info = scriptInfo.GetScriptInfoAsJson(); var info = scriptInfo.GetScriptInfoAsJson();
Send("updateScriptInfoEntry", info); Send("updateScriptInfoEntry", info);
Debug.Log($"[DATA] update script Info entry: {info}");
} }
/// <summary> /// <summary>
...@@ -194,20 +208,10 @@ namespace TeachR.WebCommunication ...@@ -194,20 +208,10 @@ namespace TeachR.WebCommunication
{ {
Debug.Log($"[DEBUG] received configuration parameters: {arg2}"); 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")) else if (arg1.Equals("speechtoolParameters"))
{ {
Debug.Log($"[DEBUG] received speechtool parameters: {arg2}"); Debug.Log($"[DEBUG] received speechtool parameters: {arg2}");
} }
//else if (arg1.Equals("requestScriptInfoList"))
//{
// Debug.Log($"[DEBUG] received requestScriptInfoList : {arg2}");
//}
} }
private static void RunEventLoop() private static void RunEventLoop()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment