Socket errors handling. Closes [#37] as well
This commit is contained in:
parent
9e23b92a33
commit
9c7a878bb1
@ -30,6 +30,8 @@ class HassioDataModel {
|
|||||||
} else {
|
} else {
|
||||||
_fetchingTimer = new Timer(new Duration(seconds: 10), () {
|
_fetchingTimer = new Timer(new Duration(seconds: 10), () {
|
||||||
_fetchCompleter.completeError({"message": "Data fetching timeout."});
|
_fetchCompleter.completeError({"message": "Data fetching timeout."});
|
||||||
|
_hassioChannel.sink.close();
|
||||||
|
_hassioChannel = null;
|
||||||
});
|
});
|
||||||
_fetchCompleter = new Completer();
|
_fetchCompleter = new Completer();
|
||||||
_reConnectSocket().then((r) {
|
_reConnectSocket().then((r) {
|
||||||
@ -139,7 +141,7 @@ class HassioDataModel {
|
|||||||
debugPrint(" $message");
|
debugPrint(" $message");
|
||||||
_hassioChannel.sink.add(message);
|
_hassioChannel.sink.add(message);
|
||||||
}).catchError((e){
|
}).catchError((e){
|
||||||
debugPrint("Unable to connect for sending =(");
|
debugPrint("Unable to connect for sending: $e");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -279,7 +279,7 @@ class _MainPageState extends State<MainPage> {
|
|||||||
title: _buildTitle()
|
title: _buildTitle()
|
||||||
),
|
),
|
||||||
drawer: _buildAppDrawer(),
|
drawer: _buildAppDrawer(),
|
||||||
body: Text(_dataModelErrorMessage != null ? "Well... no. There was an error: $_dataModelErrorMessage" : "Loading... or not..."),
|
body: Text(_dataModelErrorMessage != null ? "Well... no.\n\nThere was an error:\n$_dataModelErrorMessage" : "Loading... or not...\n\nJust wait 10 seconds"),
|
||||||
floatingActionButton: new FloatingActionButton(
|
floatingActionButton: new FloatingActionButton(
|
||||||
onPressed: _refreshData,
|
onPressed: _refreshData,
|
||||||
tooltip: 'Increment',
|
tooltip: 'Increment',
|
||||||
|
Reference in New Issue
Block a user