routing fix

This commit is contained in:
2022-03-01 12:59:23 +01:00
parent 4903014ebd
commit ecf4f9c719
3 changed files with 16 additions and 14 deletions

View File

@@ -74,7 +74,11 @@ class Routing {
data: null
}
interf.send(pack.fromID,Net.instance.networkID,response);
// HACK: Because Lua is singelthreaded the computer we respond to can get overwhelmed with
// the responses and can swollow events.
new Timer(Net.instance.networkID / 3,()->{
interf.send(response.toID,Net.instance.networkID,response);
});
}
private function genRouteList(): Array<{id:NetworkID,cost:Int}> {
@@ -109,18 +113,16 @@ class Routing {
return;
}
Log.debug("a");
var fullCost = cost+interf.getBaseRoutingCost();
if (this.routingTable.exists(toID)){
if (this.routingTable[toID].cost > fullCost){
Log.debug("Better route: " + toID + " -> " + interf.name() + ":$"+fullCost);
Log.info("Better route: " + toID + " -> " + interf.name() + ":$"+fullCost);
this.routingTable[toID] = {interf:interf,cost:cost + interf.getBaseRoutingCost()};
}
}else{
this.routingTable[toID] = {interf:interf,cost:cost + interf.getBaseRoutingCost()};
Log.debug("New route: " + toID + " -> " + interf.name() + ":$"+fullCost);
Log.info("New route: " + toID + " -> " + interf.name() + ":$"+fullCost);
this.onNewNeigborTrigger.trigger(toID);
}
}