TxIceServer.fromJson constructor
Creates a TxIceServer from a JSON map.
The map should contain:
urlsorurl: String or Listusername: Optional String for authenticationcredential: Optional String for authentication
Implementation
factory TxIceServer.fromJson(Map<String, dynamic> json) {
final urlsValue = json['urls'] ?? json['url'];
List<String> urls;
if (urlsValue is String) {
urls = [urlsValue];
} else if (urlsValue is List) {
urls = urlsValue.cast<String>();
} else {
GlobalLogger().w(
'TxIceServer :: Invalid urls value type in ICE server config: ${urlsValue?.runtimeType}. Expected String or List<String>.',
);
urls = [];
}
return TxIceServer(
urls: urls,
username: json['username'] as String?,
credential: json['credential'] as String?,
);
}