pull/1/head
戴余标 3 years ago
commit 8803402213

@ -200,7 +200,7 @@ class _OldAgeSupportListPageState extends State<OldAgeSupportListPage> {
.color(
select ? Colors.white : Colors.black.withOpacity(0.65))
.make(),
],
],
),
Spacer(),
Container(

@ -2,7 +2,7 @@ import 'dart:async';
import 'package:flutter/material.dart';
class ClockTimerProvider extends ChangeNotifier{
class ClockTimerProvider extends ChangeNotifier {
///
int second = 60;
bool timerStart = false;
@ -10,6 +10,9 @@ class ClockTimerProvider extends ChangeNotifier{
void startTimer() {
timerStart = true;
if (timer != null) {
return;
}
timer = Timer.periodic(Duration(seconds: 1), (timer) {
if (second > 0) {
second--;
@ -27,4 +30,4 @@ class ClockTimerProvider extends ChangeNotifier{
timer = null;
notifyListeners();
}
}
}

@ -30,9 +30,6 @@ class UserProvider extends ChangeNotifier {
Future init() async {
if (isLogin) {
await updateUserInfo();
WebSocketUtil().setUser(userInfoModel!.id.toString());
WebSocketUtil().setCommunityCode(userInfoModel!.communityCode);
WebSocketUtil().setNickName(userInfoModel!.nickName!);
WebSocketUtil().startWebSocket();
await updateMyHouseInfo();

@ -7,9 +7,6 @@ import 'package:web_socket_channel/web_socket_channel.dart';
import 'package:aku_new_community/widget/others/user_tool.dart';
// const String baseUri = 'wss://shop.kaidalai.cn/websocket/app';
const String baseUri = 'wss://saas.kaidalai.cn/websocket/app';
enum SOCKETSTATUS {
CONNECTED, //
BREAKOFF, //
@ -28,9 +25,10 @@ class WebSocketUtil {
IOWebSocketChannel? _webSocket;
///
String _user = 'admin';
String _communityCode = 'communityCode';
String _nickName = 'nickName';
static const String baseUri = 'wss://saas.kaidalai.cn/websocket/app';
String get urlAddress =>
'$baseUri/${UserTool.userProvider.userInfoModel?.communityCode}/${UserTool.userProvider.userInfoModel?.nickName}';
///
SOCKETSTATUS _socketStatus = SOCKETSTATUS.CLOSED;
@ -86,32 +84,19 @@ class WebSocketUtil {
print('——————————webSocket init ——————————');
}
///
void setUser(String user) {
this._user = user;
}
void setCommunityCode(String communityCode) {
this._communityCode = communityCode;
}
void setNickName(String nickName) {
this._nickName = nickName;
}
///websocket
void startWebSocket() {
closeWebSocket();
try {
_webSocket = IOWebSocketChannel.connect(
Uri.parse('$baseUri/$_communityCode/$_nickName'));
print('webSocket已连接服务器$baseUri/$_user');
_webSocket = IOWebSocketChannel.connect(Uri.parse(urlAddress));
print('webSocket已连接服务器$urlAddress');
_socketStatus = SOCKETSTATUS.CONNECTED;
endReconnect();
onStart?.call();
_webSocket!.stream.listen(
(event) => webSocketReceiveMessage(event as String),
onError: webSocketOnError,);
(event) => webSocketReceiveMessage(event as String),
onError: webSocketOnError,
);
initHeartBeat();
} catch (e) {
BotToast.showText(text: 'webSocket连接失败');

Loading…
Cancel
Save