added onNewNeigbor

This commit is contained in:
Djeeberjr 2022-02-22 01:47:55 +01:00
parent fd745d623c
commit e2431666e1

View File

@ -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<Int>;
private final onNewNeigborTrigger: SignalTrigger<Int> = 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));
}