Erweiterungen

This commit is contained in:
Sven committed 2024-02-03 11:25:46 +01:00
1 parent 70fb6dd5ef
commit 70a8c04516
3 files changed
+46 -17

No files matched your search

+13
View File
@@ -30,9 +30,16 @@ import '../model/status.dart';
import 'constants.dart';
import 'util.dart';
enum ConnectionStateEnum {
not_connected,
connected
}
class MqttCore {
static late MqttCore instance;
late ConnectionStateEnum connectionState = ConnectionStateEnum.not_connected;
late String _brokerUri;
late int _brokerPort;
late String _fromServerTopic;
@@ -191,6 +198,8 @@ class MqttCore {
}
void _sessionMessageReceived(payloadData) async {
connectionState = ConnectionStateEnum.connected;
await _sendSyncMessage();
var statusMessage = Status.fromJson(payloadData['status']);
@@ -265,6 +274,8 @@ class MqttCore {
}
void _startReconnectTimer() {
connectionState = ConnectionStateEnum.not_connected;
Util.logInfo("_startReconnectTimer called");
_reconnectDelay = min(_reconnectDelay + 1, 30);
@@ -275,6 +286,8 @@ class MqttCore {
}
void _clientDisconnected() {
connectionState = ConnectionStateEnum.not_connected;
Util.logInfo("_clientDisconnected called");
BroadcastReceiver().publish<ConnectionStatus>(Constants.messageTopicConnectionStatusChanged, arguments: ConnectionStatus(status: ConnectionStatusEnum.notConnected));