X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;ds=sidebyside;f=src%2Fnet%2Fpterodactylus%2Futil%2Ffcp%2FFcpConnection.java;h=748bb8f18bff478f2f58b1a6dbd977ba4045b587;hb=668a21e6b2cb3393710f0570589068925c483448;hp=9a132641619c364073401b246bbae6554f2d0dc0;hpb=b905d1b51018f68ba5e8c598781a494921318c91;p=jSite2.git diff --git a/src/net/pterodactylus/util/fcp/FcpConnection.java b/src/net/pterodactylus/util/fcp/FcpConnection.java index 9a13264..748bb8f 100644 --- a/src/net/pterodactylus/util/fcp/FcpConnection.java +++ b/src/net/pterodactylus/util/fcp/FcpConnection.java @@ -305,6 +305,7 @@ public class FcpConnection { /** * Notifies all listeners that a “PersistentGet” message was received. * + * @see FcpListener#receivedPersistentGet(FcpConnection, PersistentGet) * @param persistentGet * The “PersistentGet” message */ @@ -331,6 +332,8 @@ public class FcpConnection { * Notifies all listeners that a “EndListPersistentRequests” message was * received. * + * @see FcpListener#receivedEndListPersistentRequests(FcpConnection, + * EndListPersistentRequests) * @param endListPersistentRequests * The “EndListPersistentRequests” message */ @@ -343,6 +346,7 @@ public class FcpConnection { /** * Notifies all listeners that a “URIGenerated” message was received. * + * @see FcpListener#receivedURIGenerated(FcpConnection, URIGenerated) * @param uriGenerated * The “URIGenerated” message */ @@ -355,6 +359,7 @@ public class FcpConnection { /** * Notifies all listeners that a “DataFound” message was received. * + * @see FcpListener#receivedDataFound(FcpConnection, DataFound) * @param dataFound * The “DataFound” message */ @@ -367,6 +372,7 @@ public class FcpConnection { /** * Notifies all listeners that an “AllData” message was received. * + * @see FcpListener#receivedAllData(FcpConnection, AllData) * @param allData * The “AllData” message */ @@ -379,6 +385,7 @@ public class FcpConnection { /** * Notifies all listeners that a “SimpleProgress” message was received. * + * @see FcpListener#receivedSimpleProgress(FcpConnection, SimpleProgress) * @param simpleProgress * The “SimpleProgress” message */ @@ -391,6 +398,8 @@ public class FcpConnection { /** * Notifies all listeners that a “StartedCompression” message was received. * + * @see FcpListener#receivedStartedCompression(FcpConnection, + * StartedCompression) * @param startedCompression * The “StartedCompression” message */ @@ -403,6 +412,8 @@ public class FcpConnection { /** * Notifies all listeners that a “FinishedCompression” message was received. * + * @see FcpListener#receviedFinishedCompression(FcpConnection, + * FinishedCompression) * @param finishedCompression * The “FinishedCompression” message */ @@ -416,6 +427,8 @@ public class FcpConnection { * Notifies all listeners that an “UnknownPeerNoteType” message was * received. * + * @see FcpListener#receivedUnknownPeerNoteType(FcpConnection, + * UnknownPeerNoteType) * @param unknownPeerNoteType * The “UnknownPeerNoteType” message */ @@ -429,6 +442,8 @@ public class FcpConnection { * Notifies all listeners that an “UnknownNodeIdentifier” message was * received. * + * @see FcpListener#receivedUnknownNodeIdentifier(FcpConnection, + * UnknownNodeIdentifier) * @param unknownNodeIdentifier * The “UnknownNodeIdentifier” message */ @@ -441,6 +456,7 @@ public class FcpConnection { /** * Notifies all listeners that a “ConfigData” message was received. * + * @see FcpListener#receivedConfigData(FcpConnection, ConfigData) * @param configData * The “ConfigData” message */ @@ -453,6 +469,7 @@ public class FcpConnection { /** * Notifies all listeners that a “GetFailed” message was received. * + * @see FcpListener#receivedGetFailed(FcpConnection, GetFailed) * @param getFailed * The “GetFailed” message */ @@ -465,6 +482,7 @@ public class FcpConnection { /** * Notifies all listeners that a “PutFailed” message was received. * + * @see FcpListener#receivedPutFailed(FcpConnection, PutFailed) * @param putFailed * The “PutFailed” message */ @@ -478,6 +496,8 @@ public class FcpConnection { * Notifies all listeners that an “IdentifierCollision” message was * received. * + * @see FcpListener#receivedIdentifierCollision(FcpConnection, + * IdentifierCollision) * @param identifierCollision * The “IdentifierCollision” message */ @@ -490,6 +510,8 @@ public class FcpConnection { /** * Notifies all listeners that an “PersistentPutDir” message was received. * + * @see FcpListener#receivedPersistentPutDir(FcpConnection, + * PersistentPutDir) * @param persistentPutDir * The “PersistentPutDir” message */ @@ -503,6 +525,8 @@ public class FcpConnection { * Notifies all listeners that a “PersistentRequestRemoved” message was * received. * + * @see FcpListener#receivedPersistentRequestRemoved(FcpConnection, + * PersistentRequestRemoved) * @param persistentRequestRemoved * The “PersistentRequestRemoved” message */ @@ -515,6 +539,8 @@ public class FcpConnection { /** * Notifies all listeners that a “SubscribedUSKUpdate” message was received. * + * @see FcpListener#receivedSubscribedUSKUpdate(FcpConnection, + * SubscribedUSKUpdate) * @param subscribedUSKUpdate * The “SubscribedUSKUpdate” message */ @@ -527,6 +553,7 @@ public class FcpConnection { /** * Notifies all listeners that a “PluginInfo” message was received. * + * @see FcpListener#receivedPluginInfo(FcpConnection, PluginInfo) * @param pluginInfo * The “PluginInfo” message */ @@ -539,6 +566,7 @@ public class FcpConnection { /** * Notifies all listeners that an “FCPPluginReply” message was received. * + * @see FcpListener#receivedFCPPluginReply(FcpConnection, FCPPluginReply) * @param fcpPluginReply * The “FCPPluginReply” message */ @@ -549,8 +577,50 @@ public class FcpConnection { } /** + * Notifies all listeners that a “PersistentRequestModified” message was + * received. + * + * @see FcpListener#receivedPersistentRequestModified(FcpConnection, + * PersistentRequestModified) + * @param persistentRequestModified + * The “PersistentRequestModified” message + */ + private void fireReceivedPersistentRequestModified(PersistentRequestModified persistentRequestModified) { + for (FcpListener fcpListener: fcpListeners) { + fcpListener.receivedPersistentRequestModified(this, persistentRequestModified); + } + } + + /** + * Notifies all listeners that a “PutSuccessful” message was received. + * + * @see FcpListener#receivedPutSuccessful(FcpConnection, PutSuccessful) + * @param putSuccessful + * The “PutSuccessful” message + */ + private void fireReceivedPutSuccessful(PutSuccessful putSuccessful) { + for (FcpListener fcpListener: fcpListeners) { + fcpListener.receivedPutSuccessful(this, putSuccessful); + } + } + + /** + * Notifies all listeners that a “PutFetchable” message was received. + * + * @see FcpListener#receivedPutFetchable(FcpConnection, PutFetchable) + * @param putFetchable + * The “PutFetchable” message + */ + private void fireReceivedPutFetchable(PutFetchable putFetchable) { + for (FcpListener fcpListener: fcpListeners) { + fcpListener.receivedPutFetchable(this, putFetchable); + } + } + + /** * Notifies all listeners that a “ProtocolError” message was received. * + * @see FcpListener#receivedProtocolError(FcpConnection, ProtocolError) * @param protocolError * The “ProtocolError” message */ @@ -573,6 +643,17 @@ public class FcpConnection { } } + /** + * Notifies all listeners that the connection to the node was closed. + * + * @see FcpListener#connectionClosed(FcpConnection) + */ + private void fireConnectionClosed() { + for (FcpListener fcpListener: fcpListeners) { + fcpListener.connectionClosed(this); + } + } + // // ACTIONS // @@ -659,6 +740,10 @@ public class FcpConnection { fireReceivedFinishedCompression(new FinishedCompression(fcpMessage)); } else if ("GetFailed".equals(messageName)) { fireReceivedGetFailed(new GetFailed(fcpMessage)); + } else if ("PutFetchable".equals(messageName)) { + fireReceivedPutFetchable(new PutFetchable(fcpMessage)); + } else if ("PutSuccessful".equals(messageName)) { + fireReceivedPutSuccessful(new PutSuccessful(fcpMessage)); } else if ("PutFailed".equals(messageName)) { fireReceivedPutFailed(new PutFailed(fcpMessage)); } else if ("DataFound".equals(messageName)) { @@ -683,6 +768,8 @@ public class FcpConnection { fireReceivedSSKKeypair(new SSKKeypair(fcpMessage)); } else if ("PeerRemoved".equals(messageName)) { fireReceivedPeerRemoved(new PeerRemoved(fcpMessage)); + } else if ("PersistentRequestModified".equals(messageName)) { + fireReceivedPersistentRequestModified(new PersistentRequestModified(fcpMessage)); } else if ("PersistentRequestRemoved".equals(messageName)) { fireReceivedPersistentRequestRemoved(new PersistentRequestRemoved(fcpMessage)); } else if ("UnknownPeerNoteType".equals(messageName)) { @@ -724,6 +811,7 @@ public class FcpConnection { Closer.close(remoteOutputStream); Closer.close(remoteSocket); connectionHandler = null; + fireConnectionClosed(); } //