@@ -38,6 +38,8 @@ class YioAPI : public YioAPIInterface {
3838 Q_INTERFACES (YioAPIInterface)
3939
4040 public:
41+ static YioAPI* getInstance ();
42+
4143 Q_PROPERTY (bool running READ running NOTIFY runningChanged) // returns the state of the API
4244 Q_PROPERTY (QString hostname READ hostname NOTIFY hostnameChanged) // returns the hostname of the remote
4345
@@ -51,6 +53,9 @@ class YioAPI : public YioAPIInterface {
5153 */
5254 Q_INVOKABLE void sendMessage (QString message) override ;
5355
56+ void setWebSocketPort (quint16 port) { m_port = port; }
57+ quint16 webSocketPort () { return m_port; }
58+
5459 // CONFIG MANIPULATION METHODS
5560 QVariantMap getConfig () override ;
5661 bool setConfig (QVariantMap config);
@@ -67,11 +72,6 @@ class YioAPI : public YioAPIInterface {
6772 void discoverNetworkServices () override ;
6873 Q_INVOKABLE void discoverNetworkServices (QString mdns) override ;
6974
70- explicit YioAPI (QQmlApplicationEngine* engine = nullptr );
71- ~YioAPI () override ;
72-
73- static YioAPI* getInstance () { return s_instance; }
74-
7575 signals:
7676 // void closed();
7777 // void messageReceived(QVariantMap message);
@@ -87,35 +87,10 @@ class YioAPI : public YioAPIInterface {
8787 void onClientDisconnected ();
8888
8989 private:
90- QWebSocketServer* m_server;
91- QMap<QWebSocket*, bool > m_clients; // websocket client, true if authentication was successful
92-
93- QList<QWebSocket*> m_subscribed_clients;
94- QObject* m_context;
95- void subscribeOnSignalEvent (const QString& event);
96-
97- bool m_running = false ;
98-
99- static YioAPI* s_instance;
100- QQmlApplicationEngine* m_engine;
101-
102- QString m_token = " 0" ; // "c82b5fd6bea6fc3faf9a30bb864a9ee2"
103- // QCryptographicHash::hash(m_token.toLocal8Bit(), QCryptographicHash::Sha512);
104- QByteArray m_hash =
105- " {U\xC0 <$\xF7\n\xA7 PA\xC3 =\xBE k\xF5\xC1\xCA\x8B\t\x91\xA0\x9E t\xBA "
106- " E\xE9\xA0 )\xE4\x07 ^E\x04\x17 Xg\xE4 )\x04\xB7\xD4\x9D ,\x19 %\xD7\xA1\xDC\x84 U\x83\xA2\xAA\x1D\xD7 :\xBE\xF6 "
107- " 1\xFA\x90\xED\x16\xBB " ;
108- QString m_hostname;
109-
110- QZeroConf m_zeroConf;
111- QZeroConf* m_zeroConfBrowser;
90+ YioAPI ();
91+ ~YioAPI () override ;
11292
113- QStringList m_discoverableServices;
114- QString m_prevIp;
115-
116- Entities* m_entities;
117- Integrations* m_integrations;
118- Config* m_config;
93+ void subscribeOnSignalEvent (const QString& event);
11994
12095 // API CALLS
12196 void apiSendResponse (QWebSocket* client, const int & id, const bool & success, QVariantMap response);
@@ -168,4 +143,30 @@ class YioAPI : public YioAPIInterface {
168143 void apiSettingsSetDarkMode (QWebSocket* client, const int & id, const QVariantMap& map);
169144
170145 void apiLoggerControl (QWebSocket* client, const int & id, const QVariantMap& map);
146+
147+ private:
148+ quint16 m_port;
149+ bool m_running = false ;
150+ QWebSocketServer* m_server;
151+ QMap<QWebSocket*, bool > m_clients; // websocket client, true if authentication was successful
152+
153+ QList<QWebSocket*> m_subscribed_clients;
154+ QObject* m_context;
155+
156+ QString m_token = " 0" ; // "c82b5fd6bea6fc3faf9a30bb864a9ee2"
157+ // QCryptographicHash::hash(m_token.toLocal8Bit(), QCryptographicHash::Sha512);
158+ QByteArray m_hash =
159+ " {U\xC0 <$\xF7\n\xA7 PA\xC3 =\xBE k\xF5\xC1\xCA\x8B\t\x91\xA0\x9E t\xBA "
160+ " E\xE9\xA0 )\xE4\x07 ^E\x04\x17 Xg\xE4 )\x04\xB7\xD4\x9D ,\x19 %\xD7\xA1\xDC\x84 U\x83\xA2\xAA\x1D\xD7 :\xBE\xF6 "
161+ " 1\xFA\x90\xED\x16\xBB " ;
162+ QString m_hostname;
163+
164+ QZeroConf m_zeroConf;
165+
166+ QStringList m_discoverableServices;
167+ QString m_prevIp;
168+
169+ Entities* m_entities;
170+ Integrations* m_integrations;
171+ Config* m_config;
171172};
0 commit comments