getRTCIceServers method

dynamic getRTCIceServers(
  1. {String? location}

Get Ice servers from a Millicast signaling server.

Returns a Future object which represents a List of ice servers.


getRTCIceServers({String? location}) async {
  location = location ?? turnServerLocation;
  _logger.i('Getting RTC ICE servers');
  _logger.d('RTC ICE servers request location: $location');
  List<dynamic> iceServer = [];

  try {
    http.Response data = await http.put(Uri.parse(location));
    _logger.d('RTC ICE servers response: $data');
    if (jsonDecode(data.body)['s'] == 'ok') {
      // call returns old format,
      // this updates URL to URLS in credentials path.
      for (Map credentials in jsonDecode(data.body)['v']['iceServers']) {
        var url = credentials['url'];
        if (url.toString().isNotEmpty) {
          credentials['urls'] = url;

      _logger.i('RTC ICE servers successfully obtained.');
  } catch (e) {
    _logger.e('Error while getting RTC ICE servers: $e');
  return iceServer;