[DEV] continue integration to simplify user interface, but not work and does not parmit to have object and stream
This commit is contained in:
parent
1d0f1265eb
commit
fac9c55b9e
@ -476,6 +476,7 @@ class ServiceDefinition:
|
|||||||
out += "#pragma once\n"
|
out += "#pragma once\n"
|
||||||
out += "\n"
|
out += "\n"
|
||||||
out += "#include <zeus/ServiceRemote.hpp>\n"
|
out += "#include <zeus/ServiceRemote.hpp>\n"
|
||||||
|
out += "#include <zeus/BaseProxy.hpp>\n"
|
||||||
out += "#include <string>\n"
|
out += "#include <string>\n"
|
||||||
out += "#include <vector>\n"
|
out += "#include <vector>\n"
|
||||||
out += "\n"
|
out += "\n"
|
||||||
@ -495,15 +496,24 @@ class ServiceDefinition:
|
|||||||
out += space + " * authors:" + elem + "\n"
|
out += space + " * authors:" + elem + "\n"
|
||||||
out += space + " */\n"
|
out += space + " */\n"
|
||||||
#out += space + "class Proxy" + self.name[-1] + " : public " + self.name[-1] + " {\n"
|
#out += space + "class Proxy" + self.name[-1] + " : public " + self.name[-1] + " {\n"
|
||||||
out += space + "class Proxy" + self.name[-1] + " {\n"
|
out += space + "class Proxy" + self.name[-1] + " :public zeus::BaseProxy {\n"
|
||||||
space += " "
|
space += " "
|
||||||
out += space + "protected:\n"
|
|
||||||
out += space + " zeus::ServiceRemote m_srv; //!< Service instance handle\n"
|
|
||||||
out += space + "public:\n"
|
out += space + "public:\n"
|
||||||
out += space + " const Proxy" + self.name[-1] + "& operator= (const zeus::ServiceRemote& _srv) {\n"
|
out += space + " const Proxy" + self.name[-1] + "& operator= (const zeus::ServiceRemote& _srv) {\n"
|
||||||
out += space + " m_srv = _srv;\n"
|
out += space + " m_srv = _srv;\n"
|
||||||
out += space + " return *this;\n"
|
out += space + " return *this;\n"
|
||||||
out += space + " }\n"
|
out += space + " }\n"
|
||||||
|
out += space + " ~Proxy" + self.name[-1] + "() = default;\n"
|
||||||
|
out += space + " Proxy" + self.name[-1] + "() = default;\n"
|
||||||
|
out += space + " Proxy" + self.name[-1] + "(const zeus::ServiceRemote& _srv) :\n"
|
||||||
|
out += space + " zeus::BaseProxy(_srv) {\n"
|
||||||
|
out += space + " \n"
|
||||||
|
out += space + " }\n"
|
||||||
|
"""
|
||||||
|
out += space + " bool exist() const {\n"
|
||||||
|
out += space + " return m_srv.exist();\n"
|
||||||
|
out += space + " }\n"
|
||||||
|
"""
|
||||||
out += space + "public:\n"
|
out += space + "public:\n"
|
||||||
space += " "
|
space += " "
|
||||||
"""
|
"""
|
||||||
|
@ -59,6 +59,9 @@ def configure(target, my_module):
|
|||||||
'zeus/ServiceRemote.cpp',
|
'zeus/ServiceRemote.cpp',
|
||||||
'zeus/WebServer.cpp',
|
'zeus/WebServer.cpp',
|
||||||
'zeus/mineType.cpp',
|
'zeus/mineType.cpp',
|
||||||
|
'zeus/BaseProxy.cpp',
|
||||||
|
'zeus/ServiceProxy.cpp',
|
||||||
|
'zeus/SystemProxy.cpp',
|
||||||
])
|
])
|
||||||
my_module.add_header_file([
|
my_module.add_header_file([
|
||||||
'zeus/zeus.hpp',
|
'zeus/zeus.hpp',
|
||||||
@ -85,6 +88,9 @@ def configure(target, my_module):
|
|||||||
'zeus/ServiceRemote.hpp',
|
'zeus/ServiceRemote.hpp',
|
||||||
'zeus/WebServer.hpp',
|
'zeus/WebServer.hpp',
|
||||||
'zeus/mineType.hpp',
|
'zeus/mineType.hpp',
|
||||||
|
'zeus/BaseProxy.hpp',
|
||||||
|
'zeus/ServiceProxy.hpp',
|
||||||
|
'zeus/SystemProxy.hpp',
|
||||||
])
|
])
|
||||||
if target.config["compilator"] == "clang":
|
if target.config["compilator"] == "clang":
|
||||||
my_module.add_flag('c++', "-Wno-unsequenced", export=True)
|
my_module.add_flag('c++', "-Wno-unsequenced", export=True)
|
||||||
|
@ -98,7 +98,7 @@ int main(int _argc, const char *_argv[]) {
|
|||||||
zeus::service::ProxyUser remoteServiceUser;
|
zeus::service::ProxyUser remoteServiceUser;
|
||||||
remoteServiceUser = client1.getService("user");
|
remoteServiceUser = client1.getService("user");
|
||||||
if (remoteServiceUser.exist() == true) {
|
if (remoteServiceUser.exist() == true) {
|
||||||
zeus::Future<std::vector<std::string>> retCall = remoteServiceUser.getGroups("clientTest1#atria-soft.com");
|
zeus::Future<std::vector<std::string>> retCall = remoteServiceUser.clientGroupsGet("clientTest1#atria-soft.com");
|
||||||
retCall.wait();
|
retCall.wait();
|
||||||
APPL_INFO("system-user.getGroups() = " << retCall.get());
|
APPL_INFO("system-user.getGroups() = " << retCall.get());
|
||||||
zeus::Future<std::string> retDesc = remoteServiceUser.sys.getDescription();
|
zeus::Future<std::string> retDesc = remoteServiceUser.sys.getDescription();
|
||||||
@ -143,7 +143,7 @@ int main(int _argc, const char *_argv[]) {
|
|||||||
#else
|
#else
|
||||||
zeus::ServiceRemote remoteServiceUser = client1.getService("user");
|
zeus::ServiceRemote remoteServiceUser = client1.getService("user");
|
||||||
if (remoteServiceUser.exist() == true) {
|
if (remoteServiceUser.exist() == true) {
|
||||||
zeus::Future<std::vector<std::string>> retCall = remoteServiceUser.call("getGroups", "clientTest1#atria-soft.com");
|
zeus::Future<std::vector<std::string>> retCall = remoteServiceUser.call("clientGroupsGet", "clientTest1#atria-soft.com");
|
||||||
retCall.wait();
|
retCall.wait();
|
||||||
APPL_INFO("system-user.getGroups() = " << retCall.get());
|
APPL_INFO("system-user.getGroups() = " << retCall.get());
|
||||||
zeus::Future<std::string> retDesc = remoteServiceUser.call("sys.getDescription");
|
zeus::Future<std::string> retDesc = remoteServiceUser.call("sys.getDescription");
|
||||||
|
@ -53,7 +53,7 @@ bool appl::userSpecificInterface::start(uint32_t _transactionId, appl::GateWay*
|
|||||||
answerProtocolError(_transactionId, "Gateway internal error 'No user interface'");
|
answerProtocolError(_transactionId, "Gateway internal error 'No user interface'");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
zeus::Future<bool> futLocalService = m_userService->m_interfaceClient.callClient(m_localIdUser, "_new", m_userConnectionName, "**Gateway**", std::vector<std::string>());
|
zeus::Future<bool> futLocalService = m_userService->m_interfaceClient.callClient(m_localIdUser, ZEUS_ID_SERVICE_ROOT, "_new", m_userConnectionName, "**Gateway**", std::vector<std::string>());
|
||||||
futLocalService.wait(); // TODO: Set timeout ...
|
futLocalService.wait(); // TODO: Set timeout ...
|
||||||
if (futLocalService.get() == false) {
|
if (futLocalService.get() == false) {
|
||||||
answerProtocolError(_transactionId, "Gateway internal error 'Can not create client in user backend'");
|
answerProtocolError(_transactionId, "Gateway internal error 'Can not create client in user backend'");
|
||||||
@ -146,7 +146,7 @@ void appl::userSpecificInterface::onClientData(ememory::SharedPtr<zeus::Buffer>
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
zeus::Future<bool> fut = m_userService->m_interfaceClient.callClient(m_localIdUser, "checkTocken", clientName, clientTocken);
|
zeus::Future<bool> fut = m_userService->m_interfaceClient.callClient(ZEUS_NO_ID_CLIENT, m_localIdUser, "checkTocken", clientName, clientTocken);
|
||||||
fut.wait(); // TODO: Set timeout ...
|
fut.wait(); // TODO: Set timeout ...
|
||||||
if (fut.hasError() == true) {
|
if (fut.hasError() == true) {
|
||||||
APPL_ERROR("Get error from the service ...");
|
APPL_ERROR("Get error from the service ...");
|
||||||
@ -162,7 +162,7 @@ void appl::userSpecificInterface::onClientData(ememory::SharedPtr<zeus::Buffer>
|
|||||||
}
|
}
|
||||||
if (callFunction == "auth") {
|
if (callFunction == "auth") {
|
||||||
std::string password = callObj->getParameter<std::string>(0);
|
std::string password = callObj->getParameter<std::string>(0);
|
||||||
zeus::Future<bool> fut = m_userService->m_interfaceClient.callClient(m_localIdUser, "checkAuth", password);
|
zeus::Future<bool> fut = m_userService->m_interfaceClient.callClient(ZEUS_NO_ID_CLIENT, m_localIdUser, "checkAuth", password);
|
||||||
fut.wait(); // TODO: Set timeout ...
|
fut.wait(); // TODO: Set timeout ...
|
||||||
if (fut.hasError() == true) {
|
if (fut.hasError() == true) {
|
||||||
APPL_ERROR("Get error from the service ...");
|
APPL_ERROR("Get error from the service ...");
|
||||||
@ -182,7 +182,7 @@ void appl::userSpecificInterface::onClientData(ememory::SharedPtr<zeus::Buffer>
|
|||||||
// --------------------------------
|
// --------------------------------
|
||||||
// -- Get groups:
|
// -- Get groups:
|
||||||
// --------------------------------
|
// --------------------------------
|
||||||
zeus::Future<std::vector<std::string>> futGroup = m_userService->m_interfaceClient.callClient(m_localIdUser, "clientGroupsGet", m_clientName);
|
zeus::Future<std::vector<std::string>> futGroup = m_userService->m_interfaceClient.callClient(ZEUS_NO_ID_CLIENT, m_localIdUser, "clientGroupsGet", m_clientName);
|
||||||
futGroup.wait(); // TODO: Set timeout ...
|
futGroup.wait(); // TODO: Set timeout ...
|
||||||
if (futGroup.hasError() == true) {
|
if (futGroup.hasError() == true) {
|
||||||
APPL_ERROR("Get error from the service ...");
|
APPL_ERROR("Get error from the service ...");
|
||||||
@ -195,7 +195,7 @@ void appl::userSpecificInterface::onClientData(ememory::SharedPtr<zeus::Buffer>
|
|||||||
// -- Get services:
|
// -- Get services:
|
||||||
// --------------------------------
|
// --------------------------------
|
||||||
std::vector<std::string> currentServices = m_gatewayInterface->getAllServiceName();
|
std::vector<std::string> currentServices = m_gatewayInterface->getAllServiceName();
|
||||||
zeus::Future<std::vector<std::string>> futServices = m_userService->m_interfaceClient.callClient(m_localIdUser, "filterClientServices", m_clientName, currentServices);
|
zeus::Future<std::vector<std::string>> futServices = m_userService->m_interfaceClient.callClient(ZEUS_NO_ID_CLIENT, m_localIdUser, "filterClientServices", m_clientName, currentServices);
|
||||||
futServices.wait(); // TODO: Set timeout ...
|
futServices.wait(); // TODO: Set timeout ...
|
||||||
if (futServices.hasError() == true) {
|
if (futServices.hasError() == true) {
|
||||||
APPL_ERROR("Get error from the service ...");
|
APPL_ERROR("Get error from the service ...");
|
||||||
@ -232,6 +232,7 @@ void appl::userSpecificInterface::onClientData(ememory::SharedPtr<zeus::Buffer>
|
|||||||
if (callFunction == "link") {
|
if (callFunction == "link") {
|
||||||
// first param:
|
// first param:
|
||||||
std::string serviceName = callObj->getParameter<std::string>(0);
|
std::string serviceName = callObj->getParameter<std::string>(0);
|
||||||
|
ZEUS_ERROR("Connect to service : " << serviceName << " " << m_uid);
|
||||||
// Check if service already link:
|
// Check if service already link:
|
||||||
auto it = m_listConnectedService.begin();
|
auto it = m_listConnectedService.begin();
|
||||||
while (it != m_listConnectedService.end()) {
|
while (it != m_listConnectedService.end()) {
|
||||||
@ -253,7 +254,7 @@ void appl::userSpecificInterface::onClientData(ememory::SharedPtr<zeus::Buffer>
|
|||||||
}
|
}
|
||||||
ememory::SharedPtr<appl::ServiceInterface> srv = m_gatewayInterface->get(serviceName);
|
ememory::SharedPtr<appl::ServiceInterface> srv = m_gatewayInterface->get(serviceName);
|
||||||
if (srv != nullptr) {
|
if (srv != nullptr) {
|
||||||
zeus::Future<bool> futLink = srv->m_interfaceClient.callClient(m_uid, "_new", m_userConnectionName, m_clientName, m_clientgroups);
|
zeus::Future<bool> futLink = srv->m_interfaceClient.callClient(ZEUS_NO_ID_CLIENT, m_uid, "_new", m_userConnectionName, m_clientName, m_clientgroups);
|
||||||
futLink.wait(); // TODO: Set timeout ...
|
futLink.wait(); // TODO: Set timeout ...
|
||||||
if (futLink.hasError() == true) {
|
if (futLink.hasError() == true) {
|
||||||
APPL_ERROR("Get error from the service ... LINK");
|
APPL_ERROR("Get error from the service ... LINK");
|
||||||
@ -261,6 +262,7 @@ void appl::userSpecificInterface::onClientData(ememory::SharedPtr<zeus::Buffer>
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_listConnectedService.push_back(srv);
|
m_listConnectedService.push_back(srv);
|
||||||
|
ZEUS_ERROR(" ==> get ID : " << m_uid);
|
||||||
m_interfaceRouterClient->answerValue(transactionId, m_listConnectedService.size(), m_uid);
|
m_interfaceRouterClient->answerValue(transactionId, m_listConnectedService.size(), m_uid);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -271,6 +273,7 @@ void appl::userSpecificInterface::onClientData(ememory::SharedPtr<zeus::Buffer>
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (callFunction == "unlink") {
|
if (callFunction == "unlink") {
|
||||||
|
ZEUS_ERROR("Disconnnect from service : " << m_uid);
|
||||||
// first param: the service we want to unconnect ...
|
// first param: the service we want to unconnect ...
|
||||||
int64_t localServiceID = callObj->getParameter<int64_t>(0)-1;
|
int64_t localServiceID = callObj->getParameter<int64_t>(0)-1;
|
||||||
// Check if service already link:
|
// Check if service already link:
|
||||||
@ -278,7 +281,7 @@ void appl::userSpecificInterface::onClientData(ememory::SharedPtr<zeus::Buffer>
|
|||||||
m_interfaceRouterClient->answerError(transactionId, "NOT-CONNECTED-SERVICE");
|
m_interfaceRouterClient->answerError(transactionId, "NOT-CONNECTED-SERVICE");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
zeus::Future<bool> futUnLink = m_listConnectedService[localServiceID]->m_interfaceClient.callClient(m_uid, "_delete");
|
zeus::Future<bool> futUnLink = m_listConnectedService[localServiceID]->m_interfaceClient.callClient(ZEUS_NO_ID_CLIENT, m_uid, "_delete");
|
||||||
futUnLink.wait(); // TODO: Set timeout ...
|
futUnLink.wait(); // TODO: Set timeout ...
|
||||||
if (futUnLink.hasError() == true) {
|
if (futUnLink.hasError() == true) {
|
||||||
APPL_ERROR("Get error from the service ... UNLINK");
|
APPL_ERROR("Get error from the service ... UNLINK");
|
||||||
|
@ -5,7 +5,7 @@ import lutin.macro as macro
|
|||||||
|
|
||||||
|
|
||||||
def get_type():
|
def get_type():
|
||||||
return "LIBRARY_DYNAMIC"
|
return "LIBRARY"
|
||||||
#return "BINARY"
|
#return "BINARY"
|
||||||
|
|
||||||
def get_sub_type():
|
def get_sub_type():
|
||||||
|
@ -38,6 +38,7 @@ namespace appl {
|
|||||||
}
|
}
|
||||||
public:
|
public:
|
||||||
std::vector<std::string> clientGroupsGet(std::string _clientName) {
|
std::vector<std::string> clientGroupsGet(std::string _clientName) {
|
||||||
|
APPL_WARNING("call clientGroupsGet : " << _clientName);
|
||||||
std::vector<std::string> out;
|
std::vector<std::string> out;
|
||||||
if (m_client == nullptr) {
|
if (m_client == nullptr) {
|
||||||
return out;
|
return out;
|
||||||
|
@ -5,7 +5,7 @@ import lutin.macro as macro
|
|||||||
|
|
||||||
|
|
||||||
def get_type():
|
def get_type():
|
||||||
return "LIBRARY_DYNAMIC"
|
return "LIBRARY"
|
||||||
#return "BINARY"
|
#return "BINARY"
|
||||||
|
|
||||||
def get_sub_type():
|
def get_sub_type():
|
||||||
|
@ -5,7 +5,7 @@ import lutin.macro as macro
|
|||||||
|
|
||||||
|
|
||||||
def get_type():
|
def get_type():
|
||||||
return "LIBRARY_DYNAMIC"
|
return "LIBRARY"
|
||||||
#return "BINARY"
|
#return "BINARY"
|
||||||
|
|
||||||
def get_sub_type():
|
def get_sub_type():
|
||||||
|
27
zeus/BaseProxy.cpp
Normal file
27
zeus/BaseProxy.cpp
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
/** @file
|
||||||
|
* @author Edouard DUPIN
|
||||||
|
* @copyright 2016, Edouard DUPIN, all right reserved
|
||||||
|
* @license APACHE v2.0 (see license file)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <zeus/BaseProxy.hpp>
|
||||||
|
#include <zeus/debug.hpp>
|
||||||
|
|
||||||
|
const zeus::BaseProxy& zeus::BaseProxy::operator= (const zeus::ServiceRemote& _srv) {
|
||||||
|
m_srv = _srv;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
zeus::BaseProxy::BaseProxy():
|
||||||
|
sys(m_srv),
|
||||||
|
srv(m_srv) {
|
||||||
|
|
||||||
|
}
|
||||||
|
zeus::BaseProxy::BaseProxy(const zeus::ServiceRemote& _srv):
|
||||||
|
m_srv(_srv),
|
||||||
|
sys(m_srv),
|
||||||
|
srv(m_srv) {
|
||||||
|
|
||||||
|
}
|
||||||
|
bool zeus::BaseProxy::exist() const {
|
||||||
|
return m_srv.exist();
|
||||||
|
}
|
29
zeus/BaseProxy.hpp
Normal file
29
zeus/BaseProxy.hpp
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
/** @file
|
||||||
|
* @author Edouard DUPIN
|
||||||
|
* @copyright 2016, Edouard DUPIN, all right reserved
|
||||||
|
* @license APACHE v2.0 (see license file)
|
||||||
|
*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <zeus/ServiceRemote.hpp>
|
||||||
|
#include <zeus/ServiceProxy.hpp>
|
||||||
|
#include <zeus/SystemProxy.hpp>
|
||||||
|
|
||||||
|
namespace zeus {
|
||||||
|
/**
|
||||||
|
* @brief Proxy base interface
|
||||||
|
*/
|
||||||
|
class BaseProxy {
|
||||||
|
protected:
|
||||||
|
zeus::ServiceRemote m_srv; //!< Service instance handle
|
||||||
|
public:
|
||||||
|
zeus::SystemProxy sys;
|
||||||
|
zeus::ServiceProxy srv;
|
||||||
|
public:
|
||||||
|
const BaseProxy& operator= (const zeus::ServiceRemote& _srv);
|
||||||
|
BaseProxy();
|
||||||
|
virtual ~BaseProxy() = default;
|
||||||
|
BaseProxy(const zeus::ServiceRemote& _srv);
|
||||||
|
bool exist() const;
|
||||||
|
};
|
||||||
|
}
|
@ -28,7 +28,21 @@ void zeus::Client::onClientData(ememory::SharedPtr<zeus::Buffer> _value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
zeus::ServiceRemote zeus::Client::getService(const std::string& _name) {
|
zeus::ServiceRemote zeus::Client::getService(const std::string& _name) {
|
||||||
return zeus::ServiceRemote(m_interfaceClient, _name);
|
ZEUS_TODO("Lock here");
|
||||||
|
auto it = m_listConnectedService.begin();
|
||||||
|
while (it != m_listConnectedService.end()) {
|
||||||
|
ememory::SharedPtr<zeus::ServiceRemoteBase> val = it->lock();
|
||||||
|
if (val == nullptr) {
|
||||||
|
it = m_listConnectedService.erase(it);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (val->getName() == _name) {
|
||||||
|
return zeus::ServiceRemote(val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ememory::SharedPtr<zeus::ServiceRemoteBase> tmp = ememory::makeShared<zeus::ServiceRemoteBase>(m_interfaceClient, _name);
|
||||||
|
m_listConnectedService.push_back(tmp);
|
||||||
|
return zeus::ServiceRemote(tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void zeus::Client::onPropertyChangeIp() {
|
void zeus::Client::onPropertyChangeIp() {
|
||||||
|
@ -24,6 +24,7 @@ namespace zeus {
|
|||||||
eproperty::Value<uint16_t> propertyPort; //!< Port of the WebSocket connection
|
eproperty::Value<uint16_t> propertyPort; //!< Port of the WebSocket connection
|
||||||
private:
|
private:
|
||||||
ememory::SharedPtr<zeus::WebServer> m_interfaceClient; //!< Interface on the Websocket interface
|
ememory::SharedPtr<zeus::WebServer> m_interfaceClient; //!< Interface on the Websocket interface
|
||||||
|
std::vector<ememory::WeakPtr<zeus::ServiceRemoteBase>> m_listConnectedService; //!< Connect only one time on each service, not needed more.
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* @brief Create a client on a specific user in a client mode with the tocken associated
|
* @brief Create a client on a specific user in a client mode with the tocken associated
|
||||||
|
@ -40,6 +40,12 @@ namespace zeus {
|
|||||||
* @param[in] _clientId Client/sevice Id waiting answer
|
* @param[in] _clientId Client/sevice Id waiting answer
|
||||||
*/
|
*/
|
||||||
FutureBase(uint32_t _transactionId, ememory::SharedPtr<zeus::Buffer> _returnData, zeus::FutureData::ObserverFinish _callback=nullptr, uint32_t _clientId=0);
|
FutureBase(uint32_t _transactionId, ememory::SharedPtr<zeus::Buffer> _returnData, zeus::FutureData::ObserverFinish _callback=nullptr, uint32_t _clientId=0);
|
||||||
|
// TODO: Add this to have generic nec C++ interface:
|
||||||
|
/*
|
||||||
|
void andThen(zeus::FutureData::ObserverFinish _callback); // no error in the return
|
||||||
|
void andElse(zeus::FutureData::ObserverFinish _callback); // an error occured in the return
|
||||||
|
void andAbort(zeus::FutureData::ObserverFinish _callback); // an abort is requested in the actiron ...
|
||||||
|
*/
|
||||||
/**
|
/**
|
||||||
* @brief Asignement operator with an other future
|
* @brief Asignement operator with an other future
|
||||||
* @param[in] _base Generic base Future
|
* @param[in] _base Generic base Future
|
||||||
|
@ -190,5 +190,6 @@ std::string zeus::RemoteProcessCall::getFunctionDescription(std::string _funcNam
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool zeus::RemoteProcessCall::isFunctionAuthorized(uint64_t _clientSessionID, const std::string& _funcName) {
|
bool zeus::RemoteProcessCall::isFunctionAuthorized(uint64_t _clientSessionID, const std::string& _funcName) {
|
||||||
|
ZEUS_ERROR("lllllllllllllllllllllllllllllllllllllllllllllllllllllllllll");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -136,21 +136,27 @@ void zeus::Service::pingIsAlive() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void zeus::Service::callBinary(ememory::SharedPtr<zeus::Buffer> _obj) {
|
void zeus::Service::callBinary(ememory::SharedPtr<zeus::Buffer> _obj) {
|
||||||
|
ZEUS_INFO("plop 1 ...");
|
||||||
if (_obj == nullptr) {
|
if (_obj == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
ZEUS_INFO("plop 2 ...");
|
||||||
if (_obj->getType() == zeus::Buffer::typeMessage::event) {
|
if (_obj->getType() == zeus::Buffer::typeMessage::event) {
|
||||||
ZEUS_ERROR("Unknow event: '...'");
|
ZEUS_ERROR("Unknow event: '...'");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
ZEUS_INFO("plop 3 ...");
|
||||||
if (_obj->getType() == zeus::Buffer::typeMessage::answer) {
|
if (_obj->getType() == zeus::Buffer::typeMessage::answer) {
|
||||||
ZEUS_ERROR("Local Answer: '...'");
|
ZEUS_ERROR("Local Answer: '...'");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
ZEUS_INFO("plop 4 ...");
|
||||||
if (_obj->getType() == zeus::Buffer::typeMessage::call) {
|
if (_obj->getType() == zeus::Buffer::typeMessage::call) {
|
||||||
|
ZEUS_INFO("plop 5 ... ");
|
||||||
ememory::SharedPtr<zeus::BufferCall> callObj = ememory::staticPointerCast<zeus::BufferCall>(_obj);
|
ememory::SharedPtr<zeus::BufferCall> callObj = ememory::staticPointerCast<zeus::BufferCall>(_obj);
|
||||||
uint32_t clientId = callObj->getClientId();
|
uint32_t clientId = callObj->getClientId();
|
||||||
std::string callFunction = callObj->getCall();
|
std::string callFunction = callObj->getCall();
|
||||||
|
ZEUS_INFO("plop - ... " << callFunction);
|
||||||
if (callFunction[0] == '_') {
|
if (callFunction[0] == '_') {
|
||||||
if (callFunction == "_new") {
|
if (callFunction == "_new") {
|
||||||
std::string userName = callObj->getParameter<std::string>(0);
|
std::string userName = callObj->getParameter<std::string>(0);
|
||||||
@ -163,9 +169,11 @@ void zeus::Service::callBinary(ememory::SharedPtr<zeus::Buffer> _obj) {
|
|||||||
m_interfaceClient->answerValue(callObj->getTransactionId(), true, clientId);
|
m_interfaceClient->answerValue(callObj->getTransactionId(), true, clientId);
|
||||||
return;
|
return;
|
||||||
} else if (isFunctionAuthorized(clientId, callFunction) == true) {
|
} else if (isFunctionAuthorized(clientId, callFunction) == true) {
|
||||||
|
ZEUS_INFO("plop 6 ...");
|
||||||
callBinary2(callFunction, callObj);
|
callBinary2(callFunction, callObj);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
|
ZEUS_INFO("plop 7 ...");
|
||||||
m_interfaceClient->answerError(callObj->getTransactionId(), "NOT-AUTHORIZED-FUNCTION", "", clientId);
|
m_interfaceClient->answerError(callObj->getTransactionId(), "NOT-AUTHORIZED-FUNCTION", "", clientId);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -89,6 +89,7 @@ namespace zeus {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
bool isFunctionAuthorized(const std::string& _funcName) {
|
bool isFunctionAuthorized(const std::string& _funcName) {
|
||||||
|
ZEUS_ERROR("plop: " << _funcName << " " << m_listAthorizedFunction);
|
||||||
return std::find(m_listAthorizedFunction.begin(), m_listAthorizedFunction.end(), _funcName) != m_listAthorizedFunction.end();
|
return std::find(m_listAthorizedFunction.begin(), m_listAthorizedFunction.end(), _funcName) != m_listAthorizedFunction.end();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -296,6 +297,7 @@ namespace zeus {
|
|||||||
bool isFunctionAuthorized(uint64_t _clientId, const std::string& _funcName) {
|
bool isFunctionAuthorized(uint64_t _clientId, const std::string& _funcName) {
|
||||||
auto it = m_interface.find(_clientId);
|
auto it = m_interface.find(_clientId);
|
||||||
if (it == m_interface.end()) {
|
if (it == m_interface.end()) {
|
||||||
|
ZEUS_ERROR("CLIENT does not exist ... " << _clientId << " " << _funcName);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return it->second.first->isFunctionAuthorized(_funcName);
|
return it->second.first->isFunctionAuthorized(_funcName);
|
||||||
|
16
zeus/ServiceProxy.cpp
Normal file
16
zeus/ServiceProxy.cpp
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
/** @file
|
||||||
|
* @author Edouard DUPIN
|
||||||
|
* @copyright 2016, Edouard DUPIN, all right reserved
|
||||||
|
* @license APACHE v2.0 (see license file)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <zeus/ServiceProxy.hpp>
|
||||||
|
|
||||||
|
zeus::ServiceProxy::ServiceProxy(zeus::ServiceRemote& _srv):
|
||||||
|
m_srv(_srv) {
|
||||||
|
|
||||||
|
}
|
||||||
|
zeus::Future<std::vector<std::string>> zeus::ServiceProxy::getExtention() {
|
||||||
|
return m_srv.call("srv.getExtention");
|
||||||
|
}
|
||||||
|
|
22
zeus/ServiceProxy.hpp
Normal file
22
zeus/ServiceProxy.hpp
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
/** @file
|
||||||
|
* @author Edouard DUPIN
|
||||||
|
* @copyright 2016, Edouard DUPIN, all right reserved
|
||||||
|
* @license APACHE v2.0 (see license file)
|
||||||
|
*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <zeus/ServiceRemote.hpp>
|
||||||
|
|
||||||
|
namespace zeus {
|
||||||
|
class ServiceProxy {
|
||||||
|
protected:
|
||||||
|
zeus::ServiceRemote& m_srv; //!< Service instance handle
|
||||||
|
public:
|
||||||
|
ServiceProxy(zeus::ServiceRemote& _srv);
|
||||||
|
/**
|
||||||
|
* @brief Get the list of extention of this service
|
||||||
|
* @return List of all extention availlable
|
||||||
|
*/
|
||||||
|
virtual zeus::Future<std::vector<std::string>> getExtention();
|
||||||
|
};
|
||||||
|
}
|
@ -7,7 +7,7 @@
|
|||||||
#include <zeus/ServiceRemote.hpp>
|
#include <zeus/ServiceRemote.hpp>
|
||||||
#include <zeus/Client.hpp>
|
#include <zeus/Client.hpp>
|
||||||
|
|
||||||
zeus::ServiceRemote::ServiceRemote(ememory::SharedPtr<zeus::WebServer> _clientLink, const std::string& _name):
|
zeus::ServiceRemoteBase::ServiceRemoteBase(ememory::SharedPtr<zeus::WebServer> _clientLink, const std::string& _name):
|
||||||
m_interfaceClient(_clientLink),
|
m_interfaceClient(_clientLink),
|
||||||
m_name(_name),
|
m_name(_name),
|
||||||
m_serviceId(0),
|
m_serviceId(0),
|
||||||
@ -16,7 +16,7 @@ zeus::ServiceRemote::ServiceRemote(ememory::SharedPtr<zeus::WebServer> _clientLi
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// little hack : Call the service manager with the service ID=0 ...
|
// little hack : Call the service manager with the service ID=0 ...
|
||||||
zeus::Future<uint32_t> ret = call("link", _name);
|
zeus::Future<uint32_t> ret = m_interfaceClient->callService(ZEUS_NO_ID_CLIENT, m_serviceId, "link", _name);
|
||||||
ret.wait();
|
ret.wait();
|
||||||
if (ret.hasError() == true) {
|
if (ret.hasError() == true) {
|
||||||
ZEUS_WARNING("Can not link with the service named: '" << _name << "' ==> link error");
|
ZEUS_WARNING("Can not link with the service named: '" << _name << "' ==> link error");
|
||||||
@ -26,12 +26,12 @@ zeus::ServiceRemote::ServiceRemote(ememory::SharedPtr<zeus::WebServer> _clientLi
|
|||||||
m_serviceId = ret.get();
|
m_serviceId = ret.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
zeus::ServiceRemote::~ServiceRemote() {
|
zeus::ServiceRemoteBase::~ServiceRemoteBase() {
|
||||||
if (m_isLinked == true) {
|
if (m_isLinked == true) {
|
||||||
uint32_t tmpLocalService = m_serviceId;
|
uint32_t tmpLocalService = m_serviceId;
|
||||||
// little hack : Call the service manager with the service ID=0 ...
|
// little hack : Call the service manager with the service ID=0 ...
|
||||||
m_serviceId = 0;
|
m_serviceId = 0;
|
||||||
zeus::Future<bool> ret = call("unlink", tmpLocalService);
|
zeus::Future<bool> ret = m_interfaceClient->callService(ZEUS_NO_ID_CLIENT, m_serviceId, "unlink", tmpLocalService);
|
||||||
ret.wait();
|
ret.wait();
|
||||||
if (ret.hasError() == true) {
|
if (ret.hasError() == true) {
|
||||||
ZEUS_WARNING("Can not unlink with the service id: '" << tmpLocalService << "' ==> link error");
|
ZEUS_WARNING("Can not unlink with the service id: '" << tmpLocalService << "' ==> link error");
|
||||||
@ -47,7 +47,29 @@ zeus::ServiceRemote::~ServiceRemote() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool zeus::ServiceRemote::exist() {
|
bool zeus::ServiceRemoteBase::exist() const {
|
||||||
return m_isLinked;
|
return m_isLinked;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const std::string& zeus::ServiceRemoteBase::getName() const {
|
||||||
|
return m_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
zeus::ServiceRemote::ServiceRemote(ememory::SharedPtr<zeus::ServiceRemoteBase> _interface):
|
||||||
|
m_interface(_interface) {
|
||||||
|
if (m_interface == nullptr) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
zeus::ServiceRemote::~ServiceRemote() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool zeus::ServiceRemote::exist() const {
|
||||||
|
if (m_interface == nullptr) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return m_interface->m_isLinked;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -14,12 +14,14 @@
|
|||||||
|
|
||||||
namespace zeus {
|
namespace zeus {
|
||||||
class Client;
|
class Client;
|
||||||
|
class ServiceRemote;
|
||||||
/**
|
/**
|
||||||
* @brief
|
* @brief
|
||||||
* @param[in]
|
* @param[in]
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
class ServiceRemote {
|
class ServiceRemoteBase {
|
||||||
|
friend class ServiceRemote;
|
||||||
private:
|
private:
|
||||||
ememory::SharedPtr<zeus::WebServer> m_interfaceClient;
|
ememory::SharedPtr<zeus::WebServer> m_interfaceClient;
|
||||||
std::string m_name;
|
std::string m_name;
|
||||||
@ -31,7 +33,47 @@ namespace zeus {
|
|||||||
* @param[in]
|
* @param[in]
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
ServiceRemote(ememory::SharedPtr<zeus::WebServer> _clientLink, const std::string& _name);
|
ServiceRemoteBase() = default;
|
||||||
|
/**
|
||||||
|
* @brief
|
||||||
|
* @param[in]
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
ServiceRemoteBase(ememory::SharedPtr<zeus::WebServer> _clientLink, const std::string& _name);
|
||||||
|
/**
|
||||||
|
* @brief
|
||||||
|
* @param[in]
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
~ServiceRemoteBase();
|
||||||
|
/**
|
||||||
|
* @brief
|
||||||
|
* @param[in]
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
bool exist() const;
|
||||||
|
/**
|
||||||
|
* @brief
|
||||||
|
* @param[in]
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
const std::string& getName() const;
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* @brief
|
||||||
|
* @param[in]
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
class ServiceRemote {
|
||||||
|
private:
|
||||||
|
ememory::SharedPtr<zeus::ServiceRemoteBase> m_interface;
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* @brief
|
||||||
|
* @param[in]
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
ServiceRemote(ememory::SharedPtr<zeus::ServiceRemoteBase> _interface = nullptr);
|
||||||
/**
|
/**
|
||||||
* @brief
|
* @brief
|
||||||
* @param[in]
|
* @param[in]
|
||||||
@ -43,7 +85,7 @@ namespace zeus {
|
|||||||
* @param[in]
|
* @param[in]
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
bool exist();
|
bool exist() const;
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* @brief
|
* @brief
|
||||||
@ -52,31 +94,38 @@ namespace zeus {
|
|||||||
*/
|
*/
|
||||||
template<class... _ARGS>
|
template<class... _ARGS>
|
||||||
zeus::FutureBase call(const std::string& _functionName, _ARGS&&... _args) {
|
zeus::FutureBase call(const std::string& _functionName, _ARGS&&... _args) {
|
||||||
if (m_interfaceClient == nullptr) {
|
|
||||||
|
if ( m_interface == nullptr
|
||||||
|
|| m_interface->m_interfaceClient == nullptr) {
|
||||||
ememory::SharedPtr<zeus::BufferAnswer> ret = zeus::BufferAnswer::create();
|
ememory::SharedPtr<zeus::BufferAnswer> ret = zeus::BufferAnswer::create();
|
||||||
if (ret != nullptr) {
|
if (ret != nullptr) {
|
||||||
ret->addError("NULLPTR", "call " + _functionName + " with no interface open");
|
ret->addError("NULLPTR", "call " + _functionName + " with no interface open");
|
||||||
}
|
}
|
||||||
return zeus::FutureBase(0, ret);
|
return zeus::FutureBase(0, ret);
|
||||||
}
|
}
|
||||||
return m_interfaceClient->callService(m_serviceId, _functionName, _args...);
|
return m_interface->m_interfaceClient->callService(ZEUS_NO_ID_CLIENT, m_interface->m_serviceId, _functionName, _args...);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @brief
|
* @brief
|
||||||
* @param[in]
|
* @param[in]
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
// TODO: Remove the callback to add it in future with the "then(_callback)" and "else(_callback)" and "abort(_callbacl)" ...
|
||||||
template<class... _ARGS>
|
template<class... _ARGS>
|
||||||
zeus::FutureBase callAction(const std::string& _functionName, _ARGS&&... _args, zeus::FutureData::ObserverFinish _callback) {
|
zeus::FutureBase callAction(const std::string& _functionName, _ARGS&&... _args, zeus::FutureData::ObserverFinish _callback) {
|
||||||
if (m_interfaceClient == nullptr) {
|
if ( m_interface == nullptr
|
||||||
|
|| m_interface->m_interfaceClient == nullptr) {
|
||||||
ememory::SharedPtr<zeus::BufferAnswer> ret = zeus::BufferAnswer::create();
|
ememory::SharedPtr<zeus::BufferAnswer> ret = zeus::BufferAnswer::create();
|
||||||
if (ret != nullptr) {
|
if (ret != nullptr) {
|
||||||
ret->addError("NULLPTR", "call " + _functionName + " with no interface open");
|
ret->addError("NULLPTR", "call " + _functionName + " with no interface open");
|
||||||
}
|
}
|
||||||
return zeus::FutureBase(0, ret, _callback);
|
return zeus::FutureBase(0, ret, _callback);
|
||||||
}
|
}
|
||||||
return m_interfaceClient->callServiceAction(m_serviceId, _functionName, _args..., _callback);
|
return m_interface->m_interfaceClient->callServiceAction(ZEUS_NO_ID_CLIENT, m_interface->m_serviceId, _functionName, _args..., _callback);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
45
zeus/SystemProxy.cpp
Normal file
45
zeus/SystemProxy.cpp
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
/** @file
|
||||||
|
* @author Edouard DUPIN
|
||||||
|
* @copyright 2016, Edouard DUPIN, all right reserved
|
||||||
|
* @license APACHE v2.0 (see license file)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <zeus/SystemProxy.hpp>
|
||||||
|
|
||||||
|
zeus::SystemProxy::SystemProxy(zeus::ServiceRemote& _srv):
|
||||||
|
m_srv(_srv) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
zeus::Future<std::string> zeus::SystemProxy::getDescription() {
|
||||||
|
return m_srv.call("sys.getDescription");
|
||||||
|
}
|
||||||
|
|
||||||
|
zeus::Future<std::string> zeus::SystemProxy::getVersion() {
|
||||||
|
return m_srv.call("sys.getVersion");
|
||||||
|
}
|
||||||
|
|
||||||
|
zeus::Future<std::string> zeus::SystemProxy::getType() {
|
||||||
|
return m_srv.call("sys.getType");
|
||||||
|
}
|
||||||
|
|
||||||
|
zeus::Future<std::vector<std::string>> zeus::SystemProxy::getExtention() {
|
||||||
|
return m_srv.call("sys.getExtention");
|
||||||
|
}
|
||||||
|
|
||||||
|
zeus::Future<std::vector<std::string>> zeus::SystemProxy::getAuthors() {
|
||||||
|
return m_srv.call("sys.getAuthors");
|
||||||
|
}
|
||||||
|
|
||||||
|
zeus::Future<std::vector<std::string>> zeus::SystemProxy::getFunctions() {
|
||||||
|
return m_srv.call("sys.getFunctions");
|
||||||
|
}
|
||||||
|
|
||||||
|
zeus::Future<std::string> zeus::SystemProxy::getFunctionPrototype(std::string _functionName) {
|
||||||
|
return m_srv.call("sys.getFunctionPrototype", _functionName);
|
||||||
|
}
|
||||||
|
|
||||||
|
zeus::Future<std::string> zeus::SystemProxy::getFunctionDescription(std::string _functionName) {
|
||||||
|
return m_srv.call("sys.getFunctionDescription", _functionName);
|
||||||
|
}
|
||||||
|
|
26
zeus/SystemProxy.hpp
Normal file
26
zeus/SystemProxy.hpp
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
/** @file
|
||||||
|
* @author Edouard DUPIN
|
||||||
|
* @copyright 2016, Edouard DUPIN, all right reserved
|
||||||
|
* @license APACHE v2.0 (see license file)
|
||||||
|
*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <zeus/ServiceRemote.hpp>
|
||||||
|
|
||||||
|
namespace zeus {
|
||||||
|
class SystemProxy {
|
||||||
|
protected:
|
||||||
|
zeus::ServiceRemote& m_srv; //!< Service instance handle
|
||||||
|
public:
|
||||||
|
SystemProxy(zeus::ServiceRemote& _srv);
|
||||||
|
zeus::Future<std::string> getDescription();
|
||||||
|
zeus::Future<std::string> getVersion();
|
||||||
|
zeus::Future<std::string> getType();
|
||||||
|
zeus::Future<std::vector<std::string>> getExtention();
|
||||||
|
zeus::Future<std::vector<std::string>> getAuthors();
|
||||||
|
zeus::Future<std::vector<std::string>> getFunctions();
|
||||||
|
zeus::Future<std::string> getFunctionPrototype(std::string _functionName);
|
||||||
|
zeus::Future<std::string> getFunctionDescription(std::string _functionName);
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
@ -381,36 +381,39 @@ void zeus::WebServer::callForwardMultiple(uint32_t _clientId,
|
|||||||
ZEUS_ERROR("Can not transfer part of a message ...");
|
ZEUS_ERROR("Can not transfer part of a message ...");
|
||||||
}
|
}
|
||||||
|
|
||||||
void zeus::WebServer::sendCtrl(const std::string& _ctrlValue, uint32_t _clientId) {
|
void zeus::WebServer::sendCtrl(const std::string& _ctrlValue, uint32_t _clientId, uint32_t _serviceId) {
|
||||||
auto ctrl = zeus::BufferCtrl::create();
|
auto ctrl = zeus::BufferCtrl::create();
|
||||||
if (ctrl == nullptr) {
|
if (ctrl == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ctrl->setTransactionId(getId());
|
ctrl->setTransactionId(getId());
|
||||||
ctrl->setClientId(_clientId);
|
ctrl->setClientId(_clientId);
|
||||||
|
ctrl->setServiceId(_serviceId);
|
||||||
ctrl->setCtrl(_ctrlValue);
|
ctrl->setCtrl(_ctrlValue);
|
||||||
writeBinary(ctrl);
|
writeBinary(ctrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
void zeus::WebServer::answerError(uint64_t _clientTransactionId, const std::string& _errorValue, const std::string& _errorHelp, uint32_t _clientId) {
|
void zeus::WebServer::answerError(uint64_t _clientTransactionId, const std::string& _errorValue, const std::string& _errorHelp, uint32_t _clientId, uint32_t _serviceId) {
|
||||||
auto answer = zeus::BufferAnswer::create();
|
auto answer = zeus::BufferAnswer::create();
|
||||||
if (answer == nullptr) {
|
if (answer == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
answer->setTransactionId(_clientTransactionId);
|
answer->setTransactionId(_clientTransactionId);
|
||||||
answer->setClientId(_clientId);
|
answer->setClientId(_clientId);
|
||||||
|
answer->setServiceId(_serviceId);
|
||||||
answer->addError(_errorValue, _errorHelp);
|
answer->addError(_errorValue, _errorHelp);
|
||||||
writeBinary(answer);
|
writeBinary(answer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void zeus::WebServer::answerVoid(uint64_t _clientTransactionId, uint32_t _clientId) {
|
void zeus::WebServer::answerVoid(uint64_t _clientTransactionId, uint32_t _clientId, uint32_t _serviceId) {
|
||||||
auto answer = zeus::BufferAnswer::create();
|
auto answer = zeus::BufferAnswer::create();
|
||||||
if (answer == nullptr) {
|
if (answer == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
answer->setTransactionId(_clientTransactionId);
|
answer->setTransactionId(_clientTransactionId);
|
||||||
answer->setClientId(_clientId);
|
answer->setClientId(_clientId);
|
||||||
|
answer->setServiceId(_serviceId);
|
||||||
answer->addParameter();
|
answer->addParameter();
|
||||||
writeBinary(answer);
|
writeBinary(answer);
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,10 @@
|
|||||||
#include <zeus/AbstractFunction.hpp>
|
#include <zeus/AbstractFunction.hpp>
|
||||||
#include <zeus/FutureBase.hpp>
|
#include <zeus/FutureBase.hpp>
|
||||||
|
|
||||||
|
//#define ZEUS_NO_ID_CLIENT (0xFFFFFFFF)
|
||||||
|
#define ZEUS_NO_ID_CLIENT (0x00000000)
|
||||||
|
#define ZEUS_ID_SERVICE_ROOT (0x00000000)
|
||||||
|
|
||||||
namespace zeus {
|
namespace zeus {
|
||||||
/**
|
/**
|
||||||
* @brief
|
* @brief
|
||||||
@ -289,7 +293,7 @@ namespace zeus {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
template<class... _ARGS>
|
template<class... _ARGS>
|
||||||
zeus::FutureBase callService(uint32_t _serviceId, const std::string& _functionName, _ARGS&&... _args) {
|
zeus::FutureBase callService(uint32_t _clientId, uint32_t _serviceId, const std::string& _functionName, _ARGS&&... _args) {
|
||||||
uint16_t id = getId();
|
uint16_t id = getId();
|
||||||
ememory::SharedPtr<zeus::BufferCall> callElem = zeus::createCallService(id, _serviceId, _functionName, std::forward<_ARGS>(_args)...);
|
ememory::SharedPtr<zeus::BufferCall> callElem = zeus::createCallService(id, _serviceId, _functionName, std::forward<_ARGS>(_args)...);
|
||||||
return callBinary(id, callElem);
|
return callBinary(id, callElem);
|
||||||
@ -299,8 +303,9 @@ namespace zeus {
|
|||||||
* @param[in]
|
* @param[in]
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
// TODO: Remove the callback to add it in future with the "then(_callback)" and "else(_callback)" and "abort(_callbacl)" ...
|
||||||
template<class... _ARGS>
|
template<class... _ARGS>
|
||||||
zeus::FutureBase callServiceAction(uint32_t _serviceId, const std::string& _functionName, _ARGS&&... _args, zeus::FutureData::ObserverFinish _callback) {
|
zeus::FutureBase callServiceAction(uint32_t _clientId, uint32_t _serviceId, const std::string& _functionName, _ARGS&&... _args, zeus::FutureData::ObserverFinish _callback) {
|
||||||
uint16_t id = getId();
|
uint16_t id = getId();
|
||||||
ememory::SharedPtr<zeus::BufferCall> callElem = zeus::createCallService(id, _serviceId, _functionName, std::forward<_ARGS>(_args)...);
|
ememory::SharedPtr<zeus::BufferCall> callElem = zeus::createCallService(id, _serviceId, _functionName, std::forward<_ARGS>(_args)...);
|
||||||
return callBinary(id, callElem, _callback);
|
return callBinary(id, callElem, _callback);
|
||||||
@ -312,21 +317,24 @@ namespace zeus {
|
|||||||
*/
|
*/
|
||||||
template<class... _ARGS>
|
template<class... _ARGS>
|
||||||
zeus::FutureBase callClient(uint32_t _clientId,
|
zeus::FutureBase callClient(uint32_t _clientId,
|
||||||
|
uint32_t _serviceId,
|
||||||
const std::string& _functionName,
|
const std::string& _functionName,
|
||||||
_ARGS&&... _args) {
|
_ARGS&&... _args) {
|
||||||
return callService(_clientId, _functionName, _args...);
|
return callService(_clientId, _serviceId, _functionName, _args...);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @brief
|
* @brief
|
||||||
* @param[in]
|
* @param[in]
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
// TODO: Remove the callback to add it in future with the "then(_callback)" and "else(_callback)" and "abort(_callbacl)" ...
|
||||||
template<class... _ARGS>
|
template<class... _ARGS>
|
||||||
zeus::FutureBase callClientAction(uint32_t _clientId,
|
zeus::FutureBase callClientAction(uint32_t _clientId,
|
||||||
|
uint32_t _serviceId,
|
||||||
const std::string& _functionName,
|
const std::string& _functionName,
|
||||||
_ARGS&&... _args,
|
_ARGS&&... _args,
|
||||||
zeus::FutureData::ObserverFinish _callback) {
|
zeus::FutureData::ObserverFinish _callback) {
|
||||||
return callServiceAction(_clientId, _functionName, _args..., _callback);
|
return callServiceAction(_clientId, _serviceId, _functionName, _args..., _callback);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @brief
|
* @brief
|
||||||
@ -360,7 +368,7 @@ namespace zeus {
|
|||||||
* @param[in] _clientId Client to send control
|
* @param[in] _clientId Client to send control
|
||||||
*/
|
*/
|
||||||
template<class ZEUS_ARG>
|
template<class ZEUS_ARG>
|
||||||
void answerValue(uint64_t _clientTransactionId, ZEUS_ARG _value, uint32_t _clientId=0) {
|
void answerValue(uint64_t _clientTransactionId, ZEUS_ARG _value, uint32_t _clientId=0, uint32_t _serviceId=0) {
|
||||||
ememory::SharedPtr<zeus::BufferAnswer> answer = zeus::BufferAnswer::create();
|
ememory::SharedPtr<zeus::BufferAnswer> answer = zeus::BufferAnswer::create();
|
||||||
answer->setTransactionId(_clientTransactionId);
|
answer->setTransactionId(_clientTransactionId);
|
||||||
answer->setClientId(_clientId);
|
answer->setClientId(_clientId);
|
||||||
@ -372,7 +380,7 @@ namespace zeus {
|
|||||||
* @param[in] _clientTransactionId Transaction ID
|
* @param[in] _clientTransactionId Transaction ID
|
||||||
* @param[in] _clientId Client to send control
|
* @param[in] _clientId Client to send control
|
||||||
*/
|
*/
|
||||||
void answerVoid(uint64_t _clientTransactionId, uint32_t _clientId=0);
|
void answerVoid(uint64_t _clientTransactionId, uint32_t _clientId=0, uint32_t _serviceId=0);
|
||||||
/**
|
/**
|
||||||
* @brief Send an Answer error of a function
|
* @brief Send an Answer error of a function
|
||||||
* @param[in] _clientTransactionId Transaction ID
|
* @param[in] _clientTransactionId Transaction ID
|
||||||
@ -380,7 +388,7 @@ namespace zeus {
|
|||||||
* @param[in] _errorComment Help comment of the error
|
* @param[in] _errorComment Help comment of the error
|
||||||
* @param[in] _clientId Client to send control
|
* @param[in] _clientId Client to send control
|
||||||
*/
|
*/
|
||||||
void answerError(uint64_t _clientTransactionId, const std::string& _errorValue, const std::string& _errorComment="", uint32_t _clientId=0);
|
void answerError(uint64_t _clientTransactionId, const std::string& _errorValue, const std::string& _errorComment="", uint32_t _clientId=0, uint32_t _serviceId=0);
|
||||||
/**
|
/**
|
||||||
* @brief Send a control on the Interface
|
* @brief Send a control on the Interface
|
||||||
* @param[in] _clientTransactionId Transaction ID
|
* @param[in] _clientTransactionId Transaction ID
|
||||||
@ -388,7 +396,7 @@ namespace zeus {
|
|||||||
* @param[in] _clientId Client to send control
|
* @param[in] _clientId Client to send control
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
void sendCtrl(const std::string& _ctrlValue, uint32_t _clientId);
|
void sendCtrl(const std::string& _ctrlValue, uint32_t _clientId, uint32_t _serviceId=0);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user