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;
import net.pterodactylus.irc.event.ChannelNotJoined.Reason;
import net.pterodactylus.irc.event.ChannelTopic;
+import net.pterodactylus.irc.event.ClientQuit;
import net.pterodactylus.irc.event.ConnectionEstablished;
import net.pterodactylus.irc.event.ConnectionFailed;
import net.pterodactylus.irc.event.DccSendReceived;
//
/**
+ * Checks whether the given source is the client represented by this
+ * connection.
+ *
+ * @param source
+ * The source to check
+ * @return {@code true} if this connection represents the given source, {@code
+ * false} otherwise
+ */
+ public boolean isSource(Source source) {
+ return source.nick().isPresent() && source.nick().get().equals(nickname);
+ }
+
+ /**
* Joins the given channel.
*
* @param channel
} 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)));
+ } else if (command.equalsIgnoreCase("QUIT")) {
+ eventBus.post(new ClientQuit(this, reply.source().get(), parameters.get(0)));
/* common channel join errors. */
} else if (command.equals("474")) {