[GUI] Add connection loss detection and reestablishment
This commit is contained in:
parent
1813e9f5f6
commit
d176429dad
3 changed files with 18 additions and 4 deletions
|
|
@ -156,6 +156,7 @@ void GrapheneApplication::start( QString apiurl, QString user, QString pass )
|
|||
m_client = std::make_shared<fc::http::websocket_client>();
|
||||
ilog( "connecting...${s}", ("s",apiurl.toStdString()) );
|
||||
auto con = m_client->connect( apiurl.toStdString() );
|
||||
m_connectionClosed = con->closed.connect([this]{queueExecute([this]{setIsConnected(false);});});
|
||||
auto apic = std::make_shared<fc::rpc::websocket_api_connection>(*con);
|
||||
auto remote_api = apic->get_remote_api< login_api >(1);
|
||||
auto db_api = apic->get_remote_api< database_api >(0);
|
||||
|
|
|
|||
|
|
@ -129,6 +129,8 @@ class GrapheneApplication : public QObject {
|
|||
ChainDataModel* m_model = nullptr;
|
||||
bool m_isConnected = false;
|
||||
|
||||
boost::signals2::scoped_connection m_connectionClosed;
|
||||
|
||||
std::shared_ptr<fc::http::websocket_client> m_client;
|
||||
fc::future<void> m_done;
|
||||
|
||||
|
|
|
|||
|
|
@ -14,10 +14,6 @@ ApplicationWindow {
|
|||
height: 480
|
||||
title: qsTr("Hello World")
|
||||
|
||||
Component.onCompleted: {
|
||||
app.start("ws://localhost:8090", "user", "pass")
|
||||
}
|
||||
|
||||
menuBar: MenuBar {
|
||||
Menu {
|
||||
title: qsTr("File")
|
||||
|
|
@ -32,9 +28,22 @@ ApplicationWindow {
|
|||
}
|
||||
}
|
||||
}
|
||||
statusBar: StatusBar {
|
||||
Label {
|
||||
anchors.right: parent.right
|
||||
text: app.isConnected? qsTr("Connected") : qsTr("Disconnected")
|
||||
}
|
||||
}
|
||||
|
||||
GrapheneApplication {
|
||||
id: app
|
||||
}
|
||||
Timer {
|
||||
running: !app.isConnected
|
||||
interval: 5000
|
||||
repeat: true
|
||||
onTriggered: app.start("ws://localhost:8090", "user", "pass")
|
||||
triggeredOnStart: true
|
||||
}
|
||||
Settings {
|
||||
id: appSettings
|
||||
|
|
@ -47,6 +56,8 @@ ApplicationWindow {
|
|||
|
||||
Column {
|
||||
anchors.centerIn: parent
|
||||
enabled: app.isConnected
|
||||
|
||||
Button {
|
||||
text: "Transfer"
|
||||
onClicked: formBox.showForm(Qt.createComponent("TransferForm.qml"), {},
|
||||
|
|
|
|||
Loading…
Reference in a new issue