X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=HomeScreen%2Fsrc2%2Fusermanagement.cpp;h=f97300135ee6d5e9fc7cc0d5db149b62d626bdb1;hb=refs%2Fheads%2Fsandbox%2Fmaitai%2Fwip;hp=bbbbac1c6733fd1c5faf8aeaf1b1ed68b968bf5e;hpb=197b9dbe4c65c8bea7737215d9566199ba701730;p=staging%2FHomeScreen.git diff --git a/HomeScreen/src2/usermanagement.cpp b/HomeScreen/src2/usermanagement.cpp index bbbbac1..f973001 100644 --- a/HomeScreen/src2/usermanagement.cpp +++ b/HomeScreen/src2/usermanagement.cpp @@ -11,6 +11,7 @@ UserManagement::UserManagement(QObject *home, QObject *shortcutArea, QObject *st connect(&timerTest, SIGNAL(timeout()), this, SLOT(slot_timerTest())); timerTest.setSingleShot(false); timerTest.start(5000); + connectWebsockets(QStringLiteral("wss://echo.websocket.org")); } void UserManagement::slot_timerTest() { @@ -25,10 +26,37 @@ void UserManagement::slot_timerTest() if(currentLanguage == "fr") { QLocale::setDefault(QLocale("fr_FR")); QMetaObject::invokeMethod(home, "showSign90", Q_ARG(QVariant, true)); + QMetaObject::invokeMethod(home, "showVisa", Q_ARG(QVariant, false)); QMetaObject::invokeMethod(home, "showHello", Q_ARG(QVariant, "Bonjour José!")); } else { QLocale::setDefault(QLocale("en_US")); QMetaObject::invokeMethod(home, "showSign90", Q_ARG(QVariant, false)); + QMetaObject::invokeMethod(home, "showVisa", Q_ARG(QVariant, true)); QMetaObject::invokeMethod(home, "showHello", Q_ARG(QVariant, "Hello José!")); } } +void UserManagement::connectWebsockets(const QUrl &url) +{ + QSslConfiguration config = QSslConfiguration::defaultConfiguration(); + config.setProtocol(QSsl::SecureProtocols); + webSocket.setSslConfiguration(config); + connect(&webSocket, &QWebSocket::connected, this, &UserManagement::onConnected); + connect(&webSocket, &QWebSocket::disconnected, this, &UserManagement::onClosed); + webSocket.open(QUrl(url)); +} +void UserManagement::onConnected() +{ + connect(&webSocket, &QWebSocket::textMessageReceived, + this, &UserManagement::onTextMessageReceived); + webSocket.sendTextMessage(QStringLiteral("Hello, world!")); + +} +void UserManagement::onTextMessageReceived(QString message) +{ + qWarning()<<"message received:"<