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;
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;
/**
*
* @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
*/
-public class Core extends AbstractIdleService {
+public class Core extends AbstractExecutionThreadService {
/** The logger. */
private static final Logger logger = Logger.getLogger(Core.class.getName());
}
@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() {
}