mirror of
https://github.com/amigan/calls.git
synced 2024-11-21 04:19:47 -05:00
Controller
This commit is contained in:
parent
e64948bef5
commit
8e99afeb31
1 changed files with 24 additions and 0 deletions
24
lib/controller/ws.dart
Normal file
24
lib/controller/ws.dart
Normal file
|
@ -0,0 +1,24 @@
|
|||
import 'package:web_socket_channel/web_socket_channel.dart';
|
||||
|
||||
class LiveFeeder {
|
||||
late WebSocketChannel channel;
|
||||
|
||||
LiveFeeder();
|
||||
|
||||
void init() {
|
||||
String socketUrl = 'ws://xenon:3050/ws';
|
||||
Uri baseUri = Uri.base;
|
||||
if (baseUri.scheme == 'http' || baseUri.scheme == 'https') {
|
||||
String port = (baseUri.hasPort ? ':' + baseUri.port.toString() : '');
|
||||
socketUrl = 'ws://${baseUri.host}$port/ws';
|
||||
}
|
||||
final wsUri = Uri.parse(socketUrl);
|
||||
|
||||
channel = WebSocketChannel.connect(wsUri);
|
||||
channel.stream.listen((event) => _handleData(event));
|
||||
}
|
||||
|
||||
void _handleData(dynamic event) {
|
||||
print(event);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue