# performDiscoSweep method

Future <Result<DiscoError, List <DiscoInfo>>> performDiscoSweep()

## Implementation

    Future<Result<DiscoError, List<DiscoInfo>>> performDiscoSweep() async {
      final attrs = getAttributes();
      final serverJid = attrs.getConnectionSettings().jid.toDomain();
      final infoResults = List<DiscoInfo>.empty(growable: true);
      final result = await discoInfoQuery(serverJid);
      if (result.isType<DiscoInfo>()) {
        final info = result.get<DiscoInfo>();
        logger.finest('Discovered supported server features: ${info.features}');
        infoResults.add(info);

        attrs.sendEvent(ServerItemDiscoEvent(info));
        attrs.sendEvent(ServerDiscoDoneEvent());
      } else {
        logger.warning('Failed to discover server features');
        return Result(UnknownDiscoError());
      }

      final response = await discoItemsQuery(serverJid);
      if (response.isType<List<DiscoItem>>()) {
        logger.finest('Discovered disco items form $serverJid');

        // Query all items
        final items = response.get<List<DiscoItem>>();
        for (final item in items) {
          logger.finest('Querying info for ${item.jid}...');
          final itemInfoResult = await discoInfoQuery(item.jid);
          if (itemInfoResult.isType<DiscoInfo>()) {
            final itemInfo = itemInfoResult.get<DiscoInfo>();
            logger.finest('Received info for ${item.jid}');
            infoResults.add(itemInfo);
            attrs.sendEvent(ServerItemDiscoEvent(itemInfo));
          } else {
            logger.warning('Failed to discover info for ${item.jid}');
          }
        }
      } else {
        logger.warning('Failed to discover items of $serverJid');
      }

      return Result(infoResults);
    }