This commit is contained in:
Andrei Yankovich 2021-10-13 21:35:54 +03:00
parent 063ff4ece3
commit d493203b20
6 changed files with 29 additions and 2 deletions

View File

@ -94,6 +94,8 @@ bool Controller::sendStop() {
if (!d_ptr)
return false;
d_ptr->setEcho(false);
if (!d_ptr->connectToHost(false)) {
return false;
}

View File

@ -104,6 +104,11 @@ bool ControllerPrivate::connectToHost(bool echo) const {
return true;
}
void ControllerPrivate::setEcho(bool echo) {
if (_socket)
_socket->setEcho(echo);
}
void ControllerPrivate::handleReceve(QByteArray data) {
if (!_controller) {

View File

@ -32,6 +32,8 @@ public:
bool isConnected() const;
bool connectToHost(bool echo = true) const;
void setEcho(bool echo);
signals:
void sigListFeatures(QList<Feature>);

View File

@ -9,8 +9,19 @@
namespace Patronum {
ISocketWraper::ISocketWraper(){
}
State ISocketWraper::state() const {
return m_state;
}
bool ISocketWraper::echo() const {
return _echo;
}
void ISocketWraper::setEcho(bool newEcho) {
_echo = newEcho;
}
}

View File

@ -21,7 +21,7 @@ enum class State: int {
class ISocketWraper
{
public:
ISocketWraper(){};
ISocketWraper();
/**
* @brief send - send data to service
* @param data
@ -68,8 +68,12 @@ public:
State state() const;
bool echo() const;
void setEcho(bool newEcho);
protected:
State m_state = State::Disconeccted;
bool _echo = true;
};

View File

@ -15,7 +15,7 @@
namespace Patronum {
LocalSocket::LocalSocket(const QString &target, QObject *ptr):
QObject(ptr) {
QObject(ptr), ISocketWraper() {
m_target = "P" + target;
}
@ -132,6 +132,9 @@ void LocalSocket::handleIncomming() {
void LocalSocket::handleSocketError(QLocalSocket::LocalSocketError) {
if (!_echo)
return;
auto _sender = dynamic_cast<QLocalSocket*>(sender());
if (!_sender) {