websockets for web

This commit is contained in:
zoe 2022-09-03 23:32:08 +02:00
parent 3549d61045
commit 4f249fd34a
2 changed files with 8 additions and 3 deletions

View File

@ -1,10 +1,11 @@
import 'dart:async';
import 'package:flutter/foundation.dart';
import 'package:loris/business_logic/settings.dart';
import 'package:web_socket_channel/io.dart';
import 'package:web_socket_channel/html.dart';
import '../global.dart' as global;
IOWebSocketChannel? channel;
bool connected = false;
Map<String, Map<String, StreamController>> map = {};
@ -57,7 +58,9 @@ StreamController getStreamController(AccountSettings id, StreamType type) {
final uri =
Uri(scheme: scheme, host: host, path: path, queryParameters: query);
final controller = StreamController.broadcast();
final socket = IOWebSocketChannel.connect(uri);
final socket = kIsWeb
? HtmlWebSocketChannel.connect(uri)
: IOWebSocketChannel.connect(uri);
controller.addStream(socket.stream);
return controller;
}

View File

@ -53,6 +53,8 @@
"content-warning": "content warning",
"theme-title": "theme",
"send-post": "computer, send post",
"jacking-in": "jacking in..."
"jacking-in": "jacking in...",
"jack-in": "jack in",
"add-account": "add account"
}