15 _controller = controller;
18 this, &ServicePrivate::handleReceve);
25 QuasarAppUtils::Params::log(
"scoket is closed!",
26 QuasarAppUtils::Error);
31 QDataStream stream(&responce, QIODevice::WriteOnly);
35 return _socket->
send(responce);
40 QuasarAppUtils::Params::log(
"scoket is closed!",
41 QuasarAppUtils::Error);
46 QDataStream stream(&responce, QIODevice::WriteOnly);
50 return _socket->
send(responce);
55 QuasarAppUtils::Params::log(
"scoket is closed!",
56 QuasarAppUtils::Error);
61 QDataStream stream(&responce, QIODevice::WriteOnly);
65 return _socket->
send(responce);
68 void ServicePrivate::handleReceve(QByteArray data) {
70 if (data.size() < 2) {
74 const Package *
package = reinterpret_cast<const Package *>( data.data());
76 switch (package->cmd) {
81 QuasarAppUtils::Params::log(
"System error, service is not inited!",
82 QuasarAppUtils::Error);
86 if (!_socket->isValid()) {
87 QuasarAppUtils::Params::log(
"scoket is closed!",
88 QuasarAppUtils::Error);
92 QList<Feature> features = _service->supportedFeatures();
94 QDataStream stream(&sendData, QIODevice::WriteOnly);
97 if (!_socket->send(sendData)) {
98 QuasarAppUtils::Params::log(
"scoket is closed!",
99 QuasarAppUtils::Error);
108 QuasarAppUtils::Params::log(
"System error, controller is not inited!",
109 QuasarAppUtils::Error);
113 QDataStream stream(package->data);
115 QList<Feature> features;
118 _controller->handleFeatures(features);
125 QuasarAppUtils::Params::log(
"System error, service is not inited!",
126 QuasarAppUtils::Error);
130 QDataStream stream(package->data);
132 QList<Feature> feature;
134 _service->handleReceve(feature);
142 QuasarAppUtils::Params::log(
"System error, controller is not inited!",
143 QuasarAppUtils::Error);
147 QDataStream stream(package->data);
151 _controller->handleResponce(feature);
157 QuasarAppUtils::Params::log(
"Wrong command!",
158 QuasarAppUtils::Error);
ServicePrivate(const QString &name, IController *controller=nullptr, IService *service=nullptr, QObject *parent=nullptr)
The LocalSocket class this socket work only with locale data.
void sigReceve(QByteArray data)
bool send(const QByteArray &data)
send - send data to service
bool isValid() const
isValid - check validation of socket
bool sendCmd(const QList< Feature > &result)
bool sendCmdResult(const QVariantMap &result)
bool sendFeaturesRequest()