avoid relaying changes if theres no one listening to the passthrough

This commit is contained in:
Salomão
2021-07-05 19:56:41 -03:00
parent b6eef99312
commit d48c24a2e1
3 changed files with 19 additions and 1 deletions
+1 -1
View File
@@ -262,7 +262,7 @@ public class NetworkMonitor<T extends IAEStack<T>> implements IMEMonitor<T>
{
final Entry<IMEMonitorHandlerReceiver<T>, Object> o = i.next();
final IMEMonitorHandlerReceiver<T> receiver = o.getKey();
if( receiver.isValid( o.getValue() ) )
if( receiver.isValid( o.getValue() ) && receiver.hasListeners() )
{
receiver.postChange( this, diff, src );
}
@@ -90,6 +90,13 @@ public class MEMonitorPassThrough<T extends IAEStack<T>> extends MEPassThrough<T
@Override
public void addListener( final IMEMonitorHandlerReceiver<T> l, final Object verificationToken )
{
if( this.listeners.size() == 0 )
{
if( this.monitor != null )
{
this.monitor.addListener( this, this.monitor );
}
}
this.listeners.put( l, verificationToken );
}
@@ -117,6 +124,12 @@ public class MEMonitorPassThrough<T extends IAEStack<T>> extends MEPassThrough<T
return verificationToken == this.monitor;
}
@Override
public boolean hasListeners()
{
return this.listeners.size() > 0;
}
@Override
public void postChange( final IBaseMonitor<T> monitor, final Iterable<T> change, final IActionSource source )
{