diff --git a/zeus/Client.cpp b/zeus/Client.cpp index 3127c08..4c78cd6 100644 --- a/zeus/Client.cpp +++ b/zeus/Client.cpp @@ -8,8 +8,15 @@ #include #include +static const std::string protocolError = "PROTOCOL-ERROR"; +void zeus::Client::answerProtocolError(uint32_t _transactionId, const std::string& _errorHelp) { + m_interfaceWeb->answerError(_transactionId, 0, ZEUS_ID_SERVICE_ROOT, protocolError, _errorHelp); + m_interfaceWeb->disconnect(); + ZEUS_TODO("Do this error return ... " << _errorHelp); +} + zeus::Client::Client() : propertyIp(this, "ip", "127.0.0.1", "Ip to connect server", &zeus::Client::onPropertyChangeIp), propertyPort(this, "port", 1983, "Port to connect server", &zeus::Client::onPropertyChangePort), @@ -44,13 +51,13 @@ void zeus::Client::onClientData(ememory::SharedPtr _value) { //APPL_ERROR(" ==> parse DATA ..."); uint32_t transactionId = _value->getTransactionId(); if (transactionId == 0) { - APPL_ERROR("Protocol error ==>missing id"); + ZEUS_ERROR("Protocol error ==>missing id"); answerProtocolError(transactionId, "missing parameter: 'id'"); return; } // Check if we are the destinated Of this message if (_value->getDestinationId() != m_localAddress) { - APPL_ERROR("Protocol error ==> Wrong ID of the interface " << _value->getDestinationId() << " != " << m_localAddress); + ZEUS_ERROR("Protocol error ==> Wrong ID of the interface " << _value->getDestinationId() << " != " << m_localAddress); answerProtocolError(transactionId, "wrong adress: request " + etk::to_string(m_localAddress) + " have " + etk::to_string(m_localAddress)); return; } @@ -103,7 +110,7 @@ bool zeus::Client::serviceAdd(const std::string& _serviceName, factoryService _f ZEUS_ERROR("Can not provide a new sevice ... '" << futValidate.getErrorType() << "' help:" << futValidate.getErrorHelp()); return false; } - m_listServicesAvaillable.add(std::make_pair(_serviceName, _factory)); + m_listServicesAvaillable.insert(std::make_pair(_serviceName, _factory)); return true; } diff --git a/zeus/Client.hpp b/zeus/Client.hpp index 05795d4..d881ae5 100644 --- a/zeus/Client.hpp +++ b/zeus/Client.hpp @@ -33,6 +33,7 @@ namespace zeus { std::vector> m_listProvicedService; //!< Connect only one time on each service, not needed more. std::vector> m_listLocalObject; public: + void answerProtocolError(uint32_t _transactionId, const std::string& _errorHelp); /** * @brief * @param[in] @@ -86,7 +87,7 @@ namespace zeus { * @return Pointer on an interface of remote service */ zeus::ServiceRemote getService(const std::string& _serviceName); - using factoryService = std::function, zeus::Client&, uint16_t objId)>; + using factoryService = std::function(zeus::Client&, uint16_t)>; std::map m_listServicesAvaillable; //!< list of all factory availlable /** diff --git a/zeus/Object.cpp b/zeus/Object.cpp index 3ae24d0..d139171 100644 --- a/zeus/Object.cpp +++ b/zeus/Object.cpp @@ -12,11 +12,13 @@ zeus::Object::Object() { + /* zeus::AbstractFunction* func = advertise("getExtention", &zeus::Object::getExtention); if (func != nullptr) { func->setDescription("Get List of availlable extention of this Object"); func->setReturn("A list of extention register in the Object"); } + */ } zeus::Object::~Object() { @@ -84,6 +86,7 @@ void zeus::Object::callBinary(ememory::SharedPtr _obj) { uint32_t sourceId = callObj->getSourceId(); std::string callFunction = callObj->getCall(); ZEUS_INFO("plop - ... " << callFunction); + /* if (callFunction[0] == '_') { if (callFunction == "_new") { std::string userName = callObj->getParameter(0); @@ -95,13 +98,13 @@ void zeus::Object::callBinary(ememory::SharedPtr _obj) { } m_interfaceClient->answerValue(callObj->getTransactionId(), uint32_t(m_id)<<16, source, true); return; - } else if (isFunctionAuthorized(sourceId, callFunction) == true) { + } else */if (isFunctionAuthorized(sourceId, callFunction) == true) { ZEUS_INFO("plop 6 ..."); callBinary2(callFunction, callObj); return; } else { ZEUS_INFO("plop 7 ..."); - m_interfaceClient->answerError(callObj->getTransactionId(), uint32_t(m_id)<<16, source, "NOT-AUTHORIZED-FUNCTION", ""); + m_interfaceClient->answerError(callObj->getTransactionId(), uint32_t(m_ObjectId)<<16, source, "NOT-AUTHORIZED-FUNCTION", ""); return; } } diff --git a/zeus/Object.hpp b/zeus/Object.hpp index 13abdb9..0fcf9cd 100644 --- a/zeus/Object.hpp +++ b/zeus/Object.hpp @@ -28,7 +28,7 @@ namespace zeus { protected: ememory::SharedPtr m_interfaceClient; uint16_t m_ObjectId; - //std::vector m_callMultiData; + std::vector m_callMultiData; public: /** * @brief @@ -61,7 +61,7 @@ namespace zeus { * @param[in] * @return */ - virtual void callBinary2(const std::string& _call, ememory::SharedPtr _obj); + virtual void callBinary2(const std::string& _call, ememory::SharedPtr _obj) = 0; public: /** * @brief @@ -99,7 +99,7 @@ namespace zeus { template class ObjectType : public zeus::Object { private: - ZEUS_TYPE_OBJECT m_interface; // direct handle on the data; + ememory::SharedPtr m_interface; // direct handle on the data; public: /** * @brief diff --git a/zeus/Service.cpp b/zeus/Service.cpp index 4445115..133009f 100644 --- a/zeus/Service.cpp +++ b/zeus/Service.cpp @@ -158,7 +158,7 @@ void zeus::Service::callBinary(ememory::SharedPtr _obj) { uint32_t sourceId = callObj->getSourceId(); std::string callFunction = callObj->getCall(); ZEUS_INFO("plop - ... " << callFunction); - if (callFunction[0] == '_') { + /*if (callFunction[0] == '_') { if (callFunction == "_new") { std::string userName = callObj->getParameter(0); std::string clientName = callObj->getParameter(1); @@ -169,7 +169,7 @@ void zeus::Service::callBinary(ememory::SharedPtr _obj) { } m_interfaceClient->answerValue(callObj->getTransactionId(), uint32_t(m_id)<<16, source, true); return; - } else if (isFunctionAuthorized(sourceId, callFunction) == true) { + } else */if (isFunctionAuthorized(sourceId, callFunction) == true) { ZEUS_INFO("plop 6 ..."); callBinary2(callFunction, callObj); return; diff --git a/zeus/Service.hpp b/zeus/Service.hpp index 3b4d310..e440f5b 100644 --- a/zeus/Service.hpp +++ b/zeus/Service.hpp @@ -184,13 +184,13 @@ namespace zeus { * @param[in] _userName User name of the client to connect * @todo Set a relur like ==> service not availlable / service close / service maintenance / service right reject */ - virtual void clientConnect(uint16_t _sourceId, const std::string& _userName, const std::string& _clientName, const std::vector& _groups) = 0; + //virtual void clientConnect(uint16_t _sourceId, const std::string& _userName, const std::string& _clientName, const std::vector& _groups) = 0; /** * @brief * @param[in] * @return */ - virtual void clientDisconnect(uint16_t _sourceId) = 0; + //virtual void clientDisconnect(uint16_t _sourceId) = 0; /** * @brief * @param[in] @@ -247,8 +247,8 @@ namespace zeus { class ServiceType : public zeus::Service { private: // no need of shared_ptr or unique_ptr (if service die all is lost and is client die, the gateway notify us...) - ememory::SharedPtr m_property - ZEUS_TYPE_SERVICE m_interface; + ememory::SharedPtr m_property; + ememory::SharedPtr m_interface; public: /** * @brief