⚡ Optimized websocket
This commit is contained in:
parent
b808c76ea3
commit
cc59814b55
@ -13,7 +13,7 @@ import 'package:solian/models/pagination.dart';
|
|||||||
import 'package:solian/platform.dart';
|
import 'package:solian/platform.dart';
|
||||||
import 'package:solian/providers/auth.dart';
|
import 'package:solian/providers/auth.dart';
|
||||||
import 'package:solian/services.dart';
|
import 'package:solian/services.dart';
|
||||||
import 'package:web_socket_channel/io.dart';
|
import 'package:web_socket_channel/web_socket_channel.dart';
|
||||||
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
|
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
|
||||||
|
|
||||||
class AccountProvider extends GetxController {
|
class AccountProvider extends GetxController {
|
||||||
@ -27,7 +27,7 @@ class AccountProvider extends GetxController {
|
|||||||
RxList<Notification> notifications =
|
RxList<Notification> notifications =
|
||||||
List<Notification>.empty(growable: true).obs;
|
List<Notification>.empty(growable: true).obs;
|
||||||
|
|
||||||
IOWebSocketChannel? websocket;
|
WebSocketChannel? websocket;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
onInit() {
|
onInit() {
|
||||||
@ -66,7 +66,7 @@ class AccountProvider extends GetxController {
|
|||||||
isConnecting.value = true;
|
isConnecting.value = true;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
websocket = IOWebSocketChannel.connect(uri);
|
websocket = WebSocketChannel.connect(uri);
|
||||||
await websocket?.ready;
|
await websocket?.ready;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (!noRetry) {
|
if (!noRetry) {
|
||||||
|
@ -6,13 +6,13 @@ import 'package:get/get.dart';
|
|||||||
import 'package:solian/models/packet.dart';
|
import 'package:solian/models/packet.dart';
|
||||||
import 'package:solian/providers/auth.dart';
|
import 'package:solian/providers/auth.dart';
|
||||||
import 'package:solian/services.dart';
|
import 'package:solian/services.dart';
|
||||||
import 'package:web_socket_channel/io.dart';
|
import 'package:web_socket_channel/web_socket_channel.dart';
|
||||||
|
|
||||||
class ChatProvider extends GetxController {
|
class ChatProvider extends GetxController {
|
||||||
RxBool isConnected = false.obs;
|
RxBool isConnected = false.obs;
|
||||||
RxBool isConnecting = false.obs;
|
RxBool isConnecting = false.obs;
|
||||||
|
|
||||||
IOWebSocketChannel? websocket;
|
WebSocketChannel? websocket;
|
||||||
|
|
||||||
StreamController<NetworkPackage> stream = StreamController.broadcast();
|
StreamController<NetworkPackage> stream = StreamController.broadcast();
|
||||||
|
|
||||||
@ -36,7 +36,7 @@ class ChatProvider extends GetxController {
|
|||||||
isConnecting.value = true;
|
isConnecting.value = true;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
websocket = IOWebSocketChannel.connect(uri);
|
websocket = WebSocketChannel.connect(uri);
|
||||||
await websocket?.ready;
|
await websocket?.ready;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (!noRetry) {
|
if (!noRetry) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user