Fixed bug: upnp status sometimes not updated

This commit is contained in:
Monsterovich 2024-04-03 04:18:45 +02:00
parent a2afb3cab6
commit b87208883e
2 changed files with 6 additions and 2 deletions

View file

@ -105,7 +105,7 @@ public class InfoWindow extends javax.swing.JFrame implements RoutungTableListen
"ID: " + connectionManager.getLocalAddr() + "ID: " + connectionManager.getLocalAddr() +
" Port: " + connectionManager.getServerPort()); " Port: " + connectionManager.getServerPort());
connectionManager.getRouter().addTableListener(InfoWindow.this); connectionManager.getRouter().addTableListener(InfoWindow.this);
connectionManager.getUPnPPortForward().addListener(InfoWindow.this); connectionManager.getUPnPPortForward().addListener(InfoWindow.this, true);
} }
peerGraph.setConnectionManager(connectionManager); peerGraph.setConnectionManager(connectionManager);
} }

View file

@ -120,10 +120,14 @@ public class UPnPPortForward {
* Set the object of the upperlayer. * Set the object of the upperlayer.
* *
* @param l the upper layer * @param l the upper layer
* @param refresh update the listener after adding
*/ */
public void addListener(UPnPPortForwardListener l) { public void addListener(UPnPPortForwardListener l, boolean refresh) {
synchronized (listeners) { synchronized (listeners) {
listeners.add(l); listeners.add(l);
if (refresh) {
l.upnpChanged(this);
}
} }
} }