From 5cc5fd2f2cc010e77448ca044c7679739add966f Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Thu, 11 Apr 2013 22:48:34 +0200 Subject: [PATCH] Send event when a client parts a channel. --- .../java/net/pterodactylus/irc/Connection.java | 3 + .../net/pterodactylus/irc/event/ChannelLeft.java | 74 ++++++++++++++++++++++ 2 files changed, 77 insertions(+) create mode 100644 src/main/java/net/pterodactylus/irc/event/ChannelLeft.java diff --git a/src/main/java/net/pterodactylus/irc/Connection.java b/src/main/java/net/pterodactylus/irc/Connection.java index c7d5428..15c8ff5 100644 --- a/src/main/java/net/pterodactylus/irc/Connection.java +++ b/src/main/java/net/pterodactylus/irc/Connection.java @@ -39,6 +39,7 @@ import java.util.logging.Logger; import javax.net.SocketFactory; import net.pterodactylus.irc.event.ChannelJoined; +import net.pterodactylus.irc.event.ChannelLeft; import net.pterodactylus.irc.event.ChannelMessageReceived; import net.pterodactylus.irc.event.ChannelNicknames; import net.pterodactylus.irc.event.ChannelNotJoined; @@ -388,6 +389,8 @@ public class Connection extends AbstractExecutionThreadService implements Servic } else if (command.equals("366")) { eventBus.post(new ChannelNicknames(this, parameters.get(1), nicks)); nicks.clear(); + } else if (command.equalsIgnoreCase("PART")) { + eventBus.post(new ChannelLeft(this, parameters.get(0), reply.source().get(), parameters.get(1))); /* common channel join errors. */ } else if (command.equals("474")) { diff --git a/src/main/java/net/pterodactylus/irc/event/ChannelLeft.java b/src/main/java/net/pterodactylus/irc/event/ChannelLeft.java new file mode 100644 index 0000000..e9c52f3 --- /dev/null +++ b/src/main/java/net/pterodactylus/irc/event/ChannelLeft.java @@ -0,0 +1,74 @@ +/* + * XdccDownloader - ChannelLeft.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.Source; + +/** + * Event that notifies a listener that a client has left a channel. + * + * @author David ‘Bombe’ Roden + */ +public class ChannelLeft extends AbstractChannelEvent { + + /** The parting client. */ + private final Source client; + + /** The message given by the client. */ + private final String message; + + /** + * Creates a new channel joined event. + * + * @param connection + * The connection that joined the channel + * @param channel + * The channel being left + * @param message + * The message given by the client + */ + public ChannelLeft(Connection connection, String channel, Source client, String message) { + super(connection, channel); + this.client = client; + this.message = message; + } + + // + // ACCESSORS + // + + /** + * Returns the client that joined the channel. + * + * @return The client that joined the channel + */ + public Source client() { + return client; + } + + /** + * Returns the message given by the client. + * + * @return The message given by the client + */ + public String message() { + return message; + } + +} -- 2.7.4