private FcpConnectionHandler connectionHandler;
/** Incoming message statistics. */
- private Map<String, Integer> incomingMessageStatistics = Collections.synchronizedMap(new HashMap<String, Integer>());
+ private static final Map<String, Integer> incomingMessageStatistics = Collections.synchronizedMap(new HashMap<String, Integer>());
/**
* Creates a new FCP connection to the freenet node running on localhost,
fcpListenerManager.removeListener(fcpListener);
}
+ public synchronized boolean isClosed() {
+ return connectionHandler != null;
+ }
+
//
// ACTIONS
//
}
/**
- * Closes the connection. If there is no connection to the node, this method
- * does nothing.
+ * Closes the connection. If there is no connection to the node, this
+ * method does nothing.
*/
+ @Override
public void close() {
handleDisconnect(null);
}
fcpListenerManager.fireReceivedDataFound(new DataFound(fcpMessage));
} else if ("SubscribedUSKUpdate".equals(messageName)) {
fcpListenerManager.fireReceivedSubscribedUSKUpdate(new SubscribedUSKUpdate(fcpMessage));
+ } else if ("SubscribedUSK".equals(messageName)) {
+ fcpListenerManager.fireReceivedSubscribedUSK(new SubscribedUSK(fcpMessage));
} else if ("IdentifierCollision".equals(messageName)) {
fcpListenerManager.fireReceivedIdentifierCollision(new IdentifierCollision(fcpMessage));
} else if ("AllData".equals(messageName)) {
}
} else if ("PluginInfo".equals(messageName)) {
fcpListenerManager.fireReceivedPluginInfo(new PluginInfo(fcpMessage));
+ } else if ("PluginRemoved".equals(messageName)) {
+ fcpListenerManager.fireReceivedPluginRemoved(new PluginRemoved(fcpMessage));
} else if ("NodeData".equals(messageName)) {
fcpListenerManager.fireReceivedNodeData(new NodeData(fcpMessage));
} else if ("TestDDAReply".equals(messageName)) {
* Handles a disconnect from the node.
*
* @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
*/
synchronized void handleDisconnect(Throwable throwable) {
FcpUtils.close(remoteInputStream);
}
/**
- * A wrapper around an {@link InputStream} that only supplies a limit number
- * of bytes from the underlying input stream.
+ * A wrapper around an {@link InputStream} that only supplies a limit
+ * number of bytes from the underlying input stream.
*
* @author David ‘Bombe’ Roden <bombe@freenetproject.org>
*/
* @see java.io.FilterInputStream#mark(int)
*/
@Override
- public void mark(int readlimit) {
+ public synchronized void mark(int readlimit) {
/* do nothing. */
}
* @see java.io.FilterInputStream#reset()
*/
@Override
- public void reset() throws IOException {
+ public synchronized void reset() throws IOException {
/* do nothing. */
}