Update MessageReceiver.cs, app.js #132

This commit is contained in:
Namhyeon Go 2024-08-20 09:25:50 +09:00
parent c8b3ac5d99
commit f181bf2696
2 changed files with 7 additions and 1 deletions

View File

@ -3,6 +3,7 @@
using DeviceId;
using Grpc.Core;
using Grpc.Net.Client;
using System;
using System.ServiceProcess;
using System.Threading.Tasks;
using WelsonJS.GrpcService;
@ -33,8 +34,9 @@ namespace WelsonJS.Service
// Set the GRPC channel
channel = GrpcChannel.ForAddress(grpcServerAddress);
}
catch
catch (Exception ex)
{
this.parent.Log(ex.Message);
channel = null;
}
}
@ -67,6 +69,9 @@ namespace WelsonJS.Service
{
var response = call.ResponseStream.Current;
parent.Log($"Received: {response.Message}");
// dispatch to the script runtime
parent.DispatchServiceEvent("messageReceived", new string[] { response.Message });
}
}
finally

1
app.js
View File

@ -621,6 +621,7 @@ function dispatchServiceEvent(name, eventType, _args) {
start: bind("ServiceStart"),
stop: bind("ServiceStop"),
elapsedTime: bind("ServiceElapsedTime"),
messageReceived: bind("MessageReceived"),
screenTime: bind("ServiceScreenTime"),
fileCreated: bind("FileCreated"),
fileRuleMatched: bind("FileRuleMatched")