Send message when a connection fails.
[xudocci.git] / src / main / java / net / pterodactylus / xdcc / core / Core.java
index 7355283..ded98cf 100644 (file)
@@ -384,6 +384,9 @@ public class Core extends AbstractExecutionThreadService {
                                        /* ignore. */
                                }
                        }
+                       if (!isRunning()) {
+                               break;
+                       }
 
                        /* find channels that should be monitored but are not. */
                        for (Channel channel : channels) {
@@ -411,7 +414,7 @@ public class Core extends AbstractExecutionThreadService {
        }
 
        @Override
-       protected void shutDown() {
+       protected void triggerShutdown() {
                synchronized (syncObject) {
                        syncObject.notifyAll();
                }
@@ -533,6 +536,7 @@ public class Core extends AbstractExecutionThreadService {
        @Subscribe
        public void connectionClosed(ConnectionClosed connectionClosed) {
                removeConnection(connectionClosed.connection());
+               eventBus.post(new GenericMessage(String.format("Connection closed by %s.", connectionClosed.connection().hostname())));
        }
 
        /**
@@ -544,6 +548,7 @@ public class Core extends AbstractExecutionThreadService {
        @Subscribe
        public void connectionFailed(ConnectionFailed connectionFailed) {
                removeConnection(connectionFailed.connection());
+               eventBus.post(new GenericMessage(String.format("Could not connect to %s: %s.", connectionFailed.connection().hostname(), connectionFailed.cause())));
        }
 
        /**
@@ -674,9 +679,9 @@ public class Core extends AbstractExecutionThreadService {
                                        return;
                                }
 
-                               extraChannels.remove(channel);
+                               extraChannels.remove(channel.get());
                        } else {
-                               channels.remove(channel.get());
+                               joinedChannels.remove(channel.get());
                        }
                        eventBus.post(new GenericMessage(format(
                                        "Kicked from %s by %s: %s",