mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-12 00:23:08 -04:00
LibresapiLocalClient improve error handling
This commit is contained in:
parent
c3ba5511d8
commit
29a3d105c4
2 changed files with 29 additions and 7 deletions
retroshare-qml-app/src
|
@ -23,6 +23,7 @@
|
|||
#include <QLocalSocket>
|
||||
#include <QQueue>
|
||||
#include <QJSValue>
|
||||
#include <QTimer>
|
||||
|
||||
class LibresapiLocalClient : public QObject
|
||||
{
|
||||
|
@ -33,11 +34,17 @@ public:
|
|||
#ifdef QT_DEBUG
|
||||
reqCount(0), ansCount(0), mDebug(true),
|
||||
#endif // QT_DEBUG
|
||||
mLocalSocket(this) {}
|
||||
mLocalSocket(this)
|
||||
{
|
||||
mConnectAttemptTimer.setSingleShot(true);
|
||||
mConnectAttemptTimer.setInterval(500);
|
||||
connect(&mConnectAttemptTimer, SIGNAL(timeout()),
|
||||
this, SLOT(socketConnectAttempt()));
|
||||
}
|
||||
|
||||
Q_INVOKABLE int request( const QString& path, const QString& jsonData = "",
|
||||
QJSValue callback = QJSValue::NullValue );
|
||||
Q_INVOKABLE void openConnection(QString socketPath);
|
||||
Q_INVOKABLE void openConnection(const QString& socketPath);
|
||||
|
||||
#ifdef QT_DEBUG
|
||||
Q_PROPERTY(bool debug READ debug WRITE setDebug NOTIFY debugChanged)
|
||||
|
@ -51,6 +58,8 @@ public:
|
|||
#endif // QT_DEBUG
|
||||
|
||||
private:
|
||||
QTimer mConnectAttemptTimer;
|
||||
QString mSocketPath;
|
||||
QLocalSocket mLocalSocket;
|
||||
|
||||
struct PQRecord
|
||||
|
@ -68,6 +77,7 @@ private:
|
|||
QQueue<PQRecord> processingQueue;
|
||||
|
||||
private slots:
|
||||
void socketConnectAttempt() { mLocalSocket.connectToServer(mSocketPath); }
|
||||
void socketError(QLocalSocket::LocalSocketError error);
|
||||
void read();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue