Update the Screen Matching feature

This commit is contained in:
Namhyeon Go 2024-07-29 22:28:07 +09:00
parent b687cf7727
commit 3b09a47fb8
5 changed files with 16 additions and 8 deletions

View File

@ -114,7 +114,7 @@ namespace WelsonJS.Service
Timer screenTimer = new Timer
{
Interval = 1000 // 1 second
Interval = 10000 // 10 seconds
};
screenTimer.Elapsed += OnScreenTime;
timers.Add(screenTimer);
@ -224,10 +224,9 @@ namespace WelsonJS.Service
Log(result.ScreenNumber.ToString());
Log(result.Location.ToString());
Log(DispatchServiceEvent("screenTime", new object[]
Log(DispatchServiceEvent("screenTime", new string[]
{
result.FileName,
result.ScreenNumber.ToString(),
result.Location.X.ToString(),
result.Location.Y.ToString(),
result.MaxCorrelation.ToString()
@ -240,9 +239,17 @@ namespace WelsonJS.Service
}
}
private string DispatchServiceEvent(string eventType, object[] args = null)
private string DispatchServiceEvent(string eventType, string[] args = null)
{
return InvokeScriptMethod("dispatchServiceEvent", scriptName, eventType, args);
if (args == null)
{
return InvokeScriptMethod("dispatchServiceEvent", scriptName, eventType, "");
}
else
{
return InvokeScriptMethod("dispatchServiceEvent", scriptName, eventType, String.Join("; ", args));
}
}
private string InvokeScriptMethod(string methodName, params object[] parameters)

3
app.js
View File

@ -589,8 +589,9 @@ function initializeWindow(name, args, w, h) {
}
}
function dispatchServiceEvent(name, eventType, args) {
function dispatchServiceEvent(name, eventType, _args) {
var app = require(name);
var args = _args.split('; ');
// load the service
if (app) {

Binary file not shown.

Binary file not shown.

View File

@ -14,8 +14,8 @@ function onServiceElapsedTime() {
return "onServiceElapsedTime recevied";
}
function onServiceScreenTime(filename, handle, title, x, y, maxCorrelation) {
return "onServiceScreenTime recevied. " + filename;
function onServiceScreenTime(args) {
return "onServiceScreenTime recevied. " + args.join(', ');
}
exports.main = main;