X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Ffcp%2FFcpConnection.java;h=0eda39ddf8b5d9396ef3289c8b7e23fead5f0dd0;hb=064ea7223eef47bdcef90d2c63f91620171fc955;hp=2f407858a2591b549d8ede2890b769f32c2e2a6e;hpb=508624458578f01a393f8b44f32b98b40054fdc8;p=jFCPlib.git diff --git a/src/main/java/net/pterodactylus/fcp/FcpConnection.java b/src/main/java/net/pterodactylus/fcp/FcpConnection.java index 2f40785..0eda39d 100644 --- a/src/main/java/net/pterodactylus/fcp/FcpConnection.java +++ b/src/main/java/net/pterodactylus/fcp/FcpConnection.java @@ -66,7 +66,7 @@ public class FcpConnection implements Closeable { private FcpConnectionHandler connectionHandler; /** Incoming message statistics. */ - private Map incomingMessageStatistics = Collections.synchronizedMap(new HashMap()); + private static final Map incomingMessageStatistics = Collections.synchronizedMap(new HashMap()); /** * Creates a new FCP connection to the freenet node running on localhost, @@ -156,6 +156,10 @@ public class FcpConnection implements Closeable { fcpListenerManager.removeListener(fcpListener); } + public synchronized boolean isClosed() { + return connectionHandler != null; + } + // // ACTIONS // @@ -191,9 +195,10 @@ public class FcpConnection implements Closeable { } /** - * 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); } @@ -260,6 +265,8 @@ public class FcpConnection implements Closeable { 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)) { @@ -296,6 +303,8 @@ public class FcpConnection implements Closeable { } } 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)) { @@ -321,8 +330,8 @@ public class FcpConnection implements Closeable { * Handles a disconnect from the node. * * @param throwable - * The exception that caused the disconnect, or null - * if there was no exception + * The exception that caused the disconnect, or + * null if there was no exception */ synchronized void handleDisconnect(Throwable throwable) { FcpUtils.close(remoteInputStream); @@ -370,8 +379,8 @@ public class FcpConnection implements Closeable { } /** - * 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> */ @@ -452,7 +461,7 @@ public class FcpConnection implements Closeable { * @see java.io.FilterInputStream#mark(int) */ @Override - public void mark(int readlimit) { + public synchronized void mark(int readlimit) { /* do nothing. */ } @@ -474,7 +483,7 @@ public class FcpConnection implements Closeable { * @see java.io.FilterInputStream#reset() */ @Override - public void reset() throws IOException { + public synchronized void reset() throws IOException { /* do nothing. */ }