|
@@ -1,4 +1,5 @@
|
|
-#include "wsserver.h"
|
|
|
|
|
|
+//#pragma execution_character_set("utf-8")
|
|
|
|
+#include "wsserver.h"
|
|
|
|
|
|
WSServer::WSServer(QObject *parent, quint16 port) : QObject(parent)
|
|
WSServer::WSServer(QObject *parent, quint16 port) : QObject(parent)
|
|
{
|
|
{
|
|
@@ -262,25 +263,23 @@ void WSServer::returnMessage(QWebSocket *pSender, QJsonObject *jsonObj)
|
|
void WSServer::getInit(QWebSocket *pSender, QJsonObject obj)
|
|
void WSServer::getInit(QWebSocket *pSender, QJsonObject obj)
|
|
{
|
|
{
|
|
qDebug() << "网页请求初始化状态";
|
|
qDebug() << "网页请求初始化状态";
|
|
- // 假接口,指针写法
|
|
|
|
- QJsonObject *InitState = new QJsonObject();
|
|
|
|
- InitState->insert("InitState", 100);
|
|
|
|
- QJsonObject *ret = new QJsonObject();
|
|
|
|
- ret->insert("url", obj.value("url"));
|
|
|
|
- ret->insert("data", *InitState);
|
|
|
|
- delete InitState;
|
|
|
|
-
|
|
|
|
- // 真实接口,局部变量
|
|
|
|
|
|
+ // 假接口
|
|
|
|
+ QJsonObject InitState
|
|
|
|
+ {
|
|
|
|
+ {"InitState",100}
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ // 真实接口
|
|
// QJsonObject InitState
|
|
// QJsonObject InitState
|
|
// {
|
|
// {
|
|
// {"InitState",100*(int)this->zcman->common_inter->InitState}
|
|
// {"InitState",100*(int)this->zcman->common_inter->InitState}
|
|
// };
|
|
// };
|
|
|
|
|
|
-// QJsonObject *ret = new QJsonObject(
|
|
|
|
-// {
|
|
|
|
-// {"url", obj.value("url")},
|
|
|
|
-// {"data", InitState}
|
|
|
|
-// });
|
|
|
|
|
|
+ QJsonObject *ret = new QJsonObject(
|
|
|
|
+ {
|
|
|
|
+ {"url", obj.value("url")},
|
|
|
|
+ {"data", InitState}
|
|
|
|
+ });
|
|
|
|
|
|
returnMessage(pSender, ret);
|
|
returnMessage(pSender, ret);
|
|
}
|
|
}
|
|
@@ -291,21 +290,23 @@ void WSServer::getPlatformTable(QWebSocket *pSender, QJsonObject obj)
|
|
qDebug() << "网页请求平台信息";
|
|
qDebug() << "网页请求平台信息";
|
|
QJsonArray Platforms;
|
|
QJsonArray Platforms;
|
|
// 假接口
|
|
// 假接口
|
|
- QJsonObject *SinglePlatform;
|
|
|
|
- SinglePlatform = new QJsonObject();
|
|
|
|
- SinglePlatform->insert("platformID", 8015);
|
|
|
|
- SinglePlatform->insert("platformName", "侦察机_1");
|
|
|
|
- Platforms.append(*SinglePlatform);
|
|
|
|
- delete SinglePlatform;
|
|
|
|
-
|
|
|
|
- SinglePlatform = new QJsonObject();
|
|
|
|
- SinglePlatform->insert("platformID", 8016);
|
|
|
|
- SinglePlatform->insert("platformName", "侦察机_2");
|
|
|
|
- Platforms.append(*SinglePlatform);
|
|
|
|
- delete SinglePlatform;
|
|
|
|
|
|
+ QJsonObject SinglePlatform[] {
|
|
|
|
+ {
|
|
|
|
+ {"platformID", 8015},
|
|
|
|
+ {"platformName", "侦察机_1"}
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ {"platformID", 8016},
|
|
|
|
+ {"platformName", "侦察机_2"}
|
|
|
|
+ },
|
|
|
|
+ };
|
|
|
|
+ for (auto i: SinglePlatform)
|
|
|
|
+ {
|
|
|
|
+ Platforms.append(i);
|
|
|
|
+ }
|
|
|
|
|
|
// 真实接口
|
|
// 真实接口
|
|
-// for (auto i : this->zcman->zctaskplats)
|
|
|
|
|
|
+// for (auto i : this->grman->grtaskplats)
|
|
// {
|
|
// {
|
|
// QJsonObject SinglePlatform
|
|
// QJsonObject SinglePlatform
|
|
// {
|
|
// {
|