C++ (Qt)class Manager : public QObject {Q_OBJECTprivate: QWsSocket *socket; QSystemTrayIcon *icon; private slots: void messageReceived(QString);}; Manager::Manager() { socket = new QWsSocket; socket->connectToHost("127.0.0.1", 30003); icon = new QSystemTrayIcon; icon->show(); QObject::connect(socket, SIGNAL(frameReceived(QString)), SLOT(messageReceived(QString)));} void Manager::messageReceived(QString msg) { //Пренебрежём преобразованием из json в сообщение icon->showMessage("новое сообщение", msg);}
C++ (Qt)void Manager::sendMessage(QString msg) { socket->write(msg);}
C++ (Qt)void Manager::sendMessage(QString msg) { socket->write(msg); socket->waitForBytesWritten(); socket->waitForReadyRead();}
C++ (Qt)QJsonDocument res1 = manager->sendMessageSync(msg1);QJsonDocument res2 = manager->sendMessageSync(msg2);
C++ (Qt)while(!asleep()) sheep++;