trikRuntime
trikVariablesServer.h
Go to the documentation of this file.
1 /* Copyright 2018 Anastasiia Kornilova, CyberTech Labs Ltd.
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License. */
14 
15 #pragma once
16 
17 #include <QtCore/QObject>
18 #include <QtNetwork/QTcpServer>
19 
20 namespace trikScriptRunner {
21 
23 class TrikVariablesServer : public QObject
24 {
25  Q_OBJECT
26 public:
29 
30 signals:
33  void getVariables(const QString &propertyName);
34 
35 public slots:
38  void sendHTTPResponse(const QJsonObject &json);
39 
40 private slots:
42  void onNewConnection();
43 
45  void processHTTPRequest();
46 
47 private:
48  QScopedPointer<QTcpServer> mTcpServer;
49  QTcpSocket *mCurrentConnection {}; // Has ownership in QTcpServer
50 
51  constexpr static int port = 10000;
52 };
53 
54 }
Definition: trikCommunicator.h:23
void getVariables(const QString &propertyName)
Emitted when there is a new connection with a HTTP-request of variables values.
void sendHTTPResponse(const QJsonObject &json)
Sends HTTP response with JSON data about variables.
Definition: trikVariablesServer.cpp:30
Class for script variables observing, based on HTTP server.
Definition: trikVariablesServer.h:23
TrikVariablesServer()
Constructor.
Definition: trikVariablesServer.cpp:23