aboutsummaryrefslogtreecommitdiffstats
path: root/lib/vehicle-signals/viss_config.dart
diff options
context:
space:
mode:
Diffstat (limited to 'lib/vehicle-signals/viss_config.dart')
-rw-r--r--lib/vehicle-signals/viss_config.dart29
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/vehicle-signals/viss_config.dart b/lib/vehicle-signals/viss_config.dart
new file mode 100644
index 0000000..c2be5ee
--- /dev/null
+++ b/lib/vehicle-signals/viss_config.dart
@@ -0,0 +1,29 @@
+// SPDX-License-Identifier: Apache-2.0
+//import 'dart:convert';
+import 'dart:io';
+
+import 'package:flutter_homescreen/config.dart';
+import 'package:flutter_riverpod/flutter_riverpod.dart';
+//import 'package:http/http.dart' as http;
+
+final sockConnectprovider = FutureProvider.family<WebSocket, HttpClient>(
+ (ref, client) => connect(client, ref));
+
+Future<HttpClient> initializeClient() async {
+ SecurityContext ctx = SecurityContext.defaultContext;
+
+ HttpClient client = HttpClient(context: ctx)
+ ..findProxy = null
+ ..badCertificateCallback = (cert, host, port) {
+ return true;
+ };
+ return client;
+}
+
+Future<WebSocket> connect(HttpClient client, ref) async {
+ final config = ref.read(ConfigStateprovider);
+ WebSocket socket = await WebSocket.connect(
+ "wss://${config.hostname}:${config.port}",
+ customClient: client);
+ return socket;
+}