From b310622663c0ec06565ac3996660c90dd40bb771 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Thu, 2 May 2013 21:10:36 +0200 Subject: [PATCH] Send event for every received reply. --- .../java/net/pterodactylus/irc/Connection.java | 2 + .../net/pterodactylus/irc/event/ReplyReceived.java | 43 ++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 src/main/java/net/pterodactylus/irc/event/ReplyReceived.java diff --git a/src/main/java/net/pterodactylus/irc/Connection.java b/src/main/java/net/pterodactylus/irc/Connection.java index b1ca64a..ec063f6 100644 --- a/src/main/java/net/pterodactylus/irc/Connection.java +++ b/src/main/java/net/pterodactylus/irc/Connection.java @@ -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 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 index 0000000..f624fc4 --- /dev/null +++ b/src/main/java/net/pterodactylus/irc/event/ReplyReceived.java @@ -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 . + */ + +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 + * every reply received by a {@link Connection}. + * + * @author David ‘Bombe’ Roden + */ +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); + } + +} -- 2.7.4