[DEV/DEBUG] add etk::typeInfo declaration and correct add and remove object in list not thread safe
This commit is contained in:
parent
046e270179
commit
e8a09ef7d2
@ -7,6 +7,9 @@
|
|||||||
#include <zeus/debug.hpp>
|
#include <zeus/debug.hpp>
|
||||||
#include <etk/os/FSNode.hpp>
|
#include <etk/os/FSNode.hpp>
|
||||||
|
|
||||||
|
#include <etk/typeInfo.hpp>
|
||||||
|
ETK_DECLARE_TYPE(zeus::AbstractFunction);
|
||||||
|
|
||||||
static int32_t firstCall(bool& _value) {
|
static int32_t firstCall(bool& _value) {
|
||||||
_value = false;
|
_value = false;
|
||||||
return 51;
|
return 51;
|
||||||
|
@ -41,7 +41,7 @@ namespace zeus {
|
|||||||
ret = (*_pointer.*_func)(notifs, _obj->getParameter<ZEUS_TYPES>(idParam--)...);
|
ret = (*_pointer.*_func)(notifs, _obj->getParameter<ZEUS_TYPES>(idParam--)...);
|
||||||
}
|
}
|
||||||
if (_interfaceClient == nullptr) {
|
if (_interfaceClient == nullptr) {
|
||||||
ZEUS_ERROR("Nullptr for _interfaceWeb");
|
ZEUS_ERROR("Nullptr for _interfaceClient");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_interfaceClient->addAsync([=](WebServer* _interface) {
|
_interfaceClient->addAsync([=](WebServer* _interface) {
|
||||||
@ -75,7 +75,7 @@ namespace zeus {
|
|||||||
ret = (*_pointer.*_func)(_obj->getParameter<ZEUS_TYPES>(idParam--)...);
|
ret = (*_pointer.*_func)(_obj->getParameter<ZEUS_TYPES>(idParam--)...);
|
||||||
}
|
}
|
||||||
if (_interfaceClient == nullptr) {
|
if (_interfaceClient == nullptr) {
|
||||||
ZEUS_ERROR("Nullptr for _interfaceWeb");
|
ZEUS_ERROR("Nullptr for _interfaceClient");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_interfaceClient->addAsync([=](WebServer* _interface) {
|
_interfaceClient->addAsync([=](WebServer* _interface) {
|
||||||
@ -109,7 +109,7 @@ namespace zeus {
|
|||||||
(*_pointer.*_func)(notifs, _obj->getParameter<ZEUS_TYPES>(idParam--)...);
|
(*_pointer.*_func)(notifs, _obj->getParameter<ZEUS_TYPES>(idParam--)...);
|
||||||
}
|
}
|
||||||
if (_interfaceClient == nullptr) {
|
if (_interfaceClient == nullptr) {
|
||||||
ZEUS_ERROR("Nullptr for _interfaceWeb");
|
ZEUS_ERROR("Nullptr for _interfaceClient");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_interfaceClient->addAsync([=](WebServer* _interface) {
|
_interfaceClient->addAsync([=](WebServer* _interface) {
|
||||||
@ -142,7 +142,7 @@ namespace zeus {
|
|||||||
(*_pointer.*_func)(_obj->getParameter<ZEUS_TYPES>(idParam--)...);
|
(*_pointer.*_func)(_obj->getParameter<ZEUS_TYPES>(idParam--)...);
|
||||||
}
|
}
|
||||||
if (_interfaceClient == nullptr) {
|
if (_interfaceClient == nullptr) {
|
||||||
ZEUS_ERROR("Nullptr for _interfaceWeb");
|
ZEUS_ERROR("Nullptr for _interfaceClient");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_interfaceClient->addAsync([=](WebServer* _interface) {
|
_interfaceClient->addAsync([=](WebServer* _interface) {
|
||||||
|
@ -11,6 +11,10 @@
|
|||||||
static const etk::String protocolError = "PROTOCOL-ERROR";
|
static const etk::String protocolError = "PROTOCOL-ERROR";
|
||||||
|
|
||||||
|
|
||||||
|
#include <etk/typeInfo.hpp>
|
||||||
|
ETK_DECLARE_TYPE(zeus::Client);
|
||||||
|
|
||||||
|
|
||||||
void zeus::Client::answerProtocolError(uint32_t _transactionId, const etk::String& _errorHelp) {
|
void zeus::Client::answerProtocolError(uint32_t _transactionId, const etk::String& _errorHelp) {
|
||||||
m_interfaceWeb->answerError(_transactionId, 0, ZEUS_ID_SERVICE_ROOT, protocolError, _errorHelp);
|
m_interfaceWeb->answerError(_transactionId, 0, ZEUS_ID_SERVICE_ROOT, protocolError, _errorHelp);
|
||||||
m_interfaceWeb->disconnect();
|
m_interfaceWeb->disconnect();
|
||||||
|
@ -8,6 +8,10 @@
|
|||||||
#include <zeus/debug.hpp>
|
#include <zeus/debug.hpp>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#include <etk/typeInfo.hpp>
|
||||||
|
ETK_DECLARE_TYPE(zeus::FutureBase);
|
||||||
|
|
||||||
zeus::FutureBase::FutureBase(const zeus::FutureBase& _base):
|
zeus::FutureBase::FutureBase(const zeus::FutureBase& _base):
|
||||||
m_promise(_base.m_promise) {
|
m_promise(_base.m_promise) {
|
||||||
|
|
||||||
|
@ -7,6 +7,10 @@
|
|||||||
#include <zeus/FutureGroup.hpp>
|
#include <zeus/FutureGroup.hpp>
|
||||||
#include <zeus/debug.hpp>
|
#include <zeus/debug.hpp>
|
||||||
|
|
||||||
|
|
||||||
|
#include <etk/typeInfo.hpp>
|
||||||
|
ETK_DECLARE_TYPE(zeus::FutureGroup);
|
||||||
|
|
||||||
void zeus::FutureGroup::add(const zeus::FutureBase& _fut) {
|
void zeus::FutureGroup::add(const zeus::FutureBase& _fut) {
|
||||||
m_listFuture.pushBack(_fut);
|
m_listFuture.pushBack(_fut);
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,8 @@
|
|||||||
#include <enet/TcpClient.hpp>
|
#include <enet/TcpClient.hpp>
|
||||||
#include <zeus/Client.hpp>
|
#include <zeus/Client.hpp>
|
||||||
|
|
||||||
|
#include <etk/typeInfo.hpp>
|
||||||
|
ETK_DECLARE_TYPE(zeus::Object);
|
||||||
|
|
||||||
|
|
||||||
zeus::Object::Object(const ememory::SharedPtr<zeus::WebServer>& _iface, uint16_t _objectId) :
|
zeus::Object::Object(const ememory::SharedPtr<zeus::WebServer>& _iface, uint16_t _objectId) :
|
||||||
|
@ -6,6 +6,10 @@
|
|||||||
|
|
||||||
#include <zeus/ObjectIntrospect.hpp>
|
#include <zeus/ObjectIntrospect.hpp>
|
||||||
|
|
||||||
|
|
||||||
|
#include <etk/typeInfo.hpp>
|
||||||
|
ETK_DECLARE_TYPE(zeus::ObjectIntrospect);
|
||||||
|
|
||||||
zeus::ObjectIntrospect::ObjectIntrospect(zeus::ObjectRemote& _obj):
|
zeus::ObjectIntrospect::ObjectIntrospect(zeus::ObjectRemote& _obj):
|
||||||
m_obj(_obj) {
|
m_obj(_obj) {
|
||||||
|
|
||||||
|
@ -7,7 +7,8 @@
|
|||||||
#include <zeus/ObjectRemote.hpp>
|
#include <zeus/ObjectRemote.hpp>
|
||||||
#include <zeus/Client.hpp>
|
#include <zeus/Client.hpp>
|
||||||
|
|
||||||
|
#include <etk/typeInfo.hpp>
|
||||||
|
ETK_DECLARE_TYPE(zeus::ObjectRemoteBase);
|
||||||
|
|
||||||
zeus::ObjectRemoteBase::ObjectRemoteBase(const ememory::SharedPtr<zeus::WebServer>& _iface, uint16_t _localId, uint16_t _localObjectId, uint32_t _address, const etk::String& _type):
|
zeus::ObjectRemoteBase::ObjectRemoteBase(const ememory::SharedPtr<zeus::WebServer>& _iface, uint16_t _localId, uint16_t _localObjectId, uint32_t _address, const etk::String& _type):
|
||||||
zeus::WebObj(_iface, _localId, _localObjectId),
|
zeus::WebObj(_iface, _localId, _localObjectId),
|
||||||
|
@ -25,6 +25,7 @@ namespace zeus {
|
|||||||
etk::String m_type; //!< name of the remote object
|
etk::String m_type; //!< name of the remote object
|
||||||
uint32_t m_remoteAddress; //!< remote adress of the object
|
uint32_t m_remoteAddress; //!< remote adress of the object
|
||||||
bool m_isLinked; //!< link status of the object
|
bool m_isLinked; //!< link status of the object
|
||||||
|
ememory::SharedPtr<void> m_adressLocalObject; //!< Pointer on the local object if we are in the same process.
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* @brief Contructor of the remote object
|
* @brief Contructor of the remote object
|
||||||
|
@ -10,6 +10,9 @@
|
|||||||
#include <zeus/debug.hpp>
|
#include <zeus/debug.hpp>
|
||||||
#include <zeus/WebServer.hpp>
|
#include <zeus/WebServer.hpp>
|
||||||
|
|
||||||
|
#include <etk/typeInfo.hpp>
|
||||||
|
ETK_DECLARE_TYPE(zeus::Promise);
|
||||||
|
|
||||||
|
|
||||||
zeus::Promise::Promise(uint32_t _transactionId, uint32_t _source) {
|
zeus::Promise::Promise(uint32_t _transactionId, uint32_t _source) {
|
||||||
m_sendTime = echrono::Steady::now();
|
m_sendTime = echrono::Steady::now();
|
||||||
|
@ -7,6 +7,10 @@
|
|||||||
#include <zeus/Proxy.hpp>
|
#include <zeus/Proxy.hpp>
|
||||||
#include <zeus/debug.hpp>
|
#include <zeus/debug.hpp>
|
||||||
|
|
||||||
|
|
||||||
|
#include <etk/typeInfo.hpp>
|
||||||
|
ETK_DECLARE_TYPE(zeus::Proxy);
|
||||||
|
|
||||||
const zeus::Proxy& zeus::Proxy::operator= (const zeus::ObjectRemote& _obj) {
|
const zeus::Proxy& zeus::Proxy::operator= (const zeus::ObjectRemote& _obj) {
|
||||||
m_obj = _obj;
|
m_obj = _obj;
|
||||||
return *this;
|
return *this;
|
||||||
|
@ -6,7 +6,8 @@
|
|||||||
|
|
||||||
#include <zeus/Raw.hpp>
|
#include <zeus/Raw.hpp>
|
||||||
#include "debug.hpp"
|
#include "debug.hpp"
|
||||||
|
#include <etk/typeInfo.hpp>
|
||||||
|
ETK_DECLARE_TYPE(zeus::Raw);
|
||||||
|
|
||||||
zeus::Raw::Raw() :
|
zeus::Raw::Raw() :
|
||||||
m_size(0),
|
m_size(0),
|
||||||
|
@ -5,6 +5,10 @@
|
|||||||
*/
|
*/
|
||||||
#include <zeus/RemoteProcessCall.hpp>
|
#include <zeus/RemoteProcessCall.hpp>
|
||||||
|
|
||||||
|
|
||||||
|
#include <etk/typeInfo.hpp>
|
||||||
|
ETK_DECLARE_TYPE(zeus::RemoteProcessCall);
|
||||||
|
|
||||||
zeus::RemoteProcessCall::RemoteProcessCall(const ememory::SharedPtr<zeus::WebServer>& _iface, uint16_t _id, uint16_t _objectId) :
|
zeus::RemoteProcessCall::RemoteProcessCall(const ememory::SharedPtr<zeus::WebServer>& _iface, uint16_t _id, uint16_t _objectId) :
|
||||||
zeus::WebObj(_iface, _id, _objectId),
|
zeus::WebObj(_iface, _id, _objectId),
|
||||||
m_type("UNKNOW") {
|
m_type("UNKNOW") {
|
||||||
|
@ -7,6 +7,10 @@
|
|||||||
#include <zeus/WebObj.hpp>
|
#include <zeus/WebObj.hpp>
|
||||||
#include <zeus/debug.hpp>
|
#include <zeus/debug.hpp>
|
||||||
|
|
||||||
|
|
||||||
|
#include <etk/typeInfo.hpp>
|
||||||
|
ETK_DECLARE_TYPE(zeus::WebObj);
|
||||||
|
|
||||||
zeus::WebObj::WebObj(const ememory::SharedPtr<zeus::WebServer>& _iface, uint16_t _id, uint16_t _objectId) :
|
zeus::WebObj::WebObj(const ememory::SharedPtr<zeus::WebServer>& _iface, uint16_t _id, uint16_t _objectId) :
|
||||||
m_interfaceWeb(_iface),
|
m_interfaceWeb(_iface),
|
||||||
m_id(_id),
|
m_id(_id),
|
||||||
|
@ -11,6 +11,10 @@
|
|||||||
#include <zeus/message/Data.hpp>
|
#include <zeus/message/Data.hpp>
|
||||||
|
|
||||||
|
|
||||||
|
#include <etk/typeInfo.hpp>
|
||||||
|
ETK_DECLARE_TYPE(zeus::WebServer);
|
||||||
|
|
||||||
|
|
||||||
ememory::SharedPtr<zeus::message::Call> zeus::createBaseCall(const ememory::SharedPtr<zeus::WebServer>& _iface,
|
ememory::SharedPtr<zeus::message::Call> zeus::createBaseCall(const ememory::SharedPtr<zeus::WebServer>& _iface,
|
||||||
uint64_t _transactionId,
|
uint64_t _transactionId,
|
||||||
const uint32_t& _source,
|
const uint32_t& _source,
|
||||||
@ -109,18 +113,19 @@ void zeus::WebServer::setInterfaceName(const etk::String& _name) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void zeus::WebServer::addWebObj(ememory::SharedPtr<zeus::WebObj> _obj) {
|
void zeus::WebServer::addWebObj(ememory::SharedPtr<zeus::WebObj> _obj) {
|
||||||
//ethread::UniqueLock lock(m_mutex);
|
ethread::UniqueLock lock(m_listObjectMutex);
|
||||||
m_listObject.pushBack(_obj);
|
m_listObject.pushBack(_obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
void zeus::WebServer::addWebObjRemote(ememory::SharedPtr<zeus::ObjectRemoteBase> _obj) {
|
void zeus::WebServer::addWebObjRemote(ememory::SharedPtr<zeus::ObjectRemoteBase> _obj) {
|
||||||
//ethread::UniqueLock lock(m_mutex);
|
ethread::UniqueLock lock(m_listRemoteObjectMutex);
|
||||||
m_listRemoteObject.pushBack(_obj);
|
m_listRemoteObject.pushBack(_obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
void zeus::WebServer::interfaceRemoved(etk::Vector<uint16_t> _list) {
|
void zeus::WebServer::interfaceRemoved(etk::Vector<uint16_t> _list) {
|
||||||
ZEUS_WARNING("Remove interface : " << _list);
|
ZEUS_WARNING("Remove interface : " << _list);
|
||||||
for (int32_t iii=0; iii < _list.size(); ++iii) {
|
for (int32_t iii=0; iii < _list.size(); ++iii) {
|
||||||
|
ethread::UniqueLock lock(m_listRemoteObjectMutex);
|
||||||
// Call All remote Object object
|
// Call All remote Object object
|
||||||
for (auto it=m_listRemoteObject.begin();
|
for (auto it=m_listRemoteObject.begin();
|
||||||
it != m_listRemoteObject.end();
|
it != m_listRemoteObject.end();
|
||||||
@ -139,6 +144,7 @@ void zeus::WebServer::interfaceRemoved(etk::Vector<uint16_t> _list) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (int32_t iii=0; iii < _list.size(); ++iii) {
|
for (int32_t iii=0; iii < _list.size(); ++iii) {
|
||||||
|
ethread::UniqueLock lock(m_listObjectMutex);
|
||||||
// Call All remote Object object
|
// Call All remote Object object
|
||||||
for (auto it=m_listObject.begin();
|
for (auto it=m_listObject.begin();
|
||||||
it != m_listObject.end();
|
it != m_listObject.end();
|
||||||
@ -283,7 +289,7 @@ int32_t zeus::WebServer::writeBinary(ememory::SharedPtr<zeus::Message> _obj) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool zeus::WebServer::onReceiveUri(const etk::String& _uri, const etk::Vector<etk::String>& _protocols) {
|
etk::String zeus::WebServer::onReceiveUri(const etk::String& _uri, const etk::Vector<etk::String>& _protocols) {
|
||||||
ZEUS_INFO("Receive Header uri: " << _uri);
|
ZEUS_INFO("Receive Header uri: " << _uri);
|
||||||
bool findProtocol = false;
|
bool findProtocol = false;
|
||||||
for (auto &it : _protocols) {
|
for (auto &it : _protocols) {
|
||||||
@ -295,17 +301,35 @@ bool zeus::WebServer::onReceiveUri(const etk::String& _uri, const etk::Vector<et
|
|||||||
}
|
}
|
||||||
if (findProtocol == false) {
|
if (findProtocol == false) {
|
||||||
ZEUS_ERROR("Disable connection request URI='" << _uri << "' with wrong protocol:" << _protocols);
|
ZEUS_ERROR("Disable connection request URI='" << _uri << "' with wrong protocol:" << _protocols);
|
||||||
return false;
|
return "CLOSE";
|
||||||
}
|
}
|
||||||
// TODO : Add better return on specific user ...
|
// TODO : Add better return on specific user ...
|
||||||
if (m_observerRequestUri != nullptr) {
|
if (m_observerRequestUri != nullptr) {
|
||||||
return m_observerRequestUri(_uri);
|
etk::Map<etk::String,etk::String> options;
|
||||||
|
etk::String uri;
|
||||||
|
size_t pos = _uri.find('?');
|
||||||
|
if (pos == etk::String::npos) {
|
||||||
|
uri = _uri;
|
||||||
|
} else {
|
||||||
|
uri = _uri.extract(0, pos);
|
||||||
|
etk::String opt = _uri.extract(pos+1, _uri.size());
|
||||||
|
etk::Vector<etk::String> listValue = opt.split('&');
|
||||||
|
for (auto &it: listValue) {
|
||||||
|
pos = it.find('=');
|
||||||
|
if (pos == etk::String::npos) {
|
||||||
|
options.set(it, "");
|
||||||
|
} else {
|
||||||
|
options.set(it.extract(0,pos), it.extract(pos+1, it.size()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return m_observerRequestUri(uri, options);
|
||||||
}
|
}
|
||||||
if (_uri == "/") {
|
if (_uri == "/") {
|
||||||
return true;
|
return "OK";
|
||||||
}
|
}
|
||||||
ZEUS_ERROR("Disable connection all time the uri is not accepted by the server if the URI is not '/' URI='" << _uri << "'");
|
ZEUS_ERROR("Disable connection all time the uri is not accepted by the server if the URI is not '/' URI='" << _uri << "'");
|
||||||
return false;
|
return "CLOSE";
|
||||||
}
|
}
|
||||||
|
|
||||||
void zeus::WebServer::onReceiveData(etk::Vector<uint8_t>& _frame, bool _isBinary) {
|
void zeus::WebServer::onReceiveData(etk::Vector<uint8_t>& _frame, bool _isBinary) {
|
||||||
@ -414,42 +438,47 @@ void zeus::WebServer::newMessage(ememory::SharedPtr<zeus::Message> _buffer) {
|
|||||||
// Not find a pending call ==> execute it ...
|
// Not find a pending call ==> execute it ...
|
||||||
if (future.isValid() == false) {
|
if (future.isValid() == false) {
|
||||||
uint32_t dest = _buffer->getDestination();
|
uint32_t dest = _buffer->getDestination();
|
||||||
// Call local object
|
{
|
||||||
for (auto &it : m_listObject) {
|
ethread::UniqueLock lock(m_listObjectMutex);
|
||||||
if (it == nullptr) {
|
// Call local object
|
||||||
continue;
|
for (auto &it : m_listObject) {
|
||||||
}
|
if (it == nullptr) {
|
||||||
if (it->getFullId() == dest) {
|
continue;
|
||||||
// send in an other async to syncronize the
|
}
|
||||||
m_processingPool.async(
|
if (it->getFullId() == dest) {
|
||||||
[=](){
|
// send in an other async to syncronize the
|
||||||
ememory::SharedPtr<zeus::WebObj> tmpObj = it;
|
m_processingPool.async(
|
||||||
ZEUS_LOG_INPUT_OUTPUT("PROCESS : " << _buffer);
|
[=](){
|
||||||
tmpObj->receive(_buffer);
|
ememory::SharedPtr<zeus::WebObj> tmpObj = it;
|
||||||
},
|
ZEUS_LOG_INPUT_OUTPUT("PROCESS : " << _buffer);
|
||||||
dest
|
tmpObj->receive(_buffer);
|
||||||
);
|
},
|
||||||
return;
|
dest
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//ethread::UniqueLock lock(m_mutex);
|
{
|
||||||
// call local map object on remote object
|
ethread::UniqueLock lock(m_listRemoteObjectMutex);
|
||||||
for (auto &it : m_listRemoteObject) {
|
// call local map object on remote object
|
||||||
ememory::SharedPtr<zeus::ObjectRemoteBase> tmp = it.lock();
|
for (auto &it : m_listRemoteObject) {
|
||||||
if (tmp == nullptr) {
|
ememory::SharedPtr<zeus::ObjectRemoteBase> tmp = it.lock();
|
||||||
continue;
|
if (tmp == nullptr) {
|
||||||
}
|
continue;
|
||||||
if (tmp->getFullId() == dest) {
|
}
|
||||||
// send in an other async to syncronize the
|
if (tmp->getFullId() == dest) {
|
||||||
m_processingPool.async(
|
// send in an other async to syncronize the
|
||||||
[=](){
|
m_processingPool.async(
|
||||||
ememory::SharedPtr<zeus::WebObj> tmpObj = tmp;
|
[=](){
|
||||||
ZEUS_LOG_INPUT_OUTPUT("PROCESS : " << _buffer);
|
ememory::SharedPtr<zeus::WebObj> tmpObj = tmp;
|
||||||
tmpObj->receive(_buffer);
|
ZEUS_LOG_INPUT_OUTPUT("PROCESS : " << _buffer);
|
||||||
},
|
tmpObj->receive(_buffer);
|
||||||
dest
|
},
|
||||||
);
|
dest
|
||||||
return;
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (m_observerElement != nullptr) {
|
if (m_observerElement != nullptr) {
|
||||||
@ -496,24 +525,29 @@ void zeus::WebServer::newMessage(ememory::SharedPtr<zeus::Message> _buffer) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void zeus::WebServer::listObjects() {
|
void zeus::WebServer::listObjects() {
|
||||||
//ethread::UniqueLock lock(m_mutex);
|
|
||||||
if ( m_listObject.size() == 0
|
if ( m_listObject.size() == 0
|
||||||
&& m_listRemoteObject.size() == 0) {
|
&& m_listRemoteObject.size() == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ZEUS_DEBUG("[" << m_interfaceId << "] Interface WebServer:");
|
ZEUS_DEBUG("[" << m_interfaceId << "] Interface WebServer:");
|
||||||
for (auto &it : m_listObject) {
|
{
|
||||||
if (it == nullptr) {
|
ethread::UniqueLock lock(m_listObjectMutex);
|
||||||
continue;
|
for (auto &it : m_listObject) {
|
||||||
|
if (it == nullptr) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
it->display();
|
||||||
}
|
}
|
||||||
it->display();
|
|
||||||
}
|
}
|
||||||
for (auto &it : m_listRemoteObject) {
|
{
|
||||||
ememory::SharedPtr<zeus::ObjectRemoteBase> tmpp = it.lock();
|
ethread::UniqueLock lock(m_listRemoteObjectMutex);
|
||||||
if (tmpp == nullptr) {
|
for (auto &it : m_listRemoteObject) {
|
||||||
continue;
|
ememory::SharedPtr<zeus::ObjectRemoteBase> tmpp = it.lock();
|
||||||
|
if (tmpp == nullptr) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
tmpp->display();
|
||||||
}
|
}
|
||||||
tmpp->display();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -523,27 +557,37 @@ void zeus::WebServer::cleanDeadObject() {
|
|||||||
&& m_listRemoteObject.size() == 0) {
|
&& m_listRemoteObject.size() == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (auto it=m_listObject.begin();
|
ZEUS_INFO("Clean DEAD object... total=" << m_listObject.size());
|
||||||
it!=m_listObject.end();
|
etk::Vector<ememory::SharedPtr<zeus::WebObj>> tmpToRemoveObjectInAsync;
|
||||||
/* no auto increment*/) {
|
{
|
||||||
if (*it == nullptr) {
|
ethread::UniqueLock lock(m_listObjectMutex);
|
||||||
it = m_listObject.erase(it);
|
for (auto it=m_listObject.begin();
|
||||||
continue;
|
it!=m_listObject.end();
|
||||||
|
/* no auto increment*/) {
|
||||||
|
if (*it == nullptr) {
|
||||||
|
it = m_listObject.erase(it);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if ((*it)->haveRemoteConnected() == false) {
|
||||||
|
tmpToRemoveObjectInAsync.pushBack(*it);
|
||||||
|
it = m_listObject.erase(it);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
++it;
|
||||||
}
|
}
|
||||||
if ((*it)->haveRemoteConnected() == false) {
|
|
||||||
it = m_listObject.erase(it);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
++it;
|
|
||||||
}
|
}
|
||||||
for (auto it=m_listRemoteObject.begin();
|
tmpToRemoveObjectInAsync.clear();
|
||||||
it!=m_listRemoteObject.end();
|
{
|
||||||
/* no auto increment*/) {
|
ethread::UniqueLock lock(m_listRemoteObjectMutex);
|
||||||
if (it->expired() == true) {
|
for (auto it=m_listRemoteObject.begin();
|
||||||
it = m_listRemoteObject.erase(it);
|
it!=m_listRemoteObject.end();
|
||||||
continue;
|
/* no auto increment*/) {
|
||||||
|
if (it->expired() == true) {
|
||||||
|
it = m_listRemoteObject.erase(it);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
++it;
|
||||||
}
|
}
|
||||||
++it;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -553,22 +597,28 @@ bool zeus::WebServer::transferRemoteObjectOwnership(uint16_t _objectAddress, uin
|
|||||||
&& m_listRemoteObject.size() == 0) {
|
&& m_listRemoteObject.size() == 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
for (auto &it : m_listObject) {
|
{
|
||||||
if (it == nullptr) {
|
ethread::UniqueLock lock(m_listObjectMutex);
|
||||||
continue;
|
for (auto &it : m_listObject) {
|
||||||
}
|
if (it == nullptr) {
|
||||||
if (it->getObjectId() == _objectAddress) {
|
continue;
|
||||||
return it->transferOwnership(_sourceAddress, _destinataireAddress);
|
}
|
||||||
|
if (it->getObjectId() == _objectAddress) {
|
||||||
|
return it->transferOwnership(_sourceAddress, _destinataireAddress);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (auto &it : m_listRemoteObject) {
|
{
|
||||||
ememory::SharedPtr<zeus::ObjectRemoteBase> tmp = it.lock();
|
ethread::UniqueLock lock(m_listRemoteObjectMutex);
|
||||||
if (tmp == nullptr) {
|
for (auto &it : m_listRemoteObject) {
|
||||||
continue;
|
ememory::SharedPtr<zeus::ObjectRemoteBase> tmp = it.lock();
|
||||||
}
|
if (tmp == nullptr) {
|
||||||
if (tmp->getObjectId() == _objectAddress) {
|
continue;
|
||||||
ZEUS_ERROR("return a remote Object is not permited ... ==> link directly to the original elements");
|
}
|
||||||
return false;
|
if (tmp->getObjectId() == _objectAddress) {
|
||||||
|
ZEUS_ERROR("return a remote Object is not permited ... ==> link directly to the original elements");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -580,24 +630,30 @@ bool zeus::WebServer::removeObjectOwnership(uint16_t _objectAddress, uint32_t _s
|
|||||||
&& m_listRemoteObject.size() == 0) {
|
&& m_listRemoteObject.size() == 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
for (auto &it : m_listObject) {
|
{
|
||||||
if (it == nullptr) {
|
ethread::UniqueLock lock(m_listObjectMutex);
|
||||||
continue;
|
for (auto &it : m_listObject) {
|
||||||
}
|
if (it == nullptr) {
|
||||||
//ZEUS_INFO("1 Remove ownership of " << it->getObjectId() << " == " << _objectAddress);
|
continue;
|
||||||
if (it->getObjectId() == _objectAddress) {
|
}
|
||||||
return it->removeOwnership(_sourceAddress);
|
ZEUS_INFO("1 Remove ownership of " << it->getObjectId() << " == " << _objectAddress);
|
||||||
|
if (it->getObjectId() == _objectAddress) {
|
||||||
|
return it->removeOwnership(_sourceAddress);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (auto &it : m_listRemoteObject) {
|
{
|
||||||
ememory::SharedPtr<zeus::ObjectRemoteBase> tmp = it.lock();
|
ethread::UniqueLock lock(m_listRemoteObjectMutex);
|
||||||
if (tmp == nullptr) {
|
for (auto &it : m_listRemoteObject) {
|
||||||
continue;
|
ememory::SharedPtr<zeus::ObjectRemoteBase> tmp = it.lock();
|
||||||
}
|
if (tmp == nullptr) {
|
||||||
//ZEUS_INFO("2 Remove ownership of " << tmp->getObjectId() << " == " << _objectAddress);
|
continue;
|
||||||
if (tmp->getObjectId() == _objectAddress) {
|
}
|
||||||
ZEUS_ERROR("return a remote Object is not permited ... ==> link directly to the original elements");
|
ZEUS_INFO("2 Remove ownership of " << tmp->getObjectId() << " == " << _objectAddress);
|
||||||
return false;
|
if (tmp->getObjectId() == _objectAddress) {
|
||||||
|
ZEUS_ERROR("return a remote Object is not permited ... ==> link directly to the original elements");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -618,6 +674,7 @@ void zeus::WebServer::threadAsyncCallback() {
|
|||||||
if (m_threadAsyncList2.size() != 0) {
|
if (m_threadAsyncList2.size() != 0) {
|
||||||
ethread::UniqueLock lock(m_threadAsyncMutex);
|
ethread::UniqueLock lock(m_threadAsyncMutex);
|
||||||
for (auto &it : m_threadAsyncList2) {
|
for (auto &it : m_threadAsyncList2) {
|
||||||
|
ZEUS_INFO("Add async");
|
||||||
m_threadAsyncList.pushBack(it);
|
m_threadAsyncList.pushBack(it);
|
||||||
}
|
}
|
||||||
m_threadAsyncList2.clear();
|
m_threadAsyncList2.clear();
|
||||||
@ -632,6 +689,7 @@ void zeus::WebServer::threadAsyncCallback() {
|
|||||||
bool ret = (*it)(this);
|
bool ret = (*it)(this);
|
||||||
if (ret == true) {
|
if (ret == true) {
|
||||||
// Remove it ...
|
// Remove it ...
|
||||||
|
ZEUS_INFO("Remove async");
|
||||||
it = m_threadAsyncList.erase(it);
|
it = m_threadAsyncList.erase(it);
|
||||||
} else {
|
} else {
|
||||||
++it;
|
++it;
|
||||||
|
@ -115,6 +115,7 @@ namespace zeus {
|
|||||||
private:
|
private:
|
||||||
enet::WebSocket m_connection; //!< Zeus protocol is based on a webSocket to be compatible with Java-script
|
enet::WebSocket m_connection; //!< Zeus protocol is based on a webSocket to be compatible with Java-script
|
||||||
ethread::Pool m_processingPool; //!< Thread pool processing of the input data
|
ethread::Pool m_processingPool; //!< Thread pool processing of the input data
|
||||||
|
// access only with the tcp thread only
|
||||||
etk::Vector<ememory::SharedPtr<zeus::Message>> m_listPartialMessage; //!< list of all message that data has not finished to arrive.
|
etk::Vector<ememory::SharedPtr<zeus::Message>> m_listPartialMessage; //!< list of all message that data has not finished to arrive.
|
||||||
uint16_t m_localAddress; //!< Local client address.
|
uint16_t m_localAddress; //!< Local client address.
|
||||||
uint16_t m_localIdObjectIncrement; //!< attribute an unique ID for an object.
|
uint16_t m_localIdObjectIncrement; //!< attribute an unique ID for an object.
|
||||||
@ -141,8 +142,18 @@ namespace zeus {
|
|||||||
ethread::UniqueLock lock(m_mutex);
|
ethread::UniqueLock lock(m_mutex);
|
||||||
return m_localIdObjectIncrement++;
|
return m_localIdObjectIncrement++;
|
||||||
}
|
}
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* @brief Get the address of the connection source IP:port or empty string
|
||||||
|
* @return string with the remote address name.
|
||||||
|
*/
|
||||||
|
const etk::String& getRemoteAddress() const {
|
||||||
|
return m_connection.getRemoteAddress();
|
||||||
|
}
|
||||||
private:
|
private:
|
||||||
|
ethread::Mutex m_listObjectMutex; //!< m_listObject object protection
|
||||||
etk::Vector<ememory::SharedPtr<zeus::WebObj>> m_listObject; //!< List of all local object that is reference in the system.
|
etk::Vector<ememory::SharedPtr<zeus::WebObj>> m_listObject; //!< List of all local object that is reference in the system.
|
||||||
|
ethread::Mutex m_listRemoteObjectMutex; //!< m_listObject object protection
|
||||||
etk::Vector<ememory::WeakPtr<zeus::ObjectRemoteBase>> m_listRemoteObject; //!< List of all object that we have a reference in the local interface.
|
etk::Vector<ememory::WeakPtr<zeus::ObjectRemoteBase>> m_listRemoteObject; //!< List of all object that we have a reference in the local interface.
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
@ -165,6 +176,7 @@ namespace zeus {
|
|||||||
void interfaceRemoved(etk::Vector<uint16_t> _list);
|
void interfaceRemoved(etk::Vector<uint16_t> _list);
|
||||||
private:
|
private:
|
||||||
uint32_t m_interfaceId; //!< local client interface ID
|
uint32_t m_interfaceId; //!< local client interface ID
|
||||||
|
// TODO: add a lock here or an atomic get + increment
|
||||||
uint16_t m_transmissionId; //!< Unique Id of a transmission (it is != 0)
|
uint16_t m_transmissionId; //!< Unique Id of a transmission (it is != 0)
|
||||||
/**
|
/**
|
||||||
* @brief Get a new transmission ID
|
* @brief Get a new transmission ID
|
||||||
@ -188,7 +200,15 @@ namespace zeus {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
public:
|
public:
|
||||||
using ObserverRequestUri = etk::Function<bool(const etk::String&)>; //!< Define an Observer on the specific URI requested callback: function pointer (return true if the connection is accepted or not)
|
/**
|
||||||
|
* @brief Declare callback function for URI requesting
|
||||||
|
* @param[in] _uri URI connection (GET)
|
||||||
|
* @param[in] _protocols Protocol requested in the URI (ZEUS:1.0/ZEUS:0.8)
|
||||||
|
* @return "OK" Connection accepted ==> send header
|
||||||
|
* @return "CLOSE" Close the current connection: 404
|
||||||
|
* @return "REDIRECT:IP:port" Redirect at the specific IP and port
|
||||||
|
*/
|
||||||
|
using ObserverRequestUri = etk::Function<etk::String(const etk::String& _uri, const etk::Map<etk::String,etk::String>& _options)>; //!< Define an Observer on the specific URI requested callback: function pointer (return true if the connection is accepted or not)
|
||||||
protected:
|
protected:
|
||||||
ObserverRequestUri m_observerRequestUri; //!< Observer on a requesting URI connection
|
ObserverRequestUri m_observerRequestUri; //!< Observer on a requesting URI connection
|
||||||
public:
|
public:
|
||||||
@ -198,9 +218,9 @@ namespace zeus {
|
|||||||
* @param[in] _func Function to call.
|
* @param[in] _func Function to call.
|
||||||
*/
|
*/
|
||||||
template<class CLASS_TYPE>
|
template<class CLASS_TYPE>
|
||||||
void connectUri(CLASS_TYPE* _class, bool (CLASS_TYPE::*_func)(const etk::String&)) {
|
void connectUri(CLASS_TYPE* _class, etk::String (CLASS_TYPE::*_func)(const etk::String& _uri, const etk::Map<etk::String,etk::String>& _options)) {
|
||||||
m_observerRequestUri = [=](const etk::String& _value){
|
m_observerRequestUri = [=](const etk::String& _uri, const etk::Map<etk::String,etk::String>& _options){
|
||||||
return (*_class.*_func)(_value);
|
return (*_class.*_func)(_uri, _options);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@ -268,10 +288,11 @@ namespace zeus {
|
|||||||
* @brief Called by the underprotocol for a new URI connection
|
* @brief Called by the underprotocol for a new URI connection
|
||||||
* @param[in] _uri URI connection (GET)
|
* @param[in] _uri URI connection (GET)
|
||||||
* @param[in] _protocols Protocol requested in the URI (ZEUS:1.0/ZEUS:0.8)
|
* @param[in] _protocols Protocol requested in the URI (ZEUS:1.0/ZEUS:0.8)
|
||||||
* @return true the connection is accepted
|
* @return "OK" Connection accepted ==> send header
|
||||||
* @return false the connection is rejected
|
* @return "CLOSE" Close the current connection: 404
|
||||||
|
* @return "REDIRECT:IP:port" Redirect at the specific IP and port
|
||||||
*/
|
*/
|
||||||
bool onReceiveUri(const etk::String& _uri, const etk::Vector<etk::String>& _protocols);
|
etk::String onReceiveUri(const etk::String& _uri, const etk::Vector<etk::String>& _protocols);
|
||||||
/**
|
/**
|
||||||
* @brief The Zeus protocol is based on a webSocket, then the connection can send full fragment (it call newMessage when data is parsed
|
* @brief The Zeus protocol is based on a webSocket, then the connection can send full fragment (it call newMessage when data is parsed
|
||||||
* @param[in] _frame A frame that has been just received
|
* @param[in] _frame A frame that has been just received
|
||||||
|
@ -10,6 +10,9 @@
|
|||||||
#include <etk/stdTools.hpp>
|
#include <etk/stdTools.hpp>
|
||||||
#include <zeus/message/Answer.hpp>
|
#include <zeus/message/Answer.hpp>
|
||||||
|
|
||||||
|
#include <etk/typeInfo.hpp>
|
||||||
|
ETK_DECLARE_TYPE(zeus::message::Answer);
|
||||||
|
|
||||||
void zeus::message::Answer::generateDisplay(etk::Stream& _os) const {
|
void zeus::message::Answer::generateDisplay(etk::Stream& _os) const {
|
||||||
zeus::Message::generateDisplay(_os);
|
zeus::Message::generateDisplay(_os);
|
||||||
if (getNumberParameter() != 0) {
|
if (getNumberParameter() != 0) {
|
||||||
|
@ -10,6 +10,10 @@
|
|||||||
#include <etk/stdTools.hpp>
|
#include <etk/stdTools.hpp>
|
||||||
#include <zeus/message/Call.hpp>
|
#include <zeus/message/Call.hpp>
|
||||||
|
|
||||||
|
|
||||||
|
#include <etk/typeInfo.hpp>
|
||||||
|
ETK_DECLARE_TYPE(zeus::message::Call);
|
||||||
|
|
||||||
void zeus::message::Call::generateDisplay(etk::Stream& _os) const {
|
void zeus::message::Call::generateDisplay(etk::Stream& _os) const {
|
||||||
zeus::Message::generateDisplay(_os);
|
zeus::Message::generateDisplay(_os);
|
||||||
_os << " '" + m_callName + "'";
|
_os << " '" + m_callName + "'";
|
||||||
|
@ -10,6 +10,10 @@
|
|||||||
#include <etk/stdTools.hpp>
|
#include <etk/stdTools.hpp>
|
||||||
#include <zeus/message/Data.hpp>
|
#include <zeus/message/Data.hpp>
|
||||||
|
|
||||||
|
|
||||||
|
#include <etk/typeInfo.hpp>
|
||||||
|
ETK_DECLARE_TYPE(zeus::message::Data);
|
||||||
|
|
||||||
void zeus::message::Data::generateDisplay(etk::Stream& _os) const {
|
void zeus::message::Data::generateDisplay(etk::Stream& _os) const {
|
||||||
zeus::Message::generateDisplay(_os);
|
zeus::Message::generateDisplay(_os);
|
||||||
_os << " paramId=" << etk::toString(m_parameterId);
|
_os << " paramId=" << etk::toString(m_parameterId);
|
||||||
|
@ -10,6 +10,10 @@
|
|||||||
#include <etk/stdTools.hpp>
|
#include <etk/stdTools.hpp>
|
||||||
#include <zeus/message/Event.hpp>
|
#include <zeus/message/Event.hpp>
|
||||||
|
|
||||||
|
|
||||||
|
#include <etk/typeInfo.hpp>
|
||||||
|
ETK_DECLARE_TYPE(zeus::message::Event);
|
||||||
|
|
||||||
void zeus::message::Event::generateDisplay(etk::Stream& _os) const {
|
void zeus::message::Event::generateDisplay(etk::Stream& _os) const {
|
||||||
zeus::Message::generateDisplay(_os);
|
zeus::Message::generateDisplay(_os);
|
||||||
if (getNumberParameter() != 0) {
|
if (getNumberParameter() != 0) {
|
||||||
|
@ -17,6 +17,8 @@
|
|||||||
#include <zeus/message/Event.hpp>
|
#include <zeus/message/Event.hpp>
|
||||||
#include <zeus/WebServer.hpp>
|
#include <zeus/WebServer.hpp>
|
||||||
|
|
||||||
|
#include <etk/typeInfo.hpp>
|
||||||
|
ETK_DECLARE_TYPE(zeus::Message);
|
||||||
|
|
||||||
zeus::Message::Message(ememory::SharedPtr<zeus::WebServer> _iface):
|
zeus::Message::Message(ememory::SharedPtr<zeus::WebServer> _iface):
|
||||||
m_iface(_iface) {
|
m_iface(_iface) {
|
||||||
|
@ -8,6 +8,8 @@
|
|||||||
#include <zeus/debug.hpp>
|
#include <zeus/debug.hpp>
|
||||||
#include <zeus/File.hpp>
|
#include <zeus/File.hpp>
|
||||||
|
|
||||||
|
#include <etk/typeInfo.hpp>
|
||||||
|
ETK_DECLARE_TYPE(zeus::message::ParamType);
|
||||||
|
|
||||||
bool zeus::message::checkCompatibility(const ParamType& _type, const ParamType& _params) {
|
bool zeus::message::checkCompatibility(const ParamType& _type, const ParamType& _params) {
|
||||||
if (_params == _type) {
|
if (_params == _type) {
|
||||||
|
@ -12,6 +12,9 @@
|
|||||||
#include <zeus/message/Parameter.hpp>
|
#include <zeus/message/Parameter.hpp>
|
||||||
#include <zeus/File.hpp>
|
#include <zeus/File.hpp>
|
||||||
|
|
||||||
|
#include <etk/typeInfo.hpp>
|
||||||
|
ETK_DECLARE_TYPE(zeus::message::Parameter);
|
||||||
|
|
||||||
zeus::message::Parameter::Parameter(ememory::SharedPtr<zeus::WebServer> _iface):
|
zeus::message::Parameter::Parameter(ememory::SharedPtr<zeus::WebServer> _iface):
|
||||||
Message(_iface) {
|
Message(_iface) {
|
||||||
|
|
||||||
|
@ -7,6 +7,10 @@
|
|||||||
#include <etk/stdTools.hpp>
|
#include <etk/stdTools.hpp>
|
||||||
#include <zeus/message/type.hpp>
|
#include <zeus/message/type.hpp>
|
||||||
|
|
||||||
|
|
||||||
|
#include <etk/typeInfo.hpp>
|
||||||
|
ETK_DECLARE_TYPE(zeus::message::type);
|
||||||
|
|
||||||
namespace etk {
|
namespace etk {
|
||||||
template<> etk::String toString<enum zeus::message::type>(const enum zeus::message::type& _value) {
|
template<> etk::String toString<enum zeus::message::type>(const enum zeus::message::type& _value) {
|
||||||
switch (_value) {
|
switch (_value) {
|
||||||
|
@ -13,6 +13,10 @@
|
|||||||
#include "debug.hpp"
|
#include "debug.hpp"
|
||||||
|
|
||||||
|
|
||||||
|
#include <etk/typeInfo.hpp>
|
||||||
|
ETK_DECLARE_TYPE(zeus::FileImpl);
|
||||||
|
|
||||||
|
|
||||||
ememory::SharedPtr<zeus::File> zeus::File::create(etk::String _fileNameReal) {
|
ememory::SharedPtr<zeus::File> zeus::File::create(etk::String _fileNameReal) {
|
||||||
return ememory::makeShared<zeus::FileImpl>(_fileNameReal);
|
return ememory::makeShared<zeus::FileImpl>(_fileNameReal);
|
||||||
}
|
}
|
||||||
@ -28,16 +32,17 @@ ememory::SharedPtr<zeus::File> zeus::File::create(etk::String _fileNameReal, etk
|
|||||||
return ememory::makeShared<zeus::FileImpl>(_fileNameReal, _fileNameShow, _mineType, _sha512);
|
return ememory::makeShared<zeus::FileImpl>(_fileNameReal, _fileNameShow, _mineType, _sha512);
|
||||||
}
|
}
|
||||||
|
|
||||||
ememory::SharedPtr<zeus::File> zeus::File::create(etk::Vector<uint8_t> _fileNameReal, etk::String _virtualName, etk::String _mineType) {
|
ememory::SharedPtr<zeus::File> zeus::File::create(etk::Vector<uint8_t> _fileData, etk::String _virtualName, etk::String _mineType) {
|
||||||
return ememory::makeShared<zeus::FileImpl>(_fileNameReal, _virtualName, _mineType);
|
return ememory::makeShared<zeus::FileImpl>(etk::move(_fileData), _virtualName, _mineType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
zeus::FileImpl::FileImpl(const etk::Vector<uint8_t>& _value, etk::String _virtualName, etk::String _mineType) :
|
zeus::FileImpl::FileImpl(etk::Vector<uint8_t> _value, etk::String _virtualName, etk::String _mineType) :
|
||||||
m_filename(_virtualName),
|
m_filename(_virtualName),
|
||||||
m_gettedData(0),
|
m_gettedData(0),
|
||||||
m_mineType(_mineType),
|
m_mineType(_mineType),
|
||||||
m_sha512("") {
|
m_sha512("") {
|
||||||
|
ZEUS_ERROR(" ==============>>>>>>>>>>>>>> CREATE FILE");
|
||||||
m_dataRaw = true;
|
m_dataRaw = true;
|
||||||
m_data = _value;
|
m_data = _value;
|
||||||
m_size = m_data.size();
|
m_size = m_data.size();
|
||||||
@ -47,6 +52,7 @@ zeus::FileImpl::FileImpl(etk::String _fileNameReal, etk::String _sha512) :
|
|||||||
m_node(_fileNameReal),
|
m_node(_fileNameReal),
|
||||||
m_gettedData(0),
|
m_gettedData(0),
|
||||||
m_sha512(_sha512) {
|
m_sha512(_sha512) {
|
||||||
|
ZEUS_ERROR(" ==============>>>>>>>>>>>>>> CREATE FILE");
|
||||||
m_size = m_node.fileSize();
|
m_size = m_node.fileSize();
|
||||||
etk::String extention;
|
etk::String extention;
|
||||||
if ( _fileNameReal.rfind('.') != etk::String::npos
|
if ( _fileNameReal.rfind('.') != etk::String::npos
|
||||||
@ -69,6 +75,7 @@ zeus::FileImpl::FileImpl(etk::String _fileNameReal, etk::String _fileNameShow, e
|
|||||||
m_gettedData(0),
|
m_gettedData(0),
|
||||||
m_mineType(_mineType),
|
m_mineType(_mineType),
|
||||||
m_sha512(_sha512) {
|
m_sha512(_sha512) {
|
||||||
|
ZEUS_ERROR(" ==============>>>>>>>>>>>>>> CREATE FILE");
|
||||||
m_size = m_node.fileSize();
|
m_size = m_node.fileSize();
|
||||||
if ( _sha512.size() > 0
|
if ( _sha512.size() > 0
|
||||||
&& _sha512.size() != 128) {
|
&& _sha512.size() != 128) {
|
||||||
@ -78,6 +85,7 @@ zeus::FileImpl::FileImpl(etk::String _fileNameReal, etk::String _fileNameShow, e
|
|||||||
}
|
}
|
||||||
|
|
||||||
zeus::FileImpl::~FileImpl() {
|
zeus::FileImpl::~FileImpl() {
|
||||||
|
ZEUS_ERROR(" <<<<<<<<<<<<<<============== DESTROY FILE");
|
||||||
if (m_node.fileIsOpen() == true) {
|
if (m_node.fileIsOpen() == true) {
|
||||||
m_node.fileClose();
|
m_node.fileClose();
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ namespace zeus {
|
|||||||
public:
|
public:
|
||||||
FileImpl(etk::String _fileNameReal, etk::String _fileNameShow, etk::String _mineType, etk::String _sha512="");
|
FileImpl(etk::String _fileNameReal, etk::String _fileNameShow, etk::String _mineType, etk::String _sha512="");
|
||||||
FileImpl(etk::String _fileNameReal, etk::String _sha512="");
|
FileImpl(etk::String _fileNameReal, etk::String _sha512="");
|
||||||
FileImpl(const etk::Vector<uint8_t>& _value, etk::String _virtualName, etk::String _mineType);
|
FileImpl(etk::Vector<uint8_t> _value, etk::String _virtualName, etk::String _mineType);
|
||||||
~FileImpl();
|
~FileImpl();
|
||||||
uint64_t getSize() override;
|
uint64_t getSize() override;
|
||||||
etk::String getName() override;
|
etk::String getName() override;
|
||||||
|
@ -11,6 +11,10 @@
|
|||||||
#include <etk/os/FSNode.hpp>
|
#include <etk/os/FSNode.hpp>
|
||||||
#include "debug.hpp"
|
#include "debug.hpp"
|
||||||
|
|
||||||
|
|
||||||
|
#include <etk/typeInfo.hpp>
|
||||||
|
ETK_DECLARE_TYPE(zeus::MediaImpl);
|
||||||
|
|
||||||
ememory::SharedPtr<zeus::Media> zeus::Media::create(etk::String _fileNameReal) {
|
ememory::SharedPtr<zeus::Media> zeus::Media::create(etk::String _fileNameReal) {
|
||||||
return ememory::makeShared<zeus::MediaImpl>(0, _fileNameReal);
|
return ememory::makeShared<zeus::MediaImpl>(0, _fileNameReal);
|
||||||
}
|
}
|
||||||
@ -31,6 +35,7 @@ ejson::Object zeus::MediaImpl::getJson() {
|
|||||||
|
|
||||||
zeus::MediaImpl::MediaImpl(const etk::String& _basePath, ejson::Object _property) :
|
zeus::MediaImpl::MediaImpl(const etk::String& _basePath, ejson::Object _property) :
|
||||||
m_basePath(_basePath) {
|
m_basePath(_basePath) {
|
||||||
|
ZEUS_ERROR(" ==============>>>>>>>>>>>>>> CREATE MEDIA");
|
||||||
m_id = _property["id"].toNumber().getU64();
|
m_id = _property["id"].toNumber().getU64();
|
||||||
ZEUS_INFO("get ID : " << m_id);
|
ZEUS_INFO("get ID : " << m_id);
|
||||||
m_fileName = _property["file-name"].toString().get();
|
m_fileName = _property["file-name"].toString().get();
|
||||||
@ -53,6 +58,7 @@ zeus::MediaImpl::MediaImpl(uint64_t _id, const etk::String& _fileNameReal, const
|
|||||||
m_id(_id),
|
m_id(_id),
|
||||||
m_basePath(_basePath),
|
m_basePath(_basePath),
|
||||||
m_fileName(_fileNameReal) {
|
m_fileName(_fileNameReal) {
|
||||||
|
ZEUS_ERROR(" ==============>>>>>>>>>>>>>> CREATE MEDIA");
|
||||||
etk::String extention;
|
etk::String extention;
|
||||||
if ( m_fileName.rfind('.') != etk::String::npos
|
if ( m_fileName.rfind('.') != etk::String::npos
|
||||||
&& m_fileName.rfind('.') != 0) {
|
&& m_fileName.rfind('.') != 0) {
|
||||||
@ -66,6 +72,7 @@ zeus::MediaImpl::MediaImpl(uint64_t _id, const etk::String& _fileNameReal, const
|
|||||||
}
|
}
|
||||||
|
|
||||||
zeus::MediaImpl::~MediaImpl() {
|
zeus::MediaImpl::~MediaImpl() {
|
||||||
|
ZEUS_ERROR(" <<<<<<<<<<<<<<============== DESTROY MEDIA");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user