Repository navigation
Using gwamp to connect to crossbar - #6195
DeepDiver1975 wants to merge 4 commits into
Conversation
| endif() | ||
| endif() | ||
|
|
||
| find_package(Qt5WebSockets) |
There was a problem hiding this comment.
qwamp needs it - hmmm
There was a problem hiding this comment.
maybe we patch qwamp to work without the qwebsocket dependency
| set (QT_LIBRARIES ${QT_LIBRARIES} ${Qt5MacExtras_LIBRARIES}) | ||
| endif() | ||
|
|
||
| if(Qt5WebSockets_FOUND) |
| set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-z,relro -Wl,-z,now") | ||
| endif() | ||
|
|
||
| find_package(Qt5Qml REQUIRED) |
| add_library(updater STATIC ${updater_SRCS} ${updaterMoc}) | ||
| target_link_libraries(updater ${synclib_NAME}) | ||
| qt5_use_modules(updater Widgets Network Xml) | ||
| qt5_use_modules(updater Widgets Network Xml Qml) |
| ../3rdparty/qtsingleapplication/qtlocalpeer.cpp | ||
| ../3rdparty/qtsingleapplication/qtsingleapplication.cpp | ||
| ../3rdparty/qtsingleapplication/qtsinglecoreapplication.cpp | ||
| ../3rdparty/qmsgpack/src/msgpack.cpp |
There was a problem hiding this comment.
I'm sure there is a nicer way ...
There was a problem hiding this comment.
I guess it's fine.
The ideal way would be to have that in a separate .cmake file included in the qmsgpack repository, but since it's not the case, then so be it.
| ../3rdparty/qtsingleapplication/qtlocalpeer.cpp | ||
| ../3rdparty/qtsingleapplication/qtsingleapplication.cpp | ||
| ../3rdparty/qtsingleapplication/qtsinglecoreapplication.cpp | ||
| ../3rdparty/qmsgpack/src/msgpack.cpp |
There was a problem hiding this comment.
I guess it's fine.
The ideal way would be to have that in a separate .cmake file included in the qmsgpack repository, but since it's not the case, then so be it.
| session->start(); | ||
| }); | ||
|
|
||
| QObject::connect(_webSocket.data(), QOverload<QAbstractSocket::SocketError>::of(&QAbstractSocket::error), [&](QAbstractSocket::SocketError err){ |
There was a problem hiding this comment.
QOverload requires Qt 5.7 (before that, we'd have to use static_cast)
(Actually, i've been thinking about copying QOverload within some header so we can use it while still being compatible with Qt 5.6)
There was a problem hiding this comment.
well - what ever works - tell me whyt to do
| add_definitions( -DWINVER=0x0600) | ||
| endif( WIN32 ) | ||
|
|
||
| set(CMAKE_CXX_STANDARD 14) |
There was a problem hiding this comment.
Yay, \o/ finally i'd be able to use auto in lamda :-)
I guess we can do that because we stopped supporting these old debian and centOS that did not even have GCC 4.8
although this is not strictly required for your patch.
There was a problem hiding this comment.
no - not required - but much more fun coding ;-)
|
CI fails @DeepDiver1975 you can build with tests to reproduce |
| url = [email protected]:unitednetworks/qwamp.git | ||
| [submodule "src/3rdparty/qmsgpack"] | ||
| path = src/3rdparty/qmsgpack | ||
| url = [email protected]:romixlab/qmsgpack.git |
There was a problem hiding this comment.
https://github.com/unitednetworks/qwamp
says Apache 2.0 correct? Thats perfect and I'll add it to the list.
https://github.com/romixlab/qmsgpack/blob/master/LICENSE
is MIT right? Also perfect ... I do need to add both, right?
| add_definitions( -DWINVER=0x0600) | ||
| endif( WIN32 ) | ||
|
|
||
| set(CMAKE_CXX_STANDARD 14) |
| qDebug() << "Session joined to realm1 with session ID " << s; | ||
|
|
||
| session->subscribe("etag-changed-channel", [&](const QVariantList& args, const QVariantMap& options){ | ||
| qDebug() << "Event received"; |
There was a problem hiding this comment.
While in general I think the lambdas are cool, we should not become a nodejs with 3x nested callbacks :-)
| bool _csyncUnavail; | ||
| bool _proxyDirty; | ||
| QPointer<RequestEtagJob> _requestEtagJob; | ||
| QScopedPointer<QTcpSocket> _webSocket; |
There was a problem hiding this comment.
Guide me - can QSslSocket also establish a non-ssl connection?
There was a problem hiding this comment.
There was a problem hiding this comment.
You can use one of those depending on the account URL http vs https or how would this work? I wonder if the websocket URL should come from capabilities though so the server admin can scale it differently..
Things to keep in mind is the sslErrors signal. We have a AbstractSslErrorHandler that you can use.
The question is if websockets could return different ssl errors or not. Maybe as first implementation you assume they return the same error as the normal account WebDAV calls ..
There was a problem hiding this comment.
The server would expose the websocket url via a capability. The Url will either be ws:// or wss://.
So depending on using ssl or not I either call connectToHost or connectToHostEncrypted ?
There was a problem hiding this comment.
I'll postpone the ssl topic - websockets with self signed certificates are not working.
Hard to test at the moment.
Is QString serialized to the same kind of string as you will emit from the server side? So it's interoperable with non-Qt code using WAMP?
|
In my non-representative local test the string as sent by the server popped up in the client the same way. |
3896aa1 to
5ba6e6f
Compare
|
the windows build hates me - qt version? compiler used? |
location of error: https://github.com/DeepDiver1975/qwamp/blob/782e65859617e52fa0d92d56551fc05da62c1f8f/qwamp.h#L415 compiler error: |
ogoffart
left a comment
There was a problem hiding this comment.
There are lots of unrelated whitespace changes.
| QString Capabilities::getWebSocketUrl() const | ||
| { | ||
| if (!_capabilities.contains("websocket")) { | ||
| return ""; |
There was a problem hiding this comment.
return QString()
(Otherwise you make a useless conversion from char*)
Also later.
| _session.reset(new QWamp::Session(sessionName, *_webSocket.data(), QWamp::Session::MessageFormat::Msgpack, true)); | ||
|
|
||
| QObject::connect(_session.data(), &QWamp::Session::joined, [&](qint64 s) { | ||
| qDebug() << "Session joined to realm1 with session ID " << s; |
There was a problem hiding this comment.
I know this is only temporary and you are going to clean up. In the final PR there should be no qDebug without categories.
| // TODO: add current userid | ||
| _session->subscribe("files.root-etag-changed.admin", [&](const QVariantList& args, const QVariantMap& options) { | ||
| qDebug() << "Event received"; | ||
| QString notificationEtag = args.at(0).toString(); |
There was a problem hiding this comment.
QList::at crashes if the list don't have enough argument, which can happen, i guess, if the server is sending garbage.
So you can use value() which will return an empty variant if out of bounds. or you should check if there is enough element in the list before.
| } | ||
| //initialize wamp connection | ||
| _webSocket.reset(new QTcpSocket()); | ||
| QUrl webSocketUrl(wsUrl); |
There was a problem hiding this comment.
You also probably need to handle the disconnect case, and re try to connect. Also handle error such as timeout and other kind.
So you will need to move this connection code somewhere else so you can call it when you want to re-connect.
| }); | ||
|
|
||
| QObject::connect(_webSocket.data(), static_cast<void (QAbstractSocket::*)(QAbstractSocket::SocketError err)>(&QAbstractSocket::error), [&](QAbstractSocket::SocketError err) { | ||
| qInfo() << "tcp error: " << err; |
There was a problem hiding this comment.
This probably deserve to be a qCWarning. Don't forget to add a category. Also keep it in one line.
| qInfo() << _webSocket->errorString(); | ||
| }); | ||
| qInfo() << "Connecting to websocket " << wsUrl; | ||
| _webSocket->abort(); |
| if (webSocketUrl.scheme() == "ws") { | ||
| _webSocket->connectToHost(webSocketUrl.host(), webSocketUrl.port()); | ||
| } else { | ||
| qCCritical(lcFolder) << "Invalid web socket scheme: " << webSocketUrl; |
There was a problem hiding this comment.
qCWarning... critical is a bit too high.
ToDo
💟 I really love lambdas in C++ - nice to see the language evolving 💟