2 * jFCPlib - FcpListener.java - Copyright © 2008–2016 David Roden
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 package net.pterodactylus.fcp;
20 import java.util.EventListener;
23 * Interface for objects that want to be notified on certain FCP events.
25 * @author David ‘Bombe’ Roden <bombe@freenetproject.org>
27 public interface FcpListener extends EventListener {
30 * Notifies a listener that a “NodeHello” message was received.
32 * @param fcpConnection
33 * The connection that received the message
35 * The “NodeHello” message
37 public void receivedNodeHello(FcpConnection fcpConnection, NodeHello nodeHello);
40 * Notifies a listener that a “CloseConnectionDuplicateClientName” message
43 * @param fcpConnection
44 * The connection that received the message
45 * @param closeConnectionDuplicateClientName
46 * The “CloseConnectionDuplicateClientName” message
48 public void receivedCloseConnectionDuplicateClientName(FcpConnection fcpConnection, CloseConnectionDuplicateClientName closeConnectionDuplicateClientName);
51 * Notifies a listener that a “SSKKeypair” message was received.
53 * @param fcpConnection
54 * The connection that received themessage
56 * The “SSKKeypair” message
58 public void receivedSSKKeypair(FcpConnection fcpConnection, SSKKeypair sskKeypair);
61 * Notifies a listener that a “Peer” message was received.
63 * @param fcpConnection
64 * The connection that received the message
68 public void receivedPeer(FcpConnection fcpConnection, Peer peer);
71 * Notifies a listener that an “EndListPeers” message was received.
73 * @param fcpConnection
74 * The connection that recevied the message
76 * The “EndListPeers” message
78 public void receivedEndListPeers(FcpConnection fcpConnection, EndListPeers endListPeers);
81 * Notifies a listener that a “PeerNote” message was received.
83 * @param fcpConnection
84 * The connection that received the message
86 * The “PeerNote” message
88 public void receivedPeerNote(FcpConnection fcpConnection, PeerNote peerNote);
91 * Notifies a listener that an “EndListPeerNotes” message was received.
93 * @param fcpConnection
94 * The connection that received the message
95 * @param endListPeerNotes
96 * The “EndListPeerNotes” message
98 public void receivedEndListPeerNotes(FcpConnection fcpConnection, EndListPeerNotes endListPeerNotes);
101 * Notifies a listener that a “PeerRemoved” message was received.
103 * @param fcpConnection
104 * The connection that received the message
106 * The “PeerRemoved” message
108 public void receivedPeerRemoved(FcpConnection fcpConnection, PeerRemoved peerRemoved);
111 * Notifies a listener that a “NodeData” message was received.
113 * @param fcpConnection
114 * The connection that received the message
116 * The “NodeData” message
118 public void receivedNodeData(FcpConnection fcpConnection, NodeData nodeData);
121 * Notifies a listener that a “TestDDAReply” message was received.
123 * @param fcpConnection
124 * The connection that received the message
125 * @param testDDAReply
126 * The “TestDDAReply” message
128 public void receivedTestDDAReply(FcpConnection fcpConnection, TestDDAReply testDDAReply);
131 * Notifies a listener that a “TestDDAComplete” was received.
133 * @param fcpConnection
134 * The connection that received the message
135 * @param testDDAComplete
136 * The “TestDDAComplete” message
138 public void receivedTestDDAComplete(FcpConnection fcpConnection, TestDDAComplete testDDAComplete);
141 * Notifies a listener that a “PersistentGet” was received.
143 * @param fcpConnection
144 * The connection that received the message
145 * @param persistentGet
146 * The “PersistentGet” message
148 public void receivedPersistentGet(FcpConnection fcpConnection, PersistentGet persistentGet);
151 * Notifies a listener that a “PersistentPut” was received.
153 * @param fcpConnection
154 * The connection that received the message
155 * @param persistentPut
156 * The “PersistentPut” message
158 public void receivedPersistentPut(FcpConnection fcpConnection, PersistentPut persistentPut);
161 * Notifies a listener that a “EndListPersistentRequests” was received.
163 * @param fcpConnection
164 * The connection that received the message
165 * @param endListPersistentRequests
166 * The “EndListPersistentRequests” message
168 public void receivedEndListPersistentRequests(FcpConnection fcpConnection, EndListPersistentRequests endListPersistentRequests);
171 * Notifies a listener that a “URIGenerated” was received.
173 * @param fcpConnection
174 * The connection that received the message
175 * @param uriGenerated
176 * The “URIGenerated” message
178 public void receivedURIGenerated(FcpConnection fcpConnection, URIGenerated uriGenerated);
181 * Notifies a listener that a “DataFound” was received.
183 * @param fcpConnection
184 * The connection that received the message
186 * The “DataFound” message
188 public void receivedDataFound(FcpConnection fcpConnection, DataFound dataFound);
191 * Notifies a listener that an “AllData” was received.
193 * @param fcpConnection
194 * The connection that received the message
196 * The “AllData” message
198 public void receivedAllData(FcpConnection fcpConnection, AllData allData);
201 * Notifies a listener that a “SimpleProgress” was received.
203 * @param fcpConnection
204 * The connection that received the message
205 * @param simpleProgress
206 * The “SimpleProgress” message
208 public void receivedSimpleProgress(FcpConnection fcpConnection, SimpleProgress simpleProgress);
211 * Notifies a listener that a “StartedCompression” was received.
213 * @param fcpConnection
214 * The connection that received the message
215 * @param startedCompression
216 * The “StartedCompression” message
218 public void receivedStartedCompression(FcpConnection fcpConnection, StartedCompression startedCompression);
221 * Notifies a listener that a “FinishedCompression” was received.
223 * @param fcpConnection
224 * The connection that received the message
225 * @param finishedCompression
226 * The “FinishedCompression” message
228 public void receivedFinishedCompression(FcpConnection fcpConnection, FinishedCompression finishedCompression);
231 * Notifies a listener that an “UnknownPeerNoteType” was received.
233 * @param fcpConnection
234 * The connection that received the message
235 * @param unknownPeerNoteType
236 * The “UnknownPeerNoteType” message
238 public void receivedUnknownPeerNoteType(FcpConnection fcpConnection, UnknownPeerNoteType unknownPeerNoteType);
241 * Notifies a listener that a “UnknownNodeIdentifier” message was received.
243 * @param fcpConnection
244 * The connection that received the message
245 * @param unknownNodeIdentifier
246 * The “UnknownNodeIdentifier” message
248 public void receivedUnknownNodeIdentifier(FcpConnection fcpConnection, UnknownNodeIdentifier unknownNodeIdentifier);
251 * Notifies a listener that a “ConfigData” message was received.
253 * @param fcpConnection
254 * The connection that received the message
256 * The “ConfigData” message
258 public void receivedConfigData(FcpConnection fcpConnection, ConfigData configData);
261 * Notifies a listener that a “GetFailed” message was recevied.
263 * @param fcpConnection
264 * The connection that received the message
266 * The “GetFailed” message
268 public void receivedGetFailed(FcpConnection fcpConnection, GetFailed getFailed);
271 * Notifies a listener that a “PutFailed” message was received.
273 * @param fcpConnection
274 * The connection that received the message
276 * The “PutFailed” message
278 public void receivedPutFailed(FcpConnection fcpConnection, PutFailed putFailed);
281 * Notifies a listener that an “IdentifierCollision” message was receied.
283 * @param fcpConnection
284 * The connection that received the message
285 * @param identifierCollision
286 * The “IdentifierCollision” message
288 public void receivedIdentifierCollision(FcpConnection fcpConnection, IdentifierCollision identifierCollision);
291 * Notifies a listener that a “PersistentPutDir” message was received.
293 * @param fcpConnection
294 * The connection that received the message
295 * @param persistentPutDir
296 * The “PersistentPutDir” message
298 public void receivedPersistentPutDir(FcpConnection fcpConnection, PersistentPutDir persistentPutDir);
301 * Notifies a listener that a “PersistentRequestRemoved” message was
304 * @param fcpConnection
305 * The connection that received the message
306 * @param persistentRequestRemoved
307 * The “PersistentRequestRemoved” message
309 public void receivedPersistentRequestRemoved(FcpConnection fcpConnection, PersistentRequestRemoved persistentRequestRemoved);
311 void receivedSubscribedUSK(FcpConnection fcpConnection, SubscribedUSK subscribedUSK);
314 * Notifies a listener that a “SubscribedUSKUpdate” message was received.
316 * @param fcpConnection
317 * The connection that recevied the message
318 * @param subscribedUSKUpdate
319 * The “SubscribedUSKUpdate” message
321 public void receivedSubscribedUSKUpdate(FcpConnection fcpConnection, SubscribedUSKUpdate subscribedUSKUpdate);
324 * Notifies a listener that a “PluginInfo” message was received.
326 * @param fcpConnection
327 * The connection that received the message
329 * The “PluginInfo” message
331 public void receivedPluginInfo(FcpConnection fcpConnection, PluginInfo pluginInfo);
333 void receivedPluginRemoved(FcpConnection fcpConnection, PluginRemoved pluginRemoved);
336 * Notifies a listener that an “FCPPluginReply“ message was received.
338 * @param fcpConnection
339 * The connection that received the message
340 * @param fcpPluginReply
341 * The “FCPPluginReply” message
343 public void receivedFCPPluginReply(FcpConnection fcpConnection, FCPPluginReply fcpPluginReply);
346 * Notifies a listener that a “PersistentRequestModified” message was
349 * @param fcpConnection
350 * The connection that received the message
351 * @param persistentRequestModified
352 * The “PersistentRequestModified” message
354 public void receivedPersistentRequestModified(FcpConnection fcpConnection, PersistentRequestModified persistentRequestModified);
357 * Notifies a listener that a “PutSuccessful” message was received.
359 * @param fcpConnection
360 * The connection that received the message
361 * @param putSuccessful
362 * The “PutSuccessful” message
364 public void receivedPutSuccessful(FcpConnection fcpConnection, PutSuccessful putSuccessful);
367 * Notifies a listener that a “PutFetchable” message was received.
369 * @param fcpConnection
370 * The connection that received the message
371 * @param putFetchable
372 * The “PutFetchable” message
374 public void receivedPutFetchable(FcpConnection fcpConnection, PutFetchable putFetchable);
377 * Notifies a listener that a feed was sent to a peer.
380 * The connection that received the message
382 * The “SentFeed” message
384 public void receivedSentFeed(FcpConnection source, SentFeed sentFeed);
387 * Notifies a listener that a bookmark was updated.
389 * @param fcpConnection
390 * The connection that received the message
391 * @param receivedBookmarkFeed
392 * The “ReceivedBookmarkFeed” message
394 public void receivedBookmarkFeed(FcpConnection fcpConnection, ReceivedBookmarkFeed receivedBookmarkFeed);
397 * Notifies a listener that a “ProtocolError” was received.
399 * @param fcpConnection
400 * The connection that received the message
401 * @param protocolError
402 * The “ProtocolError” message
404 public void receivedProtocolError(FcpConnection fcpConnection, ProtocolError protocolError);
407 * Notifies a listener that a message has been received. This method is
408 * only called if {@link FcpConnection#handleMessage(FcpMessage)} does not
409 * recognize the message. Should that ever happen, please file a bug
412 * @param fcpConnection
413 * The connection that received the message
415 * The message that was received
417 public void receivedMessage(FcpConnection fcpConnection, FcpMessage fcpMessage);
420 * Notifies a listener that a connection was closed. A closed connection
421 * can be reestablished by calling {@link FcpConnection#connect()} on the
424 * @param fcpConnection
425 * The connection that was closed.
427 * The exception that caused the disconnect, or
428 * <code>null</code> if there was no exception
430 public void connectionClosed(FcpConnection fcpConnection, Throwable throwable);