Add possibility to disconnect all connections at once.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 2 May 2013 19:12:36 +0000 (21:12 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 2 May 2013 19:12:36 +0000 (21:12 +0200)
src/main/java/net/pterodactylus/xdcc/ui/stdin/CommandReader.java

index 2ef14d7..eaaef23 100644 (file)
@@ -169,9 +169,15 @@ public class CommandReader extends AbstractExecutionThreadService {
                                }
                                writeLine("End of connections.");
                        } else if (words[0].equalsIgnoreCase("disconnect")) {
-                               Integer index = Ints.tryParse(words[1]);
-                               if ((index != null) && (index < lastConnections.size())) {
-                                       core.closeConnection(lastConnections.get(index));
+                               if ((words.length == 1) || ("all".equals(words[1]))) {
+                                       for (Connection connection : lastConnections) {
+                                               core.closeConnection(connection);
+                                       }
+                               } else {
+                                       Integer index = Ints.tryParse(words[1]);
+                                       if ((index != null) && (index < lastConnections.size())) {
+                                               core.closeConnection(lastConnections.get(index));
+                                       }
                                }
                        }