This commit is contained in:
Timur A. Fatkhullin
2024-11-26 00:23:16 +03:00
parent ecca565f3f
commit 3f34efd244
3 changed files with 50 additions and 13 deletions

View File

@@ -344,7 +344,8 @@ public:
}
}
if (found) {
msg.ack(msg_t::DEVICE_KEY, attrs);
// msg.ack(msg_t::DEVICE_KEY, attrs);
msg.ack(constants::ADC_DEVICE_NETPROTO_KEY_DEVICE, attrs);
} else {
msg.err(std::make_error_code(AdcDeviceNetServerSessionError::ERROR_UNKNOWN_DEVICE_ID));
}
@@ -356,14 +357,17 @@ public:
for (auto& [ptr, dev_wr] : _serverPtr->_devices) {
names.emplace_back(dev_wr.ident());
}
msg.ack(msg_t::NAMES_KEY, names);
// msg.ack(msg_t::NAMES_KEY, names);
msg.ack(constants::ADC_DEVICE_NETPROTO_KEY_NAMES, names);
} else if (msg.isHELLO()) {
msg.ack(msg_t::HELLO_KEY, _serverPtr->_serverIdent);
// msg.ack(msg_t::HELLO_KEY, _serverPtr->_serverIdent);
msg.ack(constants::ADC_DEVICE_NETPROTO_KEY_HELLO, _serverPtr->_serverIdent);
} else if (msg.isGET()) { // get attribute value
attrs = msg.template attrs<attr_vec_t>(0, 1);
if (attrs.size()) {
auto val = _bindDevice->getAttr(get_elem(0));
msg.ack(msg_t::GET_KEY, get_elem(0), val);
// msg.ack(msg_t::GET_KEY, get_elem(0), val);
msg.ack(constants::ADC_DEVICE_NETPROTO_KEY_GET, get_elem(0), val);
} else { // no attr name!
msg.err(std::make_error_code(AdcDeviceNetServerSessionError::ERROR_NO_PROTO_ATTRNAME));
}
@@ -372,7 +376,8 @@ public:
if (attrs.size() >= 2) {
auto val = msg.template joinAttrs<serialized_t>(1);
_bindDevice->setAttr(get_elem(0), val);
msg.ack(msg_t::SET_KEY, get_elem(0), val);
// msg.ack(msg_t::SET_KEY, get_elem(0), val);
msg.ack(constants::ADC_DEVICE_NETPROTO_KEY_SET, get_elem(0), val);
} else { // no attr name or its value!
if (attrs.size() == 1) {
msg.err(std::make_error_code(AdcDeviceNetServerSessionError::ERROR_NO_PROTO_ATTRVALUE));
@@ -385,7 +390,8 @@ public:
if (attrs.size()) {
auto cmd_name = get_elem(0);
_bindDevice->exec(cmd_name);
msg.ack(msg_t::CMD_KEY, cmd_name);
// msg.ack(msg_t::CMD_KEY, cmd_name);
msg.ack(constants::ADC_DEVICE_NETPROTO_KEY_CMD, cmd_name);
} else { // no cmd name!
msg.err(std::make_error_code(AdcDeviceNetServerSessionError::ERROR_NO_PROTO_CMDNAME));
}