From 9b10ff1d1415dd5eb2cc5e2def31c071c6f3584c Mon Sep 17 00:00:00 2001 From: Djeeberjr Date: Mon, 29 May 2023 21:49:41 +0200 Subject: [PATCH] added example service --- src/bin/HelloWorldService.hx | 23 +++++++++++++++++++++++ src/kernel/binstore/BinStore.hx | 4 +++- 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 src/bin/HelloWorldService.hx diff --git a/src/bin/HelloWorldService.hx b/src/bin/HelloWorldService.hx new file mode 100644 index 0000000..cd67c55 --- /dev/null +++ b/src/bin/HelloWorldService.hx @@ -0,0 +1,23 @@ +package bin; + +import kernel.log.Log; +import kernel.Timer; +import kernel.ps.ProcessHandle; +import kernel.ps.Process; + +class HelloWorldService implements Process { + public function new() {} + + public function run(handle:ProcessHandle) { + Log.debug("HelloWorldService started"); + handle.write("Hello World! Started\n"); + this.startTimer(handle); + } + + public function startTimer(handle: ProcessHandle) { + new Timer(1000, function() { + handle.write("Hello World!\n"); + this.startTimer(handle); + }); + } +} \ No newline at end of file diff --git a/src/kernel/binstore/BinStore.hx b/src/kernel/binstore/BinStore.hx index 39e8412..942b5de 100644 --- a/src/kernel/binstore/BinStore.hx +++ b/src/kernel/binstore/BinStore.hx @@ -1,5 +1,6 @@ package kernel.binstore; +import bin.HelloWorldService; import bin.Service; import bin.LSPS; import bin.Turtle; @@ -25,7 +26,8 @@ class BinStore { {c: Terminal, name: "Terminal", aliases: ["terminal","term"]}, {c: Turtle, name: "Turtle", aliases: ["turtle"]}, {c: LSPS, name: "PM", aliases: ["lsps"]}, - {c: Service, name: "Service", aliases: ["service","srv"]} + {c: Service, name: "Service", aliases: ["service","srv"]}, + {c: HelloWorldService, name: "HelloWorldService", aliases: ["hello-service"] } ]; @:allow(kernel.Init)