added onNewNeigbor
This commit is contained in:
parent
fd745d623c
commit
e2431666e1
@ -1,5 +1,7 @@
|
|||||||
package kernel.net;
|
package kernel.net;
|
||||||
|
|
||||||
|
using tink.CoreApi;
|
||||||
|
|
||||||
import kernel.peripherals.Peripherals.Peripheral;
|
import kernel.peripherals.Peripherals.Peripheral;
|
||||||
import kernel.Log;
|
import kernel.Log;
|
||||||
import kernel.KernelEvents;
|
import kernel.KernelEvents;
|
||||||
@ -19,8 +21,12 @@ using util.Extender.LambdaExtender;
|
|||||||
class Net {
|
class Net {
|
||||||
public static var instance:Net;
|
public static var instance:Net;
|
||||||
|
|
||||||
|
public final onNewNeigbor: Signal<Int>;
|
||||||
|
private final onNewNeigborTrigger: SignalTrigger<Int> = Signal.trigger();
|
||||||
|
|
||||||
@:allow(kernel.Init)
|
@:allow(kernel.Init)
|
||||||
private function new() {
|
private function new() {
|
||||||
|
onNewNeigbor = onNewNeigborTrigger.asSignal();
|
||||||
KernelEvents.instance.onModemMessage.handle(params -> {
|
KernelEvents.instance.onModemMessage.handle(params -> {
|
||||||
var pack:Package = {
|
var pack:Package = {
|
||||||
fromID: params.replyChannel,
|
fromID: params.replyChannel,
|
||||||
@ -108,6 +114,7 @@ class Net {
|
|||||||
|
|
||||||
private function addRoute(toID:Int, addr:String) {
|
private function addRoute(toID:Int, addr:String) {
|
||||||
Log.debug("Added new route to " + toID + " via " + addr);
|
Log.debug("Added new route to " + toID + " via " + addr);
|
||||||
|
this.onNewNeigborTrigger.trigger(toID);
|
||||||
routingTable.set(toID, allModems.find(item -> item.addr == addr));
|
routingTable.set(toID, allModems.find(item -> item.addr == addr));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user