You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
diplomatic-quarter/lib/pages/videocall-webrtc-rnd/utils/turn.dart

20 lines
747 B
Dart

import 'dart:convert';
import 'dart:async';
import 'dart:io';
Future<Map> getTurnCredential(String host) async {
HttpClient client = HttpClient(context: SecurityContext());
client.badCertificateCallback =
(X509Certificate cert, String host, int port) {
print('getTurnCredential: Allow self-signed certificate => $host:$port. ');
return true;
};
var url = '$host/api/turn?service=turn&username=flutter-webrtc';
var request = await client.getUrl(Uri.parse(url));
var response = await request.close();
var responseBody = await response.transform(Utf8Decoder()).join();
print('getTurnCredential:response => $responseBody.');
Map data = JsonDecoder().convert(responseBody);
return data;
}