/*
- * jFCPlib - FcpClient.java -
- * Copyright © 2009 David Roden
+ * jFCPlib - FcpClient.java - Copyright © 2009 David Roden
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
/** Object used for synchronization. */
private final Object syncObject = new Object();
+ /** Listener management. */
+ private final FcpClientListenerManager fcpClientListenerManager = new FcpClientListenerManager(this);
+
/** The name of this client. */
private final String name;
public FcpClient(String name, InetAddress host, int port) {
this.name = name;
fcpConnection = new FcpConnection(host, port);
+ fcpConnection.addFcpListener(new FcpAdapter() {
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ @SuppressWarnings("synthetic-access")
+ public void connectionClosed(FcpConnection fcpConnection, Throwable throwable) {
+ connected = false;
+ fcpClientListenerManager.fireFcpClientDisconnected();
+ }
+ });
+ }
+
+ //
+ // LISTENER MANAGEMENT
+ //
+
+ /**
+ * Adds an FCP listener to the underlying connection.
+ *
+ * @param fcpListener
+ * The FCP listener to add
+ */
+ public void addFcpListener(FcpListener fcpListener) {
+ fcpConnection.addFcpListener(fcpListener);
+ }
+
+ /**
+ * Removes an FCP listener from the underlying connection.
+ *
+ * @param fcpListener
+ * The FCP listener to remove
+ */
+ public void removeFcpListener(FcpListener fcpListener) {
+ fcpConnection.removeFcpListener(fcpListener);
+ }
+
+ /**
+ * Adds an FCP client listener to the list of registered listeners.
+ *
+ * @param fcpClientListener
+ * The FCP client listener to add
+ */
+ public void addFcpClientListener(FcpClientListener fcpClientListener) {
+ fcpClientListenerManager.addListener(fcpClientListener);
+ }
+
+ /**
+ * Removes an FCP client listener from the list of registered listeners.
+ *
+ * @param fcpClientListener
+ * The FCP client listener to remove
+ */
+ public void removeFcpClientListener(FcpClientListener fcpClientListener) {
+ fcpClientListenerManager.removeListener(fcpClientListener);
}
//