public OutputStream group(final String name, final Object args, final Handler<OutputGroup> handler) {
final List<OutputGroup> groups = new ArrayList<>();
List<OutputConnection> connections = selector.select(name, this.connections);
final int connectionsSize = connections.size();
if (connectionsSize == 0) {
handler.handle(new BaseOutputGroup(name, vertx, groups));
} else {
for (OutputConnection connection : connections) {
connection.group(name, args, new Handler<OutputGroup>() {
@Override
public void handle(OutputGroup group) {
groups.add(group);
if (groups.size() == connectionsSize) {
handler.handle(new BaseOutputGroup(name, vertx, groups));
}
}
});
}
}