package net.pterodactylus.fcp;
-import net.pterodactylus.util.event.AbstractListenerManager;
+import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
/**
* Manages FCP listeners and event firing.
*
* @author David ‘Bombe’ Roden <bombe@pterodactylus.net>
*/
-public class FcpListenerManager extends AbstractListenerManager<FcpConnection, FcpListener> {
+public class FcpListenerManager {
+
+ private final FcpConnection source;
+ private final List<FcpListener> listeners = new CopyOnWriteArrayList<FcpListener>();
/**
* Creates a new listener manager.
* The source FCP connection
*/
public FcpListenerManager(FcpConnection fcpConnection) {
- super(fcpConnection);
+ this.source = fcpConnection;
+ }
+
+ public void addListener(FcpListener fcpListener) {
+ listeners.add(fcpListener);
+ }
+
+ public void removeListener(FcpListener fcpListener) {
+ listeners.remove(fcpListener);
+ }
+
+ private FcpConnection getSource() {
+ return source;
+ }
+
+ private List<FcpListener> getListeners() {
+ return listeners;
}
/**
*
* @see FcpListener#receivedPeerNote(FcpConnection, PeerNote)
* @param peerNote
+ * The “PeerNote” message
*/
public void fireReceivedPeerNote(PeerNote peerNote) {
for (FcpListener fcpListener : getListeners()) {
}
/**
- * Notifies all listeners that a “FinishedCompression” message was received.
+ * Notifies all listeners that a “FinishedCompression” message was
+ * received.
*
* @see FcpListener#receivedFinishedCompression(FcpConnection,
* FinishedCompression)
}
/**
- * Notifies all listeners that a “SubscribedUSKUpdate” message was received.
+ * Notifies all listeners that a “SubscribedUSKUpdate” message was
+ * received.
*
* @see FcpListener#receivedSubscribedUSKUpdate(FcpConnection,
* SubscribedUSKUpdate)
* Notifies all listeners that the connection to the node was closed.
*
* @param throwable
- * The exception that caused the disconnect, or <code>null</code>
- * if there was no exception
+ * The exception that caused the disconnect, or
+ * <code>null</code> if there was no exception
* @see FcpListener#connectionClosed(FcpConnection, Throwable)
*/
public void fireConnectionClosed(Throwable throwable) {