X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fxdcc%2Fcore%2FCore.java;h=1f15af0da8ef3ee285fba998bc1f3068c764d769;hb=ff99325d519095f49576105b7cd4b330b3bc8902;hp=a395537607d4e490d6bbc080832603629e9b05dd;hpb=f6942b34cf66267bc67d673cf7852f420ab06dfd;p=xudocci.git diff --git a/src/main/java/net/pterodactylus/xdcc/core/Core.java b/src/main/java/net/pterodactylus/xdcc/core/Core.java index a395537..1f15af0 100644 --- a/src/main/java/net/pterodactylus/xdcc/core/Core.java +++ b/src/main/java/net/pterodactylus/xdcc/core/Core.java @@ -27,6 +27,7 @@ import java.util.Collections; import java.util.List; import java.util.Map; import java.util.Map.Entry; +import java.util.concurrent.TimeUnit; import java.util.logging.Level; import java.util.logging.Logger; @@ -71,7 +72,7 @@ import com.google.common.collect.Table; import com.google.common.eventbus.EventBus; import com.google.common.eventbus.Subscribe; import com.google.common.io.Closeables; -import com.google.common.util.concurrent.AbstractIdleService; +import com.google.common.util.concurrent.AbstractExecutionThreadService; import com.google.inject.Inject; /** @@ -79,7 +80,7 @@ import com.google.inject.Inject; * * @author David ‘Bombe’ Roden */ -public class Core extends AbstractIdleService { +public class Core extends AbstractExecutionThreadService { /** The logger. */ private static final Logger logger = Logger.getLogger(Core.class.getName()); @@ -235,6 +236,31 @@ public class Core extends AbstractIdleService { } @Override + protected void run() throws Exception { + while (isRunning()) { + try { + Thread.sleep(TimeUnit.MINUTES.toMillis(1)); + } catch (InterruptedException ie1) { + /* ignore. */ + } + + /* find channels that should be monitored but are not. */ + for (Channel channel : channels) { + if (joinedChannels.contains(channel)) { + continue; + } + + connectNetwork(channel.network()); + Connection connection = networkConnections.get(channel.network()); + if (connection.established()) { + eventBus.post(new GenericMessage(String.format("Trying to join %s on %s.", channel.name(), channel.network().name()))); + connection.joinChannel(channel.name()); + } + } + } + } + + @Override protected void shutDown() { }