added onNewNeigbor
This commit is contained in:
parent
fd745d623c
commit
e2431666e1
@ -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));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user