[DEV/DEBUG] action signal is working and might be working as generic signaling
This commit is contained in:
parent
4801cb8306
commit
826ac3c053
@ -15,7 +15,7 @@
|
||||
|
||||
|
||||
#include <etk/stdTools.hpp>
|
||||
#include <zeus/test/ProxyService1.hpp>
|
||||
#include <zeus/service/test/ProxyService1.hpp>
|
||||
#include <zeus/ProxyFile.hpp>
|
||||
#include <zeus/ObjectRemote.hpp>
|
||||
#include <echrono/Steady.hpp>
|
||||
@ -99,13 +99,35 @@ int main(int _argc, const char *_argv[]) {
|
||||
for (auto &it: retServiceList.get()) {
|
||||
APPL_INFO(" - " << it);
|
||||
}
|
||||
zeus::test::ProxyService1 srv = client1.getService("service1");
|
||||
if (srv.exist() == true) {
|
||||
auto retCall = srv.getU32(11);
|
||||
retCall.wait();
|
||||
APPL_INFO("value = " << retCall.get());
|
||||
}
|
||||
|
||||
zeus::service::test::ProxyService1 srv = client1.getService("test-service1");
|
||||
if (srv.exist() == false) {
|
||||
APPL_ERROR("can not connect service ... 'test-service1'");
|
||||
} else {
|
||||
{
|
||||
auto retCall = srv.getU32(11);
|
||||
retCall.wait();
|
||||
APPL_INFO("value = " << retCall.get());
|
||||
}
|
||||
{
|
||||
int32_t lasNumberSend = 3000;
|
||||
auto retCall = srv.doSomething(lasNumberSend);
|
||||
int32_t lastValue=0;
|
||||
retCall.onSignal(
|
||||
[&](int32_t _value) {
|
||||
APPL_DEBUG("getSignal : " << _value);
|
||||
if (lastValue+1 != _value) {
|
||||
APPL_ERROR("Send Event Wrong ORDER ... last=" << lastValue << " new=" << _value);
|
||||
}
|
||||
lastValue = _value;
|
||||
});
|
||||
while (lasNumberSend != lastValue) {
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(50));
|
||||
}
|
||||
retCall.wait();
|
||||
APPL_INFO("END (receive " << lastValue << " signals");
|
||||
}
|
||||
}
|
||||
int32_t iii=0;
|
||||
while (iii < 3) {
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
||||
|
@ -28,7 +28,7 @@ def configure(target, my_module):
|
||||
my_module.add_path(".")
|
||||
my_module.add_depend([
|
||||
'zeus',
|
||||
'zeus-test-service1',
|
||||
'zeus-service-test-service1',
|
||||
])
|
||||
my_module.add_src_file([
|
||||
'appl/debug.cpp',
|
||||
|
@ -18,8 +18,8 @@
|
||||
|
||||
#include <etk/stdTools.hpp>
|
||||
|
||||
#include <zeus/test/Service1.hpp>
|
||||
#include <zeus/test/registerService1.hpp>
|
||||
#include <zeus/service/test/Service1.hpp>
|
||||
#include <zeus/service/test/registerService1.hpp>
|
||||
#include <zeus/File.hpp>
|
||||
#include <zeus/ProxyFile.hpp>
|
||||
#include <zeus/zeus-Media.impl.hpp>
|
||||
@ -38,7 +38,7 @@ static uint64_t createUniqueID() {
|
||||
return m_lastMaxId;
|
||||
}
|
||||
namespace appl {
|
||||
class TestService1 : public zeus::test::Service1 {
|
||||
class TestService1 : public zeus::service::test::Service1 {
|
||||
private:
|
||||
std::string m_userName;
|
||||
public:
|
||||
@ -66,6 +66,12 @@ namespace appl {
|
||||
void getVoid() override {
|
||||
// nothing to do ...;
|
||||
}
|
||||
void doSomething(zeus::ActionNotification<int32_t>& _notifs, int32_t _value) override {
|
||||
for (int32_t iii=1; iii<=_value; ++iii) {
|
||||
//std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
||||
_notifs.emit(iii);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@ -117,5 +123,5 @@ ETK_EXPORT_API void SERVICE_IO_peridic_call() {
|
||||
}
|
||||
|
||||
|
||||
ZEUS_TEST_SERVICE1_DECLARE(appl::TestService1);
|
||||
ZEUS_SERVICE_TEST_SERVICE1_DECLARE(appl::TestService1);
|
||||
|
@ -18,3 +18,7 @@ string getString(string)
|
||||
|
||||
void getVoid()
|
||||
|
||||
|
||||
|
||||
[action int32]void doSomething(int32)
|
||||
|
@ -30,11 +30,11 @@ def configure(target, my_module):
|
||||
my_module.add_depend([
|
||||
'zeus',
|
||||
'ejson',
|
||||
'zeus-test-service1'
|
||||
'zeus-service-test-service1'
|
||||
])
|
||||
my_module.add_src_file([
|
||||
'appl/debug.cpp',
|
||||
'appl/main-test-service1.cpp'
|
||||
'appl/main-service-test-service1.cpp'
|
||||
])
|
||||
my_module.add_flag('c++', "-DSERVICE_NAME=\"\\\"test-service1\\\"\"")
|
||||
return True
|
@ -32,7 +32,7 @@ def configure(target, my_module):
|
||||
])
|
||||
|
||||
zeus_macro = macro.load_macro('zeus')
|
||||
zeus_macro.parse_object_idl(my_module, 'appl/zeus-test-service1.srv.zeus.idl')
|
||||
zeus_macro.parse_object_idl(my_module, 'appl/zeus-service-test-service1.srv.zeus.idl')
|
||||
|
||||
my_module.add_flag('c++', "-DSERVICE_NAME=\"\\\"test-service1\\\"\"")
|
||||
return True
|
@ -25,7 +25,7 @@ def configure(target, my_module):
|
||||
my_module.add_depend([
|
||||
'zeus-router',
|
||||
'zeus-gateway',
|
||||
'zeus-test-service1-impl',
|
||||
'zeus-service-test-service1-impl',
|
||||
'zeus-service-user-impl',
|
||||
'zeus-launcher',
|
||||
'zeus-test-client',
|
||||
|
@ -104,9 +104,8 @@ void appl::DirectInterface::receive(ememory::SharedPtr<zeus::Message> _value) {
|
||||
answerProtocolError(transactionId, "Must get first the Client ID... call 'getAddress' and not '" + callObj->getCall() + "'");
|
||||
return;
|
||||
}
|
||||
APPL_INFO("Get the unique ID...");
|
||||
m_uid = m_gateway->getId();
|
||||
APPL_INFO("get ID : " << m_uid);
|
||||
APPL_INFO("clent call getAddress ==> return addresse " << m_uid);
|
||||
if (m_uid == 0) {
|
||||
answerProtocolError(transactionId, "Can not get the Client ID...");
|
||||
return;
|
||||
|
@ -59,7 +59,7 @@ void appl::IOInterface::receive(ememory::SharedPtr<zeus::Message> _value) {
|
||||
if (_value == nullptr) {
|
||||
return;
|
||||
}
|
||||
//APPL_ERROR(" ==> parse DATA ...");
|
||||
APPL_INFO("RECEIVE message " << _value);
|
||||
uint32_t transactionId = _value->getTransactionId();
|
||||
if (transactionId == 0) {
|
||||
APPL_ERROR("Protocol error ==>missing id");
|
||||
@ -79,6 +79,10 @@ void appl::IOInterface::receive(ememory::SharedPtr<zeus::Message> _value) {
|
||||
if (callFunction == "removeRouterClient") {
|
||||
// TODO : Broadcast that an IO is remoed ...
|
||||
m_state = appl::clientState::unconnect;
|
||||
APPL_ERROR("Remote client disconnect ...");
|
||||
zeus::WebServer* iface = getInterface();
|
||||
iface->answerVoid(transactionId, _value->getDestination(), _value->getSource());
|
||||
return;
|
||||
}
|
||||
switch (m_state) {
|
||||
case appl::clientState::disconnect:
|
||||
|
@ -397,7 +397,7 @@ void appl::MediaDecoder::init(ememory::SharedPtr<ClientProperty> _property, uint
|
||||
m_remote->m_fileHandle = _proxy;
|
||||
APPL_WARNING("We have handle");
|
||||
m_remote->m_fileHandle.getSize().andThen(
|
||||
[=](uint64_t _value) {
|
||||
[=](uint64_t _value) mutable {
|
||||
APPL_WARNING("Receive FileSize to index property");
|
||||
APPL_WARNING("pppllloooppp " << _value);
|
||||
m_remote->m_buffer.resize(_value, 0);
|
||||
|
@ -171,7 +171,7 @@ namespace appl {
|
||||
throw std::invalid_argument("Wrong file ID ...");
|
||||
//
|
||||
}
|
||||
uint32_t add(zeus::ActionNotification& _notifs, zeus::ProxyFile _dataFile) override {
|
||||
uint32_t add(zeus::ActionNotification<std::string>& _notifs, zeus::ProxyFile _dataFile) override {
|
||||
//_action.setProgress("{\"pourcent\":" + etk::to_string(23.54) + ", \"comment\":\"Start loading file\"");
|
||||
//_action.setProgress("{\"pourcent\":" + etk::to_string(23.54) + ", \"comment\":\"transfering file\"");;
|
||||
//_action.setProgress("{\"pourcent\":" + etk::to_string(23.54) + ", \"comment\":\"synchronize meta-data\"");
|
||||
|
@ -31,6 +31,7 @@ void zeus::Client::onClientData(ememory::SharedPtr<zeus::Message> _value) {
|
||||
if (_value == nullptr) {
|
||||
return;
|
||||
}
|
||||
ZEUS_DEBUG("receive message : " << _value);
|
||||
// TODO : We will receive here some notification and call ...like :
|
||||
/*
|
||||
if (call && id = 0 && objectid == 0) {
|
||||
@ -118,21 +119,13 @@ void zeus::Client::onClientData(ememory::SharedPtr<zeus::Message> _value) {
|
||||
}
|
||||
m_interfaceWeb->answerError(transactionId, _value->getDestination(), _value->getSource(), "TRANSFER-OWNERSHIP-ERROR");
|
||||
return;
|
||||
}
|
||||
answerProtocolError(transactionId, "interact with client, musty only call: link/unlink/movelink");
|
||||
return;
|
||||
/*
|
||||
} else if (_value->getType() == zeus::message::type::event) {
|
||||
ememory::SharedPtr<zeus::message::Event> eventObj = ememory::staticPointerCast<zeus::message::Event>(_value);
|
||||
std::string callFunction = eventObj->getCall();
|
||||
if (callFunction == "removeInterface") {
|
||||
ZEUS_VERBOSE("Remove Object : " << eventObj);
|
||||
m_interfaceWeb->interfaceRemoved(eventObj->getParameter<std::vector<uint16_t>>(0));
|
||||
} else if (callFunction == "removeInterface") {
|
||||
ZEUS_VERBOSE("Remove Object : " << callObj);
|
||||
m_interfaceWeb->interfaceRemoved(callObj->getParameter<std::vector<uint16_t>>(0));
|
||||
return;
|
||||
}
|
||||
answerProtocolError(transactionId, "interact with client, musty only call: removeInterface");
|
||||
answerProtocolError(transactionId, "interact with client, musty only call: link/unlink/movelink/removeInterface");
|
||||
return;
|
||||
*/
|
||||
}
|
||||
m_interfaceWeb->answerError(transactionId, _value->getDestination(), _value->getSource(), "UNKNOW-ACTION");
|
||||
return;
|
||||
@ -241,6 +234,7 @@ bool zeus::Client::connectTo(const std::string& _address, echrono::Duration _tim
|
||||
|
||||
zeus::Future<uint16_t> retIdentify = call(0, ZEUS_ID_GATEWAY, "getAddress").wait();
|
||||
if (retIdentify.hasError() == true) {
|
||||
ZEUS_ERROR("Has error when getting Address of client ... " << retIdentify.getErrorType() << " ? " << retIdentify.getErrorHelp());
|
||||
disconnect();
|
||||
return false;
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ namespace zeus {
|
||||
* @param[in] _base Generic base Future
|
||||
* @return the reference on the local element
|
||||
*/
|
||||
zeus::Future<ZEUS_RETURN>& operator= (const zeus::FutureBase& _base) {
|
||||
zeus::Future<ZEUS_RETURN, ZEUS_EVENT>& operator= (const zeus::FutureBase& _base) {
|
||||
m_promise = _base.m_promise;
|
||||
return *this;
|
||||
}
|
||||
@ -39,36 +39,36 @@ namespace zeus {
|
||||
* @return requested value
|
||||
*/
|
||||
ZEUS_RETURN get();
|
||||
const Future<ZEUS_RETURN>& wait() const {
|
||||
const Future<ZEUS_RETURN, ZEUS_EVENT>& wait() const {
|
||||
zeus::FutureBase::wait();
|
||||
return *this;
|
||||
}
|
||||
Future<ZEUS_RETURN>& wait() {
|
||||
Future<ZEUS_RETURN, ZEUS_EVENT>& wait() {
|
||||
zeus::FutureBase::wait();
|
||||
return *this;
|
||||
}
|
||||
const Future<ZEUS_RETURN>& waitFor(echrono::Duration _delta = echrono::seconds(30)) const {
|
||||
const Future<ZEUS_RETURN, ZEUS_EVENT>& waitFor(echrono::Duration _delta = echrono::seconds(30)) const {
|
||||
zeus::FutureBase::waitFor(_delta);
|
||||
return *this;
|
||||
}
|
||||
Future<ZEUS_RETURN>& waitFor(echrono::Duration _delta = echrono::seconds(30)) {
|
||||
Future<ZEUS_RETURN, ZEUS_EVENT>& waitFor(echrono::Duration _delta = echrono::seconds(30)) {
|
||||
zeus::FutureBase::waitFor(_delta);
|
||||
return *this;
|
||||
}
|
||||
const Future<ZEUS_RETURN>& waitUntil(echrono::Steady _endTime) const {
|
||||
const Future<ZEUS_RETURN, ZEUS_EVENT>& waitUntil(echrono::Steady _endTime) const {
|
||||
zeus::FutureBase::waitUntil(_endTime);
|
||||
return *this;
|
||||
}
|
||||
Future<ZEUS_RETURN>& waitUntil(echrono::Steady _endTime) {
|
||||
Future<ZEUS_RETURN, ZEUS_EVENT>& waitUntil(echrono::Steady _endTime) {
|
||||
zeus::FutureBase::waitUntil(_endTime);
|
||||
return *this;
|
||||
}
|
||||
using ObserverFut = std::function<bool(zeus::Future<ZEUS_RETURN>)>; //!< Define an Observer: function pointer for the local specific Future
|
||||
using ObserverFut = std::function<bool(zeus::Future<ZEUS_RETURN, ZEUS_EVENT>)>; //!< Define an Observer: function pointer for the local specific Future
|
||||
/**
|
||||
* @brief Attach callback on all return type of value
|
||||
* @param[in] _callback Handle on the function to call in all case
|
||||
*/
|
||||
Future<ZEUS_RETURN>& andAll(ObserverFut _callback) {
|
||||
Future<ZEUS_RETURN, ZEUS_EVENT>& andAll(ObserverFut _callback) {
|
||||
zeus::FutureBase::andAll(
|
||||
[=](zeus::FutureBase _fut) {
|
||||
return _callback(zeus::Future<ZEUS_RETURN>(_fut));
|
||||
@ -81,7 +81,7 @@ namespace zeus {
|
||||
*/
|
||||
/*
|
||||
note : this is anbigous ???
|
||||
Future<ZEUS_RETURN>& andThen(std::function<bool(const ZEUS_RETURN&)> _callback) {
|
||||
Future<ZEUS_RETURN, ZEUS_EVENT>& andThen(std::function<bool(const ZEUS_RETURN&)> _callback) {
|
||||
zeus::FutureBase::andThen(
|
||||
[=](zeus::FutureBase _fut) {
|
||||
zeus::Future<ZEUS_RETURN> tmp(_fut);
|
||||
@ -90,7 +90,7 @@ namespace zeus {
|
||||
return *this;
|
||||
}
|
||||
*/
|
||||
Future<ZEUS_RETURN>& andThen(std::function<bool(ZEUS_RETURN)> _callback) {
|
||||
Future<ZEUS_RETURN, ZEUS_EVENT>& andThen(std::function<bool(ZEUS_RETURN)> _callback) {
|
||||
zeus::FutureBase::andThen(
|
||||
[=](zeus::FutureBase _fut) {
|
||||
return _callback(std::move(zeus::Future<ZEUS_RETURN>(_fut).get()));
|
||||
@ -98,7 +98,7 @@ namespace zeus {
|
||||
return *this;
|
||||
}
|
||||
/*
|
||||
Future<ZEUS_RETURN>& andThen(ObserverFut _callback) {
|
||||
Future<ZEUS_RETURN, ZEUS_EVENT>& andThen(ObserverFut _callback) {
|
||||
zeus::FutureBase::andThen(
|
||||
[=](zeus::FutureBase _fut) {
|
||||
return _callback(zeus::Future<ZEUS_RETURN>(_fut));
|
||||
@ -109,14 +109,16 @@ namespace zeus {
|
||||
* @brief Attach callback on a specific return action (ERROR)
|
||||
* @param[in] _callback Handle on the function to call in case of error on the call
|
||||
*/
|
||||
Future<ZEUS_RETURN>& andElse(ObserverFut _callback) {
|
||||
/*
|
||||
Future<ZEUS_RETURN, ZEUS_EVENT>& andElse(ObserverFut _callback) {
|
||||
zeus::FutureBase::andElse(
|
||||
[=](zeus::FutureBase _fut) {
|
||||
return _callback(zeus::Future<ZEUS_RETURN>(_fut));
|
||||
});
|
||||
return *this;
|
||||
}
|
||||
Future<ZEUS_RETURN>& andElse(std::function<bool(const std::string&, const std::string&)> _callback) {
|
||||
*/
|
||||
Future<ZEUS_RETURN, ZEUS_EVENT>& andElse(std::function<bool(const std::string&, const std::string&)> _callback) {
|
||||
zeus::FutureBase::andElse(
|
||||
[=](zeus::FutureBase _fut) {
|
||||
return _callback(_fut.getErrorType(), _fut.getErrorHelp());
|
||||
@ -128,12 +130,13 @@ namespace zeus {
|
||||
* @param[in] _callback Handle on the function to call in progress information
|
||||
*/
|
||||
// TODO: this is deprecated ...
|
||||
Future<ZEUS_RETURN>& onProgress(Promise::ObserverEvent _callback) {
|
||||
Future<ZEUS_RETURN, ZEUS_EVENT>& onProgress(Promise::ObserverEvent _callback) {
|
||||
zeus::FutureBase::onEvent(_callback);
|
||||
return *this;
|
||||
}
|
||||
//template<typename = std::enable_if<std::is_void<ZEUS_EVENT>::value, false>>
|
||||
Future<ZEUS_RETURN>& onSignal(std::function<void(const ZEUS_EVENT&)> _callback) {
|
||||
/*
|
||||
Future<ZEUS_RETURN, ZEUS_EVENT>& onSignal(std::function<void(const ZEUS_EVENT&)> _callback) {
|
||||
zeus::FutureBase::onEvent(
|
||||
[=](ememory::SharedPtr<zeus::message::Event> _msg) {
|
||||
if (_msg == nullptr) {
|
||||
@ -143,8 +146,9 @@ namespace zeus {
|
||||
});
|
||||
return *this;
|
||||
}
|
||||
*/
|
||||
//template<typename = std::enable_if<std::is_void<ZEUS_EVENT>::value, false>>
|
||||
Future<ZEUS_RETURN>& onSignal(std::function<void(ZEUS_EVENT)> _callback) {
|
||||
Future<ZEUS_RETURN, ZEUS_EVENT>& onSignal(std::function<void(ZEUS_EVENT)> _callback) {
|
||||
zeus::FutureBase::onEvent(
|
||||
[=](ememory::SharedPtr<zeus::message::Event> _msg) {
|
||||
if (_msg == nullptr) {
|
||||
@ -158,8 +162,8 @@ namespace zeus {
|
||||
/**
|
||||
* @brief future template to cast type in a void methode (fallback)
|
||||
*/
|
||||
template<>
|
||||
class Future<void> : public zeus::FutureBase {
|
||||
template<class ZEUS_EVENT>
|
||||
class Future<void, ZEUS_EVENT> : public zeus::FutureBase {
|
||||
public:
|
||||
/**
|
||||
* @brief contructor of the Future with the basic FutureBase
|
||||
@ -174,40 +178,40 @@ namespace zeus {
|
||||
* @param[in] _base Generic base Future
|
||||
* @return the reference on the local element
|
||||
*/
|
||||
zeus::Future<void>& operator= (const zeus::FutureBase& _base) {
|
||||
zeus::Future<void, ZEUS_EVENT>& operator= (const zeus::FutureBase& _base) {
|
||||
m_promise = _base.m_promise;
|
||||
return *this;
|
||||
}
|
||||
const Future<void>& wait() const {
|
||||
const Future<void, ZEUS_EVENT>& wait() const {
|
||||
zeus::FutureBase::wait();
|
||||
return *this;
|
||||
}
|
||||
Future<void>& wait() {
|
||||
Future<void, ZEUS_EVENT>& wait() {
|
||||
zeus::FutureBase::wait();
|
||||
return *this;
|
||||
}
|
||||
const Future<void>& waitFor(echrono::Duration _delta = echrono::seconds(30)) const {
|
||||
const Future<void, ZEUS_EVENT>& waitFor(echrono::Duration _delta = echrono::seconds(30)) const {
|
||||
zeus::FutureBase::waitFor(_delta);
|
||||
return *this;
|
||||
}
|
||||
Future<void>& waitFor(echrono::Duration _delta = echrono::seconds(30)) {
|
||||
Future<void, ZEUS_EVENT>& waitFor(echrono::Duration _delta = echrono::seconds(30)) {
|
||||
zeus::FutureBase::waitFor(_delta);
|
||||
return *this;
|
||||
}
|
||||
const Future<void>& waitUntil(echrono::Steady _endTime) const {
|
||||
const Future<void, ZEUS_EVENT>& waitUntil(echrono::Steady _endTime) const {
|
||||
zeus::FutureBase::waitUntil(_endTime);
|
||||
return *this;
|
||||
}
|
||||
Future<void>& waitUntil(echrono::Steady _endTime) {
|
||||
Future<void, ZEUS_EVENT>& waitUntil(echrono::Steady _endTime) {
|
||||
zeus::FutureBase::waitUntil(_endTime);
|
||||
return *this;
|
||||
}
|
||||
using ObserverFut = std::function<bool(zeus::Future<void>)>; //!< Define an Observer: function pointer for the local specific Future
|
||||
using ObserverFut = std::function<bool(zeus::Future<void, ZEUS_EVENT>)>; //!< Define an Observer: function pointer for the local specific Future
|
||||
/**
|
||||
* @brief Attach callback on all return type of value
|
||||
* @param[in] _callback Handle on the function to call in all case
|
||||
*/
|
||||
Future<void>& andAll(ObserverFut _callback) {
|
||||
Future<void, ZEUS_EVENT>& andAll(ObserverFut _callback) {
|
||||
zeus::FutureBase::andAll(
|
||||
[=](zeus::FutureBase _fut) {
|
||||
return _callback(zeus::Future<void>(_fut));
|
||||
@ -218,31 +222,61 @@ namespace zeus {
|
||||
* @brief Attach callback on a specific return action (SUCESS)
|
||||
* @param[in] _callback Handle on the function to call in case of sucess on the call
|
||||
*/
|
||||
Future<void>& andThen(ObserverFut _callback) {
|
||||
/*
|
||||
Future<void, ZEUS_EVENT>& andThen(ObserverFut _callback) {
|
||||
zeus::FutureBase::andThen(
|
||||
[=](zeus::FutureBase _fut) {
|
||||
return _callback(zeus::Future<void>(_fut));
|
||||
});
|
||||
return *this;
|
||||
}
|
||||
*/
|
||||
Future<void, ZEUS_EVENT>& andThen(std::function<bool()> _callback) {
|
||||
zeus::FutureBase::andThen(
|
||||
[=](zeus::FutureBase _fut) {
|
||||
return _callback();
|
||||
});
|
||||
return *this;
|
||||
}
|
||||
/**
|
||||
* @brief Attach callback on a specific return action (ERROR)
|
||||
* @param[in] _callback Handle on the function to call in case of error on the call
|
||||
*/
|
||||
Future<void>& andElse(ObserverFut _callback) {
|
||||
/*
|
||||
Future<void, ZEUS_EVENT>& andElse(ObserverFut _callback) {
|
||||
zeus::FutureBase::andElse(
|
||||
[=](zeus::FutureBase _fut) {
|
||||
return _callback(zeus::Future<void>(_fut));
|
||||
});
|
||||
return *this;
|
||||
}
|
||||
*/
|
||||
Future<void, ZEUS_EVENT>& andElse(std::function<bool(const std::string&, const std::string&)> _callback) {
|
||||
zeus::FutureBase::andElse(
|
||||
[=](zeus::FutureBase _fut) {
|
||||
return _callback(_fut.getErrorType(), _fut.getErrorHelp());
|
||||
});
|
||||
return *this;
|
||||
}
|
||||
/**
|
||||
* @brief Attach callback on activity of the action if user set some return information
|
||||
* @param[in] _callback Handle on the function to call in progress information
|
||||
*/
|
||||
Future<void>& onEvent(Promise::ObserverEvent _callback) {
|
||||
/*
|
||||
Future<void, ZEUS_EVENT>& onEvent(Promise::ObserverEvent _callback) {
|
||||
zeus::FutureBase::onEvent(_callback);
|
||||
return *this;
|
||||
}
|
||||
*/
|
||||
Future<void, ZEUS_EVENT>& onSignal(std::function<void(ZEUS_EVENT)> _callback) {
|
||||
zeus::FutureBase::onEvent(
|
||||
[=](ememory::SharedPtr<zeus::message::Event> _msg) {
|
||||
if (_msg == nullptr) {
|
||||
return;
|
||||
}
|
||||
_callback(std::move(_msg->getEvent<ZEUS_EVENT>()));
|
||||
});
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -127,17 +127,13 @@ bool zeus::Promise::setMessage(ememory::SharedPtr<zeus::Message> _value) {
|
||||
std::unique_lock<std::mutex> lock(m_mutex);
|
||||
m_receiveTime = echrono::Steady::now();
|
||||
}
|
||||
if (_value->getType() != zeus::message::type::event) {
|
||||
if (_value->getType() == zeus::message::type::event) {
|
||||
std::unique_lock<std::mutex> lock(m_mutex);
|
||||
// notification of a progresion ...
|
||||
if (m_callbackEvent != nullptr) {
|
||||
if (_value == nullptr) {
|
||||
return true;
|
||||
}
|
||||
if (_value->getType() != zeus::message::type::event) {
|
||||
ZEUS_WARNING("No Return value ...");
|
||||
return true;
|
||||
}
|
||||
m_callbackEvent(ememory::staticPointerCast<zeus::message::Event>(_value));
|
||||
return false; // no error
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ uint32_t zeus::WebObj::getFullId() {
|
||||
}
|
||||
|
||||
void zeus::WebObj::receive(ememory::SharedPtr<zeus::Message> _value) {
|
||||
ZEUS_ERROR("Receive a message ==> not implemented magaging ..." << _value);
|
||||
ZEUS_ERROR("Receive a message ==> not implemented messaging ..." << _value);
|
||||
}
|
||||
|
||||
void zeus::WebObj::display() {
|
||||
|
@ -389,7 +389,8 @@ void zeus::WebServer::newMessage(ememory::SharedPtr<zeus::Message> _buffer) {
|
||||
uint64_t tid = _buffer->getTransactionId();
|
||||
// TODO : Check the UDI reaaly utility ...
|
||||
if ( _buffer->getType() == zeus::message::type::answer
|
||||
|| _buffer->getType() == zeus::message::type::data) {
|
||||
|| _buffer->getType() == zeus::message::type::data
|
||||
|| _buffer->getType() == zeus::message::type::event) {
|
||||
std::unique_lock<std::mutex> lock(m_pendingCallMutex);
|
||||
auto it = m_pendingCall.begin();
|
||||
while (it != m_pendingCall.end()) {
|
||||
|
Loading…
Reference in New Issue
Block a user