listAllPeers method

Future<List> listAllPeers()

@deprecated

Implementation

Future<List<dynamic>> listAllPeers() async {
  try {
    final response = await _buildRequest('peers');

    if (response.statusCode != 200) {
      if (response.statusCode == 401) {
        String helpfulError = '';

        if (_options.host == util.CLOUD_HOST) {
          helpfulError = "It looks like you're using the cloud server. You can email " +
              "team@peerjs.com to enable peer listing for your API key.";
        } else {
          helpfulError =
              "You need to enable `allow_discovery` on your self-hosted " + "PeerServer to use this feature.";
        }

        throw Exception("It doesn't look like you have permission to list peers IDs. " + helpfulError);
      }

      throw Exception('Error. Status:${response.statusCode}');
    }

    return List<dynamic>.from(response.body as List<dynamic>);
  } catch (error) {
    logger.error('Error retrieving list p $error');

    throw Exception('Could not get list peers from the server. $error');
  }
}