implement send command
This commit is contained in:
29
main.cpp
29
main.cpp
@@ -1,36 +1,23 @@
|
||||
#include <QApplication>
|
||||
#include <QSslSocket>
|
||||
#include <QThread>
|
||||
|
||||
#include "stompframe.h"
|
||||
#include "stomp.h"
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
QApplication application(argc, argv);
|
||||
|
||||
QSslSocket socket;
|
||||
socket.setPeerVerifyMode(QSslSocket::VerifyNone);
|
||||
Stomp st;
|
||||
st.connectRequest("sdi.hevs.ch", 61614, "/", "sdi10", "809c02f36becb0868da98761fe3209f6");
|
||||
|
||||
st.sendRequest("/topic/sdi10.gem.command", "right");
|
||||
|
||||
QObject::connect(&socket, &QSslSocket::readyRead, [&]() {
|
||||
auto frame = STOMPFrame::receive(socket);
|
||||
st.sendRequest("/topic/sdi10.gem.command", "up");
|
||||
|
||||
qDebug() << "Connected:" << (frame.command() == STOMPFrame::CONNECTED) << Qt::endl
|
||||
<< "Version:" << frame.headers().value("version");
|
||||
});
|
||||
st.sendRequest("/topic/sdi10.gem.command", "left");
|
||||
|
||||
socket.connectToHostEncrypted("sdi.hevs.ch", 61614);
|
||||
if(!socket.waitForConnected()) return -1;
|
||||
st.sendRequest("/topic/sdi10.gem.command", "down");
|
||||
|
||||
STOMPFrame(STOMPFrame::STOMP, {
|
||||
{"accept-version", "1.2"},
|
||||
{"host", "/"},
|
||||
{"login", "sdi10"},
|
||||
{"passcode", "809c02f36becb0868da98761fe3209f6"}
|
||||
}).send(socket);
|
||||
|
||||
|
||||
|
||||
STOMPFrame(STOMPFrame::MESSAGE, {
|
||||
{},
|
||||
}).send(socket);
|
||||
return application.exec();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user