From e2431666e17c306667416eaeaf8a3b9ecabfb946 Mon Sep 17 00:00:00 2001 From: Djeeberjr Date: Tue, 22 Feb 2022 01:47:55 +0100 Subject: [PATCH] added onNewNeigbor --- src/kernel/net/Net.hx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/kernel/net/Net.hx b/src/kernel/net/Net.hx index bc7a34d..bf781b2 100644 --- a/src/kernel/net/Net.hx +++ b/src/kernel/net/Net.hx @@ -1,5 +1,7 @@ package kernel.net; +using tink.CoreApi; + import kernel.peripherals.Peripherals.Peripheral; import kernel.Log; import kernel.KernelEvents; @@ -19,8 +21,12 @@ using util.Extender.LambdaExtender; class Net { public static var instance:Net; + public final onNewNeigbor: Signal; + private final onNewNeigborTrigger: SignalTrigger = Signal.trigger(); + @:allow(kernel.Init) private function new() { + onNewNeigbor = onNewNeigborTrigger.asSignal(); KernelEvents.instance.onModemMessage.handle(params -> { var pack:Package = { fromID: params.replyChannel, @@ -108,6 +114,7 @@ class Net { private function addRoute(toID:Int, addr:String) { Log.debug("Added new route to " + toID + " via " + addr); + this.onNewNeigborTrigger.trigger(toID); routingTable.set(toID, allModems.find(item -> item.addr == addr)); }