X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Firc%2FConnection.java;h=a50c9463c4ad3acb69c42213cd6e2cea7cf0ee4b;hb=8bff1793a5004091ac9b4ef6bd1fd33b5086432a;hp=69aa64880cba58142945d25b3ce6499c49fea706;hpb=74da24c29fa7403eed48acb97bc2ffa72f22bc8c;p=xudocci.git diff --git a/src/main/java/net/pterodactylus/irc/Connection.java b/src/main/java/net/pterodactylus/irc/Connection.java index 69aa648..a50c946 100644 --- a/src/main/java/net/pterodactylus/irc/Connection.java +++ b/src/main/java/net/pterodactylus/irc/Connection.java @@ -32,7 +32,6 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Set; -import java.util.concurrent.SynchronousQueue; import java.util.logging.Level; import java.util.logging.Logger; import javax.net.SocketFactory; @@ -56,7 +55,6 @@ import com.beust.jcommander.internal.Maps; import com.beust.jcommander.internal.Sets; import com.google.common.base.Optional; import com.google.common.eventbus.EventBus; -import com.google.common.eventbus.Subscribe; import com.google.common.io.Closeables; import com.google.common.util.concurrent.AbstractExecutionThreadService; import com.google.common.util.concurrent.Service; @@ -203,42 +201,11 @@ public class Connection extends AbstractExecutionThreadService implements Servic * @param channel * The channel to join * @return {@code true} if the channel was joined, {@code false} otherwise + * @throws IOException + * if an I/O error occurs */ - public boolean joinChannel(final String channel) { - final SynchronousQueue result = new SynchronousQueue(); - Object eventHandler = new Object() { - - @Subscribe - public void channelJoined(ChannelJoined channelJoined) throws InterruptedException { - if (!channelJoined.channel().equalsIgnoreCase(channel)) { - return; - } - Optional nickname = channelJoined.client().nick(); - if (!nickname.isPresent() || (nickname.isPresent() && nickname().equalsIgnoreCase(nickname.get()))) { - eventBus.unregister(this); - result.put(true); - } - } - - @Subscribe - public void channelNotJoined(ChannelNotJoined channelNotJoined) throws InterruptedException { - if (!channelNotJoined.channel().equalsIgnoreCase(channel)) { - return; - } - eventBus.unregister(this); - result.put(false); - } - }; - eventBus.register(eventHandler); - try { - connectionHandler.sendCommand("JOIN", channel); - return result.take(); - } catch (IOException ioe1) { - eventBus.unregister(eventHandler); - } catch (InterruptedException ie1) { - /* TODO - how to handle? */ - } - return false; + public void joinChannel(final String channel) throws IOException { + connectionHandler.sendCommand("JOIN", channel); } //