Send event for every received reply.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 2 May 2013 19:10:36 +0000 (21:10 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 2 May 2013 19:10:36 +0000 (21:10 +0200)
src/main/java/net/pterodactylus/irc/Connection.java
src/main/java/net/pterodactylus/irc/event/ReplyReceived.java [new file with mode: 0644]

index b1ca64a..ec063f6 100644 (file)
@@ -59,6 +59,7 @@ import net.pterodactylus.irc.event.NicknameInUseReceived;
 import net.pterodactylus.irc.event.NoNicknameGivenReceived;
 import net.pterodactylus.irc.event.PrivateMessageReceived;
 import net.pterodactylus.irc.event.PrivateNoticeReceived;
+import net.pterodactylus.irc.event.ReplyReceived;
 import net.pterodactylus.irc.event.UnknownReplyReceived;
 import net.pterodactylus.irc.util.RandomNickname;
 import net.pterodactylus.xdcc.util.io.BandwidthCountingInputStream;
@@ -373,6 +374,7 @@ public class Connection extends AbstractExecutionThreadService implements Servic
 
                        while (connected) {
                                Reply reply = connectionHandler.readReply();
+                               eventBus.post(new ReplyReceived(this, reply));
                                logger.finest(String.format("<< %s", reply));
                                String command = reply.command();
                                List<String> parameters = reply.parameters();
diff --git a/src/main/java/net/pterodactylus/irc/event/ReplyReceived.java b/src/main/java/net/pterodactylus/irc/event/ReplyReceived.java
new file mode 100644 (file)
index 0000000..f624fc4
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * XdccDownloader - ReplyReceived.java - Copyright © 2013 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
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package net.pterodactylus.irc.event;
+
+import net.pterodactylus.irc.Connection;
+import net.pterodactylus.irc.Reply;
+
+/**
+ * Notifies a listener that a reply was received. This event is sent for
+ * <em>every</em> reply received by a {@link Connection}.
+ *
+ * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
+ */
+public class ReplyReceived extends AbstractReplyEvent {
+
+       /**
+        * Creates a new reply received event.
+        *
+        * @param connection
+        *              The connection that received the event
+        * @param reply
+        *              The reply that triggered the event
+        */
+       public ReplyReceived(Connection connection, Reply reply) {
+               super(connection, reply);
+       }
+
+}