//
/**
+ * Returns all currently known connections.
+ *
+ * @return All currently known connections
+ */
+ public Collection<Connection> connections() {
+ return networkConnections.values();
+ }
+
+ /**
* Returns all configured channels. Due to various circumstances, configured
* channels might not actually be joined.
*
import java.util.List;
import java.util.Set;
+import net.pterodactylus.irc.Connection;
import net.pterodactylus.irc.DccReceiver;
import net.pterodactylus.irc.util.MessageCleaner;
import net.pterodactylus.xdcc.core.Core;
String lastLine = "";
String line;
final List<Result> lastResult = Lists.newArrayList();
+ final List<Connection> lastConnections = Lists.newArrayList();
while ((line = reader.readLine()) != null) {
if (line.equals("")) {
line = lastLine;
}
writeLine(String.format("%d channels (%d joined, %d extra), %d bots offering %d packs (%d unique).", configuredChannelsCount, joinedChannelsCount, extraChannelsCount, bots.size(), packsCount, packNames.size()));
+ } 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")) {
+ Integer index = Ints.tryParse(words[1]);
+ if ((index != null) && (index < lastConnections.size())) {
+ core.closeConnection(lastConnections.get(index));
+ }
}
lastLine = line;