+ } else if (words[0].equalsIgnoreCase("connections")) {
+ lastConnections.clear();
+ int counter = 0;
+ for (Connection connection : core.connections()) {
+ lastConnections.add(connection);
+ writer.write(String.format("[%d] %s:%d, %s/s\n", counter++, connection.hostname(), connection.port(), f(connection.getInputRate())));
+ }
+ writeLine("End of connections.");
+ } else if (words[0].equalsIgnoreCase("disconnect")) {
+ 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));
+ }
+ }