connectivity handling, audio publishing

This commit is contained in:
David Zhao
2021-08-04 10:59:41 -07:00
parent aec2003140
commit 593890331e
14 changed files with 208 additions and 33 deletions
+18
View File
@@ -0,0 +1,18 @@
import 'dart:async';
// ignore: avoid_web_libraries_in_flutter
import 'dart:html';
import 'package:web_socket_channel/html.dart';
import 'package:web_socket_channel/web_socket_channel.dart';
Future<WebSocketChannel> connectToWebSocket(Uri uri) {
var ws = WebSocket(uri.toString());
var completer = Completer<WebSocketChannel>();
ws.onOpen.first.then((_) {
completer.complete(HtmlWebSocketChannel(ws));
});
ws.onError.first.then((e) {
completer.completeError('could not connect');
});
return completer.future;
}