[#43] Handling bad configuration. Advanced connection error handling

This commit is contained in:
estevez
2018-09-20 23:21:03 +03:00
parent e5fbc40c66
commit eceece5a90
3 changed files with 95 additions and 40 deletions

View File

@ -6,6 +6,12 @@ class StateChangedEvent {
StateChangedEvent(this.entityId);
}
class SettingsChangedEvent {
bool reconnect;
SettingsChangedEvent(this.reconnect);
}
class HassioDataModel {
String _hassioAPIEndpoint;
String _hassioPassword;
@ -56,7 +62,7 @@ class HassioDataModel {
closeConnection() {
if (_hassioChannel?.closeCode == null) {
_hassioChannel.sink?.close();
_hassioChannel?.sink?.close();
}
_hassioChannel = null;
}
@ -111,7 +117,7 @@ class HassioDataModel {
_sendSubscribe();
connectionCompleter.complete();
} else if (data["type"] == "auth_invalid") {
connectionCompleter.completeError({message: "Auth error: ${data["message"]}"});
connectionCompleter.completeError({"errorCode": 6, "errorMessage": "${data["message"]}"});
} else if (data["type"] == "result") {
if (data["id"] == _configMessageId) {
_parseConfig(data);