[DEV] nearly finish the send and get file
This commit is contained in:
parent
615486529d
commit
d13a239878
@ -463,7 +463,7 @@ class ServiceDefinition:
|
||||
"""
|
||||
out += " addType(data, createType<" + class_name + ">());\n"
|
||||
"""
|
||||
out += " addTypeObject(data, \"" + class_name + "\");\n"
|
||||
out += " addTypeObject(data, \"obj:" + class_name + "\");\n"
|
||||
out += " int32_t currentOffset = data.size();\n"
|
||||
out += " int32_t startOffset = data.size();\n"
|
||||
out += " data.resize(data.size()+4);\n"
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include <etk/etk.hpp>
|
||||
#include <zeus/zeus.hpp>
|
||||
#include <etk/os/FSNode.hpp>
|
||||
#include <elog/elog.hpp>
|
||||
|
||||
|
||||
#include <etk/stdTools.hpp>
|
||||
@ -23,6 +24,7 @@
|
||||
|
||||
int main(int _argc, const char *_argv[]) {
|
||||
etk::init(_argc, _argv);
|
||||
elog::init(_argc, _argv);
|
||||
zeus::init(_argc, _argv);
|
||||
zeus::Client client1;
|
||||
for (int32_t iii=0; iii<_argc ; ++iii) {
|
||||
@ -92,7 +94,7 @@ int main(int _argc, const char *_argv[]) {
|
||||
}
|
||||
*/
|
||||
|
||||
if (true) {
|
||||
if (false) {
|
||||
APPL_INFO(" ----------------------------------");
|
||||
APPL_INFO(" -- Get service system-user");
|
||||
APPL_INFO(" ----------------------------------");
|
||||
@ -143,6 +145,7 @@ int main(int _argc, const char *_argv[]) {
|
||||
if (true) {
|
||||
zeus::service::ProxyPicture remoteServicePicture = client1.getService("picture");
|
||||
if (remoteServicePicture.exist() == true) {
|
||||
#if 0
|
||||
zeus::Future<std::vector<std::string>> retCall = remoteServicePicture.getAlbums().wait();
|
||||
APPL_INFO(" album list: ");
|
||||
for (auto &it : retCall.get()) {
|
||||
@ -166,7 +169,7 @@ int main(int _argc, const char *_argv[]) {
|
||||
APPL_INFO(" - " << it3);
|
||||
// TODO : This is really bad : Do it better ...
|
||||
zeus::Future<ememory::SharedPtr<zeus::ObjectRemoteBase>> retListImage = remoteServicePicture.getAlbumListPicture(it3).wait();
|
||||
zeus::ProxyFile tmpFile = zeus::ObjectRemote(retListImage.get(client1.m_interfaceWeb));
|
||||
zeus::ProxyFile tmpFile = zeus::ObjectRemote(retListImage.get());
|
||||
APPL_INFO(" mine-type: " << tmpFile.getMineType().wait().get());
|
||||
APPL_INFO(" size: " << tmpFile.size().wait().get());
|
||||
APPL_INFO(" receive in =" << int64_t(retListImage.getTransmitionTime().count()/1000)/1000.0 << " ms");
|
||||
@ -184,15 +187,16 @@ int main(int _argc, const char *_argv[]) {
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if 1
|
||||
echrono::Steady start = echrono::Steady::now();
|
||||
//zeus::File tmp("./testzz.png");
|
||||
// TODO : Read file size before ..
|
||||
int32_t size = 1024;
|
||||
ememory::SharedPtr<zeus::File> tmp = zeus::File::create("./tmpResult.bmp");
|
||||
zeus::FutureBase retSendImage = remoteServicePicture.addFile(tmp).wait();
|
||||
auto retSendImage = remoteServicePicture.addFile(tmp).wait();
|
||||
echrono::Steady stop = echrono::Steady::now();
|
||||
APPL_WARNING(" IO*=" << (stop-start));
|
||||
APPL_WARNING(" IO*=" << (stop-start) << " " << retSendImage.get());
|
||||
double megaParSec = double(size)/(double((stop-start).count())/1000000000.0);
|
||||
APPL_WARNING(" speed=" << int64_t(megaParSec/1024.0)/1024.0 << " Mo/s");
|
||||
#endif
|
||||
|
@ -189,8 +189,11 @@ namespace appl {
|
||||
}
|
||||
std::string addFile(zeus::ProxyFile _dataFile) {
|
||||
std::unique_lock<std::mutex> lock(g_mutex);
|
||||
APPL_ERROR("Call add file ... ");
|
||||
// TODO : Check right ...
|
||||
uint64_t id = createFileID();
|
||||
APPL_ERROR("New ID : " << id);
|
||||
/*
|
||||
auto fut = _dataFile.getPart(0, 6400);
|
||||
fut.andThen([](zeus::FutureBase _data){
|
||||
zeus::Future<zeus::Raw> data(_data);
|
||||
@ -198,6 +201,29 @@ namespace appl {
|
||||
APPL_ERROR("Get data In andThen " << ppp.size());
|
||||
return true;
|
||||
});
|
||||
*/
|
||||
auto futType = _dataFile.getMineType();
|
||||
auto futName = _dataFile.getName();
|
||||
auto futSize = _dataFile.getSize();
|
||||
futType.wait();
|
||||
APPL_ERROR("mine-type : " << futType.get());
|
||||
futName.wait();
|
||||
APPL_ERROR("name : " << futName.get());
|
||||
futSize.wait();
|
||||
APPL_ERROR("size : " << futSize.get());
|
||||
int64_t retSize = futSize.get();
|
||||
int64_t offset = 0;
|
||||
while (retSize > 0) {
|
||||
int32_t nbElement = 4096;
|
||||
if (retSize<nbElement) {
|
||||
nbElement = retSize;
|
||||
}
|
||||
auto futData = _dataFile.getPart(offset, offset + nbElement);
|
||||
futData.wait();
|
||||
offset += nbElement;
|
||||
retSize -= nbElement;
|
||||
}
|
||||
|
||||
/*
|
||||
APPL_ERROR(" ==> Receive FILE " << _dataFile.getMineType() << " size=" << _dataFile.getData().size());
|
||||
std::stringstream val;
|
||||
@ -208,7 +234,7 @@ namespace appl {
|
||||
_dataFile.storeIn(g_basePath + filename);
|
||||
m_listFile.insert(std::make_pair(id, filename));
|
||||
*/
|
||||
return etk::to_string(id);//zeus::FileServer();
|
||||
return etk::to_string(id);
|
||||
}
|
||||
/*
|
||||
// Return a global UTC time
|
||||
|
@ -32,10 +32,10 @@ namespace zeus {
|
||||
// clang generate a basic warning:
|
||||
// warning: multiple unsequenced modifications to 'idParam' [-Wunsequenced]
|
||||
int32_t idParam = 0;
|
||||
ret = (*_pointer.*_func)(_obj->getParameter<ZEUS_TYPES>(idParam++)...);
|
||||
ret = (*_pointer.*_func)(_obj->getParameter<ZEUS_TYPES>(_interfaceClient, idParam++)...);
|
||||
} else {
|
||||
int32_t idParam = int32_t(sizeof...(ZEUS_TYPES))-1;
|
||||
ret = (*_pointer.*_func)(_obj->getParameter<ZEUS_TYPES>(idParam--)...);
|
||||
ret = (*_pointer.*_func)(_obj->getParameter<ZEUS_TYPES>(_interfaceClient, idParam--)...);
|
||||
}
|
||||
if (_interfaceClient == nullptr) {
|
||||
ZEUS_ERROR("Nullptr for _interfaceWeb");
|
||||
@ -65,10 +65,10 @@ namespace zeus {
|
||||
// clang generate a basic warning:
|
||||
// warning: multiple unsequenced modifications to 'idParam' [-Wunsequenced]
|
||||
int32_t idParam = 0;
|
||||
(*_pointer.*_func)(_obj->getParameter<ZEUS_TYPES>(idParam++)...);
|
||||
(*_pointer.*_func)(_obj->getParameter<ZEUS_TYPES>(_interfaceClient, idParam++)...);
|
||||
} else {
|
||||
int32_t idParam = int32_t(sizeof...(ZEUS_TYPES))-1;
|
||||
(*_pointer.*_func)(_obj->getParameter<ZEUS_TYPES>(idParam--)...);
|
||||
(*_pointer.*_func)(_obj->getParameter<ZEUS_TYPES>(_interfaceClient, idParam--)...);
|
||||
}
|
||||
if (_interfaceClient == nullptr) {
|
||||
ZEUS_ERROR("Nullptr for _interfaceWeb");
|
||||
|
@ -27,10 +27,10 @@ namespace zeus {
|
||||
// clang generate a basic warning:
|
||||
// warning: multiple unsequenced modifications to 'idParam' [-Wunsequenced]
|
||||
int32_t idParam = 0;
|
||||
ret = _func(_obj->getParameter<ZEUS_TYPES>(idParam++)...);
|
||||
ret = _func(_obj->getParameter<ZEUS_TYPES>(_interfaceClient, idParam++)...);
|
||||
} else {
|
||||
int32_t idParam = int32_t(sizeof...(ZEUS_TYPES))-1;
|
||||
ret = _func(_obj->getParameter<ZEUS_TYPES>(idParam--)...);
|
||||
ret = _func(_obj->getParameter<ZEUS_TYPES>(_interfaceClient, idParam--)...);
|
||||
}
|
||||
if (_interfaceClient == nullptr) {
|
||||
ZEUS_ERROR("Nullptr for _interfaceWeb");
|
||||
@ -58,10 +58,10 @@ namespace zeus {
|
||||
// clang generate a basic warning:
|
||||
// warning: multiple unsequenced modifications to 'idParam' [-Wunsequenced]
|
||||
int32_t idParam = 0;
|
||||
_func(_obj->getParameter<ZEUS_TYPES>(idParam++)...);
|
||||
_func(_obj->getParameter<ZEUS_TYPES>(_interfaceClient, idParam++)...);
|
||||
} else {
|
||||
int32_t idParam = int32_t(sizeof...(ZEUS_TYPES))-1;
|
||||
_func(_obj->getParameter<ZEUS_TYPES>(idParam--)...);
|
||||
_func(_obj->getParameter<ZEUS_TYPES>(_interfaceClient, idParam--)...);
|
||||
}
|
||||
if (_interfaceClient == nullptr) {
|
||||
ZEUS_ERROR("Nullptr for _interfaceWeb");
|
||||
|
@ -16,6 +16,8 @@
|
||||
#include <zeus/BufferData.hpp>
|
||||
#include <zeus/BufferFlow.hpp>
|
||||
#include <zeus/BufferEvent.hpp>
|
||||
#include <zeus/WebServer.hpp>
|
||||
|
||||
|
||||
namespace etk {
|
||||
template<> std::string to_string<enum zeus::Buffer::typeMessage>(const enum zeus::Buffer::typeMessage& _value) {
|
||||
@ -59,7 +61,8 @@ static enum zeus::Buffer::typeMessage getTypeType(uint16_t _value) {
|
||||
return zeus::Buffer::typeMessage::unknow;
|
||||
}
|
||||
|
||||
zeus::Buffer::Buffer() {
|
||||
zeus::Buffer::Buffer(ememory::SharedPtr<zeus::WebServer> _iface):
|
||||
m_iface(_iface) {
|
||||
clear();
|
||||
}
|
||||
|
||||
@ -230,11 +233,11 @@ enum zeus::Buffer::typeMessage zeus::Buffer::getType() const {
|
||||
// ------------------------------------------------------------------------------------
|
||||
// -- Factory
|
||||
// ------------------------------------------------------------------------------------
|
||||
ememory::SharedPtr<zeus::Buffer> zeus::Buffer::create() {
|
||||
return ememory::SharedPtr<zeus::Buffer>(new zeus::Buffer);
|
||||
ememory::SharedPtr<zeus::Buffer> zeus::Buffer::create(ememory::SharedPtr<zeus::WebServer> _iface) {
|
||||
return ememory::SharedPtr<zeus::Buffer>(new zeus::Buffer(_iface));
|
||||
}
|
||||
|
||||
ememory::SharedPtr<zeus::Buffer> zeus::Buffer::create(const std::vector<uint8_t>& _buffer) {
|
||||
ememory::SharedPtr<zeus::Buffer> zeus::Buffer::create(ememory::SharedPtr<zeus::WebServer> _iface, const std::vector<uint8_t>& _buffer) {
|
||||
headerBin header;
|
||||
if (_buffer.size() < sizeof(headerBin)) {
|
||||
ZEUS_ERROR("wrong size of the buffer");
|
||||
@ -246,7 +249,7 @@ ememory::SharedPtr<zeus::Buffer> zeus::Buffer::create(const std::vector<uint8_t>
|
||||
case zeus::Buffer::typeMessage::unknow:
|
||||
return nullptr;
|
||||
case zeus::Buffer::typeMessage::ctrl: {
|
||||
ememory::SharedPtr<zeus::BufferCtrl> value = zeus::BufferCtrl::create();
|
||||
ememory::SharedPtr<zeus::BufferCtrl> value = zeus::BufferCtrl::create(_iface);
|
||||
if (value == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
@ -262,7 +265,7 @@ ememory::SharedPtr<zeus::Buffer> zeus::Buffer::create(const std::vector<uint8_t>
|
||||
}
|
||||
break;
|
||||
case zeus::Buffer::typeMessage::call: {
|
||||
ememory::SharedPtr<zeus::BufferCall> value = zeus::BufferCall::create();
|
||||
ememory::SharedPtr<zeus::BufferCall> value = zeus::BufferCall::create(_iface);
|
||||
if (value == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
@ -278,7 +281,7 @@ ememory::SharedPtr<zeus::Buffer> zeus::Buffer::create(const std::vector<uint8_t>
|
||||
}
|
||||
break;
|
||||
case zeus::Buffer::typeMessage::answer: {
|
||||
ememory::SharedPtr<zeus::BufferAnswer> value = zeus::BufferAnswer::create();
|
||||
ememory::SharedPtr<zeus::BufferAnswer> value = zeus::BufferAnswer::create(_iface);
|
||||
if (value == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
@ -294,7 +297,7 @@ ememory::SharedPtr<zeus::Buffer> zeus::Buffer::create(const std::vector<uint8_t>
|
||||
}
|
||||
break;
|
||||
case zeus::Buffer::typeMessage::data: {
|
||||
ememory::SharedPtr<zeus::BufferData> value = zeus::BufferData::create();
|
||||
ememory::SharedPtr<zeus::BufferData> value = zeus::BufferData::create(_iface);
|
||||
if (value == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -104,11 +104,13 @@ namespace zeus {
|
||||
*/
|
||||
class Buffer {
|
||||
friend std::ostream& operator<<(std::ostream&, zeus::Buffer*);
|
||||
protected:
|
||||
ememory::SharedPtr<zeus::WebServer> m_iface;
|
||||
protected:
|
||||
/**
|
||||
* @brief basic constructor (hidden to force the use of ememory::SharedPtr) @ref zeus::Buffer::create
|
||||
*/
|
||||
Buffer();
|
||||
Buffer(ememory::SharedPtr<zeus::WebServer> _iface);
|
||||
public:
|
||||
/**
|
||||
* Virtualize the buffer class
|
||||
@ -118,13 +120,13 @@ namespace zeus {
|
||||
* @brief Create a shared pointer on the buffer
|
||||
* @return Allocated Buffer.
|
||||
*/
|
||||
static ememory::SharedPtr<zeus::Buffer> create();
|
||||
static ememory::SharedPtr<zeus::Buffer> create(ememory::SharedPtr<zeus::WebServer> _iface);
|
||||
/**
|
||||
* @brief Create a shared pointer on the buffer
|
||||
* @param[in] _buffer Buffer on the data
|
||||
* @return Allocated Buffer.
|
||||
*/
|
||||
static ememory::SharedPtr<zeus::Buffer> create(const std::vector<uint8_t>& _buffer);
|
||||
static ememory::SharedPtr<zeus::Buffer> create(ememory::SharedPtr<zeus::WebServer> _iface, const std::vector<uint8_t>& _buffer);
|
||||
protected:
|
||||
uint32_t m_interfaceID; //!< For debug ==> unterface ID ...
|
||||
headerBin m_header; //!< header of the protocol
|
||||
|
@ -80,7 +80,7 @@ void zeus::BufferAnswer::appendBufferData(ememory::SharedPtr<zeus::BufferData> _
|
||||
// -- Factory
|
||||
// ------------------------------------------------------------------------------------
|
||||
|
||||
ememory::SharedPtr<zeus::BufferAnswer> zeus::BufferAnswer::create() {
|
||||
return ememory::SharedPtr<zeus::BufferAnswer>(new zeus::BufferAnswer);
|
||||
ememory::SharedPtr<zeus::BufferAnswer> zeus::BufferAnswer::create(ememory::SharedPtr<zeus::WebServer> _iface) {
|
||||
return ememory::SharedPtr<zeus::BufferAnswer>(new zeus::BufferAnswer(_iface));
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,8 @@ namespace zeus {
|
||||
/**
|
||||
* @brief basic constructor (hidden to force the use of ememory::SharedPtr) @ref zeus::BufferAnswer::create
|
||||
*/
|
||||
BufferAnswer() {
|
||||
BufferAnswer(ememory::SharedPtr<zeus::WebServer> _iface):
|
||||
zeus::BufferParameter(_iface) {
|
||||
m_header.flags = ZEUS_BUFFER_FLAG_FINISH + uint8_t(zeus::Buffer::typeMessage::answer);
|
||||
};
|
||||
void composeWith(const uint8_t* _buffer, uint32_t _lenght) override;
|
||||
@ -33,7 +34,7 @@ namespace zeus {
|
||||
* @brief Create a shared pointer on the BufferAnswer
|
||||
* @return Allocated Buffer.
|
||||
*/
|
||||
static ememory::SharedPtr<zeus::BufferAnswer> create();
|
||||
static ememory::SharedPtr<zeus::BufferAnswer> create(ememory::SharedPtr<zeus::WebServer> _iface);
|
||||
public:
|
||||
enum zeus::Buffer::typeMessage getType() const override {
|
||||
return zeus::Buffer::typeMessage::answer;
|
||||
@ -50,14 +51,9 @@ namespace zeus {
|
||||
* @brief get the answer value
|
||||
* @param[in] Data of the answer
|
||||
*/
|
||||
// TODO : Do it better check error ... ==> can be good ...
|
||||
template<class ZEUS_TYPE_DATA>
|
||||
ZEUS_TYPE_DATA getAnswer() const {
|
||||
return getParameter<ZEUS_TYPE_DATA>(0);
|
||||
}
|
||||
template<class ZEUS_TYPE_DATA>
|
||||
ZEUS_TYPE_DATA getAnswer(const ememory::SharedPtr<zeus::WebServer>& _iface) const {
|
||||
return getParameter<ZEUS_TYPE_DATA>(_iface, 0);
|
||||
return getParameter<ZEUS_TYPE_DATA>(m_iface, 0);
|
||||
}
|
||||
/**
|
||||
* @brief Ann an error on the message answer
|
||||
|
@ -64,6 +64,6 @@ void zeus::BufferCall::appendBufferData(ememory::SharedPtr<zeus::BufferData> _ob
|
||||
// ------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
ememory::SharedPtr<zeus::BufferCall> zeus::BufferCall::create() {
|
||||
return ememory::SharedPtr<zeus::BufferCall>(new zeus::BufferCall);
|
||||
ememory::SharedPtr<zeus::BufferCall> zeus::BufferCall::create(ememory::SharedPtr<zeus::WebServer> _iface) {
|
||||
return ememory::SharedPtr<zeus::BufferCall>(new zeus::BufferCall(_iface));
|
||||
}
|
||||
|
@ -20,7 +20,8 @@ namespace zeus {
|
||||
/**
|
||||
* @brief basic constructor (hidden to force the use of ememory::SharedPtr) @ref zeus::BufferCall::create
|
||||
*/
|
||||
BufferCall() {
|
||||
BufferCall(ememory::SharedPtr<zeus::WebServer> _iface):
|
||||
zeus::BufferParameter(_iface) {
|
||||
m_header.flags = ZEUS_BUFFER_FLAG_FINISH + uint8_t(zeus::Buffer::typeMessage::call);
|
||||
};
|
||||
void composeWith(const uint8_t* _buffer, uint32_t _lenght) override;
|
||||
@ -32,7 +33,7 @@ namespace zeus {
|
||||
* @brief Create a shared pointer on the BufferCall
|
||||
* @return Allocated Buffer.
|
||||
*/
|
||||
static ememory::SharedPtr<zeus::BufferCall> create();
|
||||
static ememory::SharedPtr<zeus::BufferCall> create(ememory::SharedPtr<zeus::WebServer> _iface);
|
||||
public:
|
||||
enum zeus::Buffer::typeMessage getType() const override {
|
||||
return zeus::Buffer::typeMessage::call;
|
||||
|
@ -52,6 +52,6 @@ void zeus::BufferCtrl::appendBufferData(ememory::SharedPtr<zeus::BufferData> _ob
|
||||
// ------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
ememory::SharedPtr<zeus::BufferCtrl> zeus::BufferCtrl::create() {
|
||||
return ememory::SharedPtr<zeus::BufferCtrl>(new zeus::BufferCtrl);
|
||||
ememory::SharedPtr<zeus::BufferCtrl> zeus::BufferCtrl::create(ememory::SharedPtr<zeus::WebServer> _iface) {
|
||||
return ememory::SharedPtr<zeus::BufferCtrl>(new zeus::BufferCtrl(_iface));
|
||||
}
|
||||
|
@ -19,7 +19,8 @@ namespace zeus {
|
||||
/**
|
||||
* @brief basic constructor (hidden to force the use of ememory::SharedPtr) @ref zeus::BufferCall::create
|
||||
*/
|
||||
BufferCtrl() {
|
||||
BufferCtrl(ememory::SharedPtr<zeus::WebServer> _iface):
|
||||
zeus::Buffer(_iface) {
|
||||
m_header.flags = ZEUS_BUFFER_FLAG_FINISH + uint8_t(zeus::Buffer::typeMessage::ctrl);
|
||||
};
|
||||
void composeWith(const uint8_t* _buffer, uint32_t _lenght) override;
|
||||
@ -31,7 +32,7 @@ namespace zeus {
|
||||
* @brief Create a shared pointer on the BufferCall
|
||||
* @return Allocated Buffer.
|
||||
*/
|
||||
static ememory::SharedPtr<zeus::BufferCtrl> create();
|
||||
static ememory::SharedPtr<zeus::BufferCtrl> create(ememory::SharedPtr<zeus::WebServer> _iface);
|
||||
public:
|
||||
enum zeus::Buffer::typeMessage getType() const override {
|
||||
return zeus::Buffer::typeMessage::ctrl;
|
||||
|
@ -62,6 +62,6 @@ void zeus::BufferData::composeWith(const uint8_t* _buffer, uint32_t _lenght) {
|
||||
// -- Factory
|
||||
// ------------------------------------------------------------------------------------
|
||||
|
||||
ememory::SharedPtr<zeus::BufferData> zeus::BufferData::create() {
|
||||
return ememory::SharedPtr<zeus::BufferData>(new zeus::BufferData);
|
||||
ememory::SharedPtr<zeus::BufferData> zeus::BufferData::create(ememory::SharedPtr<zeus::WebServer> _iface) {
|
||||
return ememory::SharedPtr<zeus::BufferData>(new zeus::BufferData(_iface));
|
||||
}
|
||||
|
@ -22,7 +22,8 @@ namespace zeus {
|
||||
/**
|
||||
* @brief basic constructor (hidden to force the use of ememory::SharedPtr) @ref zeus::BufferData::create
|
||||
*/
|
||||
BufferData():
|
||||
BufferData(ememory::SharedPtr<zeus::WebServer> _iface):
|
||||
zeus::Buffer(_iface),
|
||||
m_partId(0) {
|
||||
m_header.flags = ZEUS_BUFFER_FLAG_FINISH + uint8_t(zeus::Buffer::typeMessage::data);
|
||||
};
|
||||
@ -35,7 +36,7 @@ namespace zeus {
|
||||
* @brief Create a shared pointer on the BufferData
|
||||
* @return Allocated Buffer.
|
||||
*/
|
||||
static ememory::SharedPtr<zeus::BufferData> create();
|
||||
static ememory::SharedPtr<zeus::BufferData> create(ememory::SharedPtr<zeus::WebServer> _iface);
|
||||
public:
|
||||
enum zeus::Buffer::typeMessage getType() const override {
|
||||
return zeus::Buffer::typeMessage::data;
|
||||
|
@ -12,6 +12,11 @@
|
||||
#include <zeus/BufferParameter.hpp>
|
||||
#include <zeus/File.hpp>
|
||||
|
||||
zeus::BufferParameter::BufferParameter(ememory::SharedPtr<zeus::WebServer> _iface):
|
||||
Buffer(_iface) {
|
||||
|
||||
}
|
||||
|
||||
bool zeus::BufferParameter::writeOn(enet::WebSocket& _interface) {
|
||||
uint8_t* data = nullptr;
|
||||
uint32_t dataSize = 0;
|
||||
|
@ -16,20 +16,24 @@ namespace zeus {
|
||||
protected:
|
||||
mutable std::vector<std::pair<int32_t,std::vector<uint8_t>>> m_parameter; //!< list of the parameter (offset of start data and buffer of data (subprotocol...)
|
||||
public:
|
||||
BufferParameter(ememory::SharedPtr<zeus::WebServer> _iface);
|
||||
/**
|
||||
* @brief Template to get a parameter with a specific type
|
||||
* @param[in] _id Number of the parameter
|
||||
* @return Converted type of the parameter (or empty value)
|
||||
*/
|
||||
template<class ZEUS_TYPE_DATA>
|
||||
ZEUS_TYPE_DATA getParameter(int32_t _id) const;
|
||||
/**
|
||||
* @brief Template to get a parameter with a specific type
|
||||
* @param[in] _id Number of the parameter
|
||||
* @param[in] _iface IO Web interface
|
||||
* @return Converted type of the parameter (or empty value)
|
||||
*/
|
||||
template<class ZEUS_TYPE_DATA>
|
||||
ZEUS_TYPE_DATA getParameter(const ememory::SharedPtr<zeus::WebServer>& _iface, int32_t _id) const;
|
||||
/**
|
||||
* @brief Template to get a parameter with a specific type
|
||||
* @param[in] _id Number of the parameter
|
||||
* @return Converted type of the parameter (or empty value)
|
||||
*/
|
||||
template<class ZEUS_TYPE_DATA>
|
||||
ZEUS_TYPE_DATA getParameter(int32_t _id) const {
|
||||
return getParameter<ZEUS_TYPE_DATA>(m_iface, _id);
|
||||
}
|
||||
/**
|
||||
* @brief Get the type of a parameter.
|
||||
* @param[in] _id Number of the parameter
|
||||
|
@ -324,12 +324,13 @@ namespace zeus {
|
||||
~SendData() {
|
||||
|
||||
}
|
||||
// TODO : Set it with a sharedPtr instaed of pointer ...
|
||||
bool operator() (zeus::WebServer* _interface,
|
||||
uint32_t _source,
|
||||
uint32_t _destination,
|
||||
uint32_t _transactionId,
|
||||
uint32_t _partId) {
|
||||
ememory::SharedPtr<zeus::BufferData> answer = zeus::BufferData::create();
|
||||
ememory::SharedPtr<zeus::BufferData> answer = zeus::BufferData::create(_interface->sharedFromThis());
|
||||
answer->setTransactionId(_transactionId);
|
||||
answer->setSource(_source);
|
||||
answer->setDestination(_destination);
|
||||
|
@ -14,7 +14,7 @@
|
||||
#include <climits>
|
||||
namespace zeus {
|
||||
template<>
|
||||
bool BufferParameter::getParameter<bool>(int32_t _id) const {
|
||||
bool BufferParameter::getParameter<bool>(const ememory::SharedPtr<zeus::WebServer>& _iface, int32_t _id) const {
|
||||
zeus::ParamType type = getParameterType(_id);
|
||||
const uint8_t* pointer = getParameterPointer(_id);
|
||||
uint32_t dataSize = getParameterSize(_id);
|
||||
@ -31,7 +31,7 @@ namespace zeus {
|
||||
}
|
||||
|
||||
template<>
|
||||
std::string BufferParameter::getParameter<std::string>(int32_t _id) const {
|
||||
std::string BufferParameter::getParameter<std::string>(const ememory::SharedPtr<zeus::WebServer>& _iface, int32_t _id) const {
|
||||
std::string out;
|
||||
zeus::ParamType type = getParameterType(_id);
|
||||
const uint8_t* pointer = getParameterPointer(_id);
|
||||
@ -43,7 +43,7 @@ namespace zeus {
|
||||
|
||||
|
||||
template<>
|
||||
uint8_t BufferParameter::getParameter<uint8_t>(int32_t _id) const {
|
||||
uint8_t BufferParameter::getParameter<uint8_t>(const ememory::SharedPtr<zeus::WebServer>& _iface, int32_t _id) const {
|
||||
zeus::ParamType type = getParameterType(_id);
|
||||
const uint8_t* pointer = getParameterPointer(_id);
|
||||
uint32_t dataSize = getParameterSize(_id);
|
||||
@ -83,7 +83,7 @@ namespace zeus {
|
||||
return 0;
|
||||
}
|
||||
template<>
|
||||
uint16_t BufferParameter::getParameter<uint16_t>(int32_t _id) const {
|
||||
uint16_t BufferParameter::getParameter<uint16_t>(const ememory::SharedPtr<zeus::WebServer>& _iface, int32_t _id) const {
|
||||
zeus::ParamType type = getParameterType(_id);
|
||||
const uint8_t* pointer = getParameterPointer(_id);
|
||||
uint32_t dataSize = getParameterSize(_id);
|
||||
@ -124,7 +124,7 @@ namespace zeus {
|
||||
}
|
||||
|
||||
template<>
|
||||
uint32_t BufferParameter::getParameter<uint32_t>(int32_t _id) const {
|
||||
uint32_t BufferParameter::getParameter<uint32_t>(const ememory::SharedPtr<zeus::WebServer>& _iface, int32_t _id) const {
|
||||
zeus::ParamType type = getParameterType(_id);
|
||||
const uint8_t* pointer = getParameterPointer(_id);
|
||||
uint32_t dataSize = getParameterSize(_id);
|
||||
@ -165,7 +165,7 @@ namespace zeus {
|
||||
}
|
||||
|
||||
template<>
|
||||
uint64_t BufferParameter::getParameter<uint64_t>(int32_t _id) const {
|
||||
uint64_t BufferParameter::getParameter<uint64_t>(const ememory::SharedPtr<zeus::WebServer>& _iface, int32_t _id) const {
|
||||
zeus::ParamType type = getParameterType(_id);
|
||||
const uint8_t* pointer = getParameterPointer(_id);
|
||||
uint32_t dataSize = getParameterSize(_id);
|
||||
@ -208,12 +208,12 @@ namespace zeus {
|
||||
#if defined(__TARGET_OS__MacOs) \
|
||||
|| defined(__TARGET_OS__IOs)
|
||||
template<>
|
||||
size_t BufferParameter::getParameter<size_t>(int32_t _id) const {
|
||||
size_t BufferParameter::getParameter<size_t>(const ememory::SharedPtr<zeus::WebServer>& _iface, int32_t _id) const {
|
||||
return getParameter<uint64_t>(_id);
|
||||
}
|
||||
#endif
|
||||
template<>
|
||||
int8_t BufferParameter::getParameter<int8_t>(int32_t _id) const {
|
||||
int8_t BufferParameter::getParameter<int8_t>(const ememory::SharedPtr<zeus::WebServer>& _iface, int32_t _id) const {
|
||||
zeus::ParamType type = getParameterType(_id);
|
||||
const uint8_t* pointer = getParameterPointer(_id);
|
||||
uint32_t dataSize = getParameterSize(_id);
|
||||
@ -254,7 +254,7 @@ namespace zeus {
|
||||
}
|
||||
|
||||
template<>
|
||||
int16_t BufferParameter::getParameter<int16_t>(int32_t _id) const {
|
||||
int16_t BufferParameter::getParameter<int16_t>(const ememory::SharedPtr<zeus::WebServer>& _iface, int32_t _id) const {
|
||||
zeus::ParamType type = getParameterType(_id);
|
||||
const uint8_t* pointer = getParameterPointer(_id);
|
||||
uint32_t dataSize = getParameterSize(_id);
|
||||
@ -295,7 +295,7 @@ namespace zeus {
|
||||
}
|
||||
|
||||
template<>
|
||||
int32_t BufferParameter::getParameter<int32_t>(int32_t _id) const {
|
||||
int32_t BufferParameter::getParameter<int32_t>(const ememory::SharedPtr<zeus::WebServer>& _iface, int32_t _id) const {
|
||||
zeus::ParamType type = getParameterType(_id);
|
||||
const uint8_t* pointer = getParameterPointer(_id);
|
||||
uint32_t dataSize = getParameterSize(_id);
|
||||
@ -336,7 +336,7 @@ namespace zeus {
|
||||
}
|
||||
|
||||
template<>
|
||||
int64_t BufferParameter::getParameter<int64_t>(int32_t _id) const {
|
||||
int64_t BufferParameter::getParameter<int64_t>(const ememory::SharedPtr<zeus::WebServer>& _iface, int32_t _id) const {
|
||||
zeus::ParamType type = getParameterType(_id);
|
||||
const uint8_t* pointer = getParameterPointer(_id);
|
||||
uint32_t dataSize = getParameterSize(_id);
|
||||
@ -377,7 +377,7 @@ namespace zeus {
|
||||
}
|
||||
|
||||
template<>
|
||||
float BufferParameter::getParameter<float>(int32_t _id) const {
|
||||
float BufferParameter::getParameter<float>(const ememory::SharedPtr<zeus::WebServer>& _iface, int32_t _id) const {
|
||||
zeus::ParamType type = getParameterType(_id);
|
||||
const uint8_t* pointer = getParameterPointer(_id);
|
||||
uint32_t dataSize = getParameterSize(_id);
|
||||
@ -417,7 +417,7 @@ namespace zeus {
|
||||
return 0.0f;
|
||||
}
|
||||
template<>
|
||||
double BufferParameter::getParameter<double>(int32_t _id) const {
|
||||
double BufferParameter::getParameter<double>(const ememory::SharedPtr<zeus::WebServer>& _iface, int32_t _id) const {
|
||||
zeus::ParamType type = getParameterType(_id);
|
||||
const uint8_t* pointer = getParameterPointer(_id);
|
||||
uint32_t dataSize = getParameterSize(_id);
|
||||
@ -481,7 +481,7 @@ namespace zeus {
|
||||
|
||||
|
||||
template<>
|
||||
std::vector<uint8_t> BufferParameter::getParameter<std::vector<uint8_t>>(int32_t _id) const {
|
||||
std::vector<uint8_t> BufferParameter::getParameter<std::vector<uint8_t>>(const ememory::SharedPtr<zeus::WebServer>& _iface, int32_t _id) const {
|
||||
std::vector<uint8_t> out;
|
||||
zeus::ParamType type = getParameterType(_id);
|
||||
const uint8_t* pointer = getParameterPointer(_id);
|
||||
@ -571,7 +571,7 @@ namespace zeus {
|
||||
return out;
|
||||
}
|
||||
template<>
|
||||
std::vector<uint16_t> BufferParameter::getParameter<std::vector<uint16_t>>(int32_t _id) const {
|
||||
std::vector<uint16_t> BufferParameter::getParameter<std::vector<uint16_t>>(const ememory::SharedPtr<zeus::WebServer>& _iface, int32_t _id) const {
|
||||
std::vector<uint16_t> out;
|
||||
zeus::ParamType type = getParameterType(_id);
|
||||
const uint8_t* pointer = getParameterPointer(_id);
|
||||
@ -662,7 +662,7 @@ namespace zeus {
|
||||
}
|
||||
|
||||
template<>
|
||||
std::vector<uint32_t> BufferParameter::getParameter<std::vector<uint32_t>>(int32_t _id) const {
|
||||
std::vector<uint32_t> BufferParameter::getParameter<std::vector<uint32_t>>(const ememory::SharedPtr<zeus::WebServer>& _iface, int32_t _id) const {
|
||||
std::vector<uint32_t> out;
|
||||
zeus::ParamType type = getParameterType(_id);
|
||||
const uint8_t* pointer = getParameterPointer(_id);
|
||||
@ -753,7 +753,7 @@ namespace zeus {
|
||||
}
|
||||
|
||||
template<>
|
||||
std::vector<uint64_t> BufferParameter::getParameter<std::vector<uint64_t>>(int32_t _id) const {
|
||||
std::vector<uint64_t> BufferParameter::getParameter<std::vector<uint64_t>>(const ememory::SharedPtr<zeus::WebServer>& _iface, int32_t _id) const {
|
||||
std::vector<uint64_t> out;
|
||||
zeus::ParamType type = getParameterType(_id);
|
||||
const uint8_t* pointer = getParameterPointer(_id);
|
||||
@ -844,7 +844,7 @@ namespace zeus {
|
||||
}
|
||||
|
||||
template<>
|
||||
std::vector<int8_t> BufferParameter::getParameter<std::vector<int8_t>>(int32_t _id) const {
|
||||
std::vector<int8_t> BufferParameter::getParameter<std::vector<int8_t>>(const ememory::SharedPtr<zeus::WebServer>& _iface, int32_t _id) const {
|
||||
std::vector<int8_t> out;
|
||||
zeus::ParamType type = getParameterType(_id);
|
||||
const uint8_t* pointer = getParameterPointer(_id);
|
||||
@ -935,7 +935,7 @@ namespace zeus {
|
||||
}
|
||||
|
||||
template<>
|
||||
std::vector<int16_t> BufferParameter::getParameter<std::vector<int16_t>>(int32_t _id) const {
|
||||
std::vector<int16_t> BufferParameter::getParameter<std::vector<int16_t>>(const ememory::SharedPtr<zeus::WebServer>& _iface, int32_t _id) const {
|
||||
std::vector<int16_t> out;
|
||||
zeus::ParamType type = getParameterType(_id);
|
||||
const uint8_t* pointer = getParameterPointer(_id);
|
||||
@ -1026,7 +1026,7 @@ namespace zeus {
|
||||
}
|
||||
|
||||
template<>
|
||||
std::vector<int32_t> BufferParameter::getParameter<std::vector<int32_t>>(int32_t _id) const {
|
||||
std::vector<int32_t> BufferParameter::getParameter<std::vector<int32_t>>(const ememory::SharedPtr<zeus::WebServer>& _iface, int32_t _id) const {
|
||||
std::vector<int32_t> out;
|
||||
zeus::ParamType type = getParameterType(_id);
|
||||
const uint8_t* pointer = getParameterPointer(_id);
|
||||
@ -1117,7 +1117,7 @@ namespace zeus {
|
||||
}
|
||||
|
||||
template<>
|
||||
std::vector<int64_t> BufferParameter::getParameter<std::vector<int64_t>>(int32_t _id) const {
|
||||
std::vector<int64_t> BufferParameter::getParameter<std::vector<int64_t>>(const ememory::SharedPtr<zeus::WebServer>& _iface, int32_t _id) const {
|
||||
std::vector<int64_t> out;
|
||||
zeus::ParamType type = getParameterType(_id);
|
||||
const uint8_t* pointer = getParameterPointer(_id);
|
||||
@ -1208,7 +1208,7 @@ namespace zeus {
|
||||
}
|
||||
|
||||
template<>
|
||||
std::vector<float> BufferParameter::getParameter<std::vector<float>>(int32_t _id) const {
|
||||
std::vector<float> BufferParameter::getParameter<std::vector<float>>(const ememory::SharedPtr<zeus::WebServer>& _iface, int32_t _id) const {
|
||||
std::vector<float> out;
|
||||
zeus::ParamType type = getParameterType(_id);
|
||||
const uint8_t* pointer = getParameterPointer(_id);
|
||||
@ -1299,7 +1299,7 @@ namespace zeus {
|
||||
}
|
||||
|
||||
template<>
|
||||
std::vector<double> BufferParameter::getParameter<std::vector<double>>(int32_t _id) const {
|
||||
std::vector<double> BufferParameter::getParameter<std::vector<double>>(const ememory::SharedPtr<zeus::WebServer>& _iface, int32_t _id) const {
|
||||
std::vector<double> out;
|
||||
zeus::ParamType type = getParameterType(_id);
|
||||
const uint8_t* pointer = getParameterPointer(_id);
|
||||
@ -1390,7 +1390,7 @@ namespace zeus {
|
||||
}
|
||||
|
||||
template<>
|
||||
std::vector<bool> BufferParameter::getParameter<std::vector<bool>>(int32_t _id) const {
|
||||
std::vector<bool> BufferParameter::getParameter<std::vector<bool>>(const ememory::SharedPtr<zeus::WebServer>& _iface, int32_t _id) const {
|
||||
std::vector<bool> out;
|
||||
zeus::ParamType type = getParameterType(_id);
|
||||
const uint8_t* pointer = getParameterPointer(_id);
|
||||
@ -1412,7 +1412,7 @@ namespace zeus {
|
||||
}
|
||||
|
||||
template<>
|
||||
std::vector<std::string> BufferParameter::getParameter<std::vector<std::string>>(int32_t _id) const {
|
||||
std::vector<std::string> BufferParameter::getParameter<std::vector<std::string>>(const ememory::SharedPtr<zeus::WebServer>& _iface, int32_t _id) const {
|
||||
std::vector<std::string> out;
|
||||
zeus::ParamType type = getParameterType(_id);
|
||||
const uint8_t* pointer = getParameterPointer(_id);
|
||||
@ -1473,7 +1473,7 @@ namespace zeus {
|
||||
}
|
||||
*/
|
||||
template<>
|
||||
zeus::Raw BufferParameter::getParameter<zeus::Raw>(int32_t _id) const {
|
||||
zeus::Raw BufferParameter::getParameter<zeus::Raw>(const ememory::SharedPtr<zeus::WebServer>& _iface, int32_t _id) const {
|
||||
zeus::ParamType type = getParameterType(_id);
|
||||
const uint8_t* pointer = getParameterPointer(_id);
|
||||
uint32_t dataSize = getParameterSize(_id);
|
||||
|
@ -148,7 +148,7 @@ zeus::ObjectRemote zeus::Client::getService(const std::string& _name) {
|
||||
ZEUS_WARNING("Can not unlink with the service id: '" << _name << "' ==> link error");
|
||||
return zeus::ObjectRemote();
|
||||
}
|
||||
return zeus::ObjectRemote(ret.get(m_interfaceWeb));
|
||||
return zeus::ObjectRemote(ret.get());
|
||||
}
|
||||
|
||||
void zeus::Client::onPropertyChangeIp() {
|
||||
|
@ -116,7 +116,7 @@ namespace zeus {
|
||||
const std::string& _functionName,
|
||||
_ARGS&&... _args) {
|
||||
if (m_interfaceWeb == nullptr) {
|
||||
ememory::SharedPtr<zeus::BufferAnswer> ret = zeus::BufferAnswer::create();
|
||||
ememory::SharedPtr<zeus::BufferAnswer> ret = zeus::BufferAnswer::create(nullptr); // TODO : This is really a bad case ...
|
||||
ret->addError("NULLPTR", "call " + _functionName + " with no interface open");
|
||||
return zeus::FutureBase(0, ret);
|
||||
}
|
||||
|
@ -5,6 +5,7 @@
|
||||
*/
|
||||
|
||||
#include <zeus/FileImpl.hpp>
|
||||
#include <zeus/mineType.hpp>
|
||||
#include "debug.hpp"
|
||||
|
||||
namespace zeus {
|
||||
@ -21,27 +22,43 @@ namespace zeus {
|
||||
zeus::FileImpl::FileImpl(std::string _filename) :
|
||||
m_filename(_filename),
|
||||
m_node(_filename) {
|
||||
m_size = m_node.fileSize();
|
||||
m_node.fileOpenRead();
|
||||
std::string extention = std::string(_filename.begin()+_filename.size() -3, _filename.end());
|
||||
m_mineType = zeus::getMineType(extention);
|
||||
}
|
||||
|
||||
zeus::FileImpl::~FileImpl() {
|
||||
m_node.fileClose();
|
||||
}
|
||||
|
||||
uint64_t zeus::FileImpl::size() {
|
||||
return 4092;
|
||||
uint64_t zeus::FileImpl::getSize() {
|
||||
return m_size;
|
||||
}
|
||||
|
||||
std::string zeus::FileImpl::name() {
|
||||
std::string zeus::FileImpl::getName() {
|
||||
return m_filename;
|
||||
}
|
||||
|
||||
std::string zeus::FileImpl::getMineType() {
|
||||
return "audio/x-matroska";
|
||||
return m_mineType;
|
||||
}
|
||||
|
||||
zeus::Raw zeus::FileImpl::getPart(uint64_t _start, uint64_t _stop) {
|
||||
return zeus::Raw(4092);
|
||||
if ((_stop - _start) > 25*1024*1024) {
|
||||
ZEUS_ERROR("REQUEST more that 25 Mo in a part file ...");
|
||||
// TODO : throw an error ...
|
||||
return zeus::Raw();
|
||||
}
|
||||
zeus::Raw tmp(_stop - _start);
|
||||
if (m_node.fileSeek(_start, etk::seekNode_start) == false) {
|
||||
ZEUS_ERROR("REQUEST seek error ...");
|
||||
// TODO : throw an error ...
|
||||
return zeus::Raw();
|
||||
}
|
||||
int64_t sizeCopy = m_node.fileRead(tmp.writeData(), 1, _stop-_start);
|
||||
// TODO : Check if copy is correct ...
|
||||
return std::move(tmp);
|
||||
}
|
||||
|
||||
|
||||
|
@ -13,11 +13,13 @@ namespace zeus {
|
||||
private:
|
||||
std::string m_filename;
|
||||
etk::FSNode m_node;
|
||||
size_t m_size;
|
||||
std::string m_mineType;
|
||||
public:
|
||||
FileImpl(std::string _filename);
|
||||
~FileImpl();
|
||||
uint64_t size() override;
|
||||
std::string name() override;
|
||||
uint64_t getSize() override;
|
||||
std::string getName() override;
|
||||
std::string getMineType() override;
|
||||
zeus::Raw getPart(uint64_t _start, uint64_t _stop) override;
|
||||
|
||||
|
@ -335,13 +335,8 @@ namespace zeus {
|
||||
}
|
||||
return static_cast<zeus::BufferAnswer*>(m_data->m_returnData.get())->getAnswer<zeus::Raw>();
|
||||
}
|
||||
}
|
||||
|
||||
// NamespaceSpace for Object and services
|
||||
|
||||
namespace zeus {
|
||||
template<>
|
||||
ememory::SharedPtr<zeus::ObjectRemoteBase> zeus::Future<ememory::SharedPtr<zeus::ObjectRemoteBase>>::get(const ememory::SharedPtr<zeus::WebServer>& _iface) {
|
||||
ememory::SharedPtr<zeus::ObjectRemoteBase> zeus::Future<ememory::SharedPtr<zeus::ObjectRemoteBase>>::get() {
|
||||
ememory::SharedPtr<zeus::ObjectRemoteBase> out;
|
||||
if ( m_data == nullptr
|
||||
|| m_data->m_returnData == nullptr) {
|
||||
@ -351,7 +346,7 @@ namespace zeus {
|
||||
ZEUS_WARNING("No Return value ...");
|
||||
return out;
|
||||
}
|
||||
out = static_cast<zeus::BufferAnswer*>(m_data->m_returnData.get())->getAnswer<ememory::SharedPtr<zeus::ObjectRemoteBase>>(_iface);
|
||||
out = static_cast<zeus::BufferAnswer*>(m_data->m_returnData.get())->getAnswer<ememory::SharedPtr<zeus::ObjectRemoteBase>>();
|
||||
return out;
|
||||
}
|
||||
}
|
||||
|
@ -38,12 +38,6 @@ namespace zeus {
|
||||
* @return requested value
|
||||
*/
|
||||
ZEUS_RETURN get();
|
||||
/**
|
||||
* @brief Get the value Requested with the type expecially for object and services
|
||||
* @return requested value
|
||||
*/
|
||||
ZEUS_RETURN get(const ememory::SharedPtr<zeus::WebServer>& _iface);
|
||||
|
||||
const Future<ZEUS_RETURN>& wait() const {
|
||||
zeus::FutureBase::wait();
|
||||
return *this;
|
||||
|
@ -99,7 +99,7 @@ namespace zeus {
|
||||
zeus::FutureBase call(const std::string& _functionName, _ARGS&&... _args) {
|
||||
if ( m_interface == nullptr
|
||||
|| m_interface->m_interfaceWeb == nullptr) {
|
||||
ememory::SharedPtr<zeus::BufferAnswer> ret = zeus::BufferAnswer::create();
|
||||
ememory::SharedPtr<zeus::BufferAnswer> ret = zeus::BufferAnswer::create(nullptr); // TODO : This is a real bad case ...
|
||||
if (ret != nullptr) {
|
||||
ret->addError("NULLPTR", "call " + _functionName + " with no interface open");
|
||||
}
|
||||
|
57
zeus/Raw.cpp
57
zeus/Raw.cpp
@ -0,0 +1,57 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2016, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <zeus/Raw.hpp>
|
||||
#include "debug.hpp"
|
||||
|
||||
|
||||
zeus::Raw::Raw() :
|
||||
m_size(0),
|
||||
m_dataExternal(nullptr),
|
||||
m_dataInternal() {
|
||||
|
||||
}
|
||||
|
||||
zeus::Raw::Raw(uint32_t _size) :
|
||||
m_size(_size),
|
||||
m_dataExternal(nullptr),
|
||||
m_dataInternal() {
|
||||
m_dataInternal.resize(_size);
|
||||
}
|
||||
|
||||
zeus::Raw::Raw(uint32_t _size, const uint8_t* _data) :
|
||||
m_size(_size),
|
||||
m_dataExternal(_data),
|
||||
m_dataInternal() {
|
||||
|
||||
}
|
||||
|
||||
zeus::Raw::~Raw() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
uint32_t zeus::Raw::size() const {
|
||||
return m_size;
|
||||
}
|
||||
|
||||
const uint8_t* zeus::Raw::data() const {
|
||||
if (m_dataExternal != nullptr) {
|
||||
return m_dataExternal;
|
||||
}
|
||||
return &m_dataInternal[0];
|
||||
}
|
||||
|
||||
uint8_t* zeus::Raw::writeData() {
|
||||
if (m_dataExternal != nullptr) {
|
||||
ZEUS_ERROR("Try to write on Data that is not allowed ...");
|
||||
return nullptr;
|
||||
}
|
||||
return &m_dataInternal[0];
|
||||
}
|
||||
|
||||
|
||||
|
42
zeus/Raw.hpp
42
zeus/Raw.hpp
@ -15,52 +15,26 @@ namespace zeus {
|
||||
private:
|
||||
uint32_t m_size;
|
||||
const uint8_t* m_dataExternal;
|
||||
uint8_t* m_dataInternal;
|
||||
std::vector<uint8_t> m_dataInternal;
|
||||
public:
|
||||
/**
|
||||
* @brief generic constructor
|
||||
*/
|
||||
Raw() :
|
||||
m_size(0),
|
||||
m_dataExternal(nullptr),
|
||||
m_dataInternal(nullptr) {
|
||||
|
||||
}
|
||||
Raw();
|
||||
/**
|
||||
* @brief generic constructor
|
||||
*/
|
||||
Raw(uint32_t _size) :
|
||||
m_size(_size),
|
||||
m_dataExternal(nullptr),
|
||||
m_dataInternal(new uint8_t[_size]) {
|
||||
|
||||
}
|
||||
Raw(uint32_t _size);
|
||||
|
||||
Raw(uint32_t _size, const uint8_t* _data) :
|
||||
m_size(_size),
|
||||
m_dataExternal(_data),
|
||||
m_dataInternal(nullptr) {
|
||||
|
||||
}
|
||||
Raw(uint32_t _size, const uint8_t* _data);
|
||||
|
||||
~Raw() {
|
||||
if (m_dataInternal != nullptr) {
|
||||
delete[] m_dataInternal;
|
||||
m_dataInternal = nullptr;
|
||||
}
|
||||
}
|
||||
~Raw();
|
||||
|
||||
|
||||
uint32_t size() const {
|
||||
return m_size;
|
||||
}
|
||||
uint32_t size() const;
|
||||
|
||||
const uint8_t* data() const {
|
||||
if (m_dataExternal != nullptr) {
|
||||
return m_dataExternal;
|
||||
}
|
||||
return m_dataInternal;
|
||||
}
|
||||
const uint8_t* data() const;
|
||||
uint8_t* writeData();
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -11,8 +11,8 @@
|
||||
#include <zeus/BufferCtrl.hpp>
|
||||
|
||||
|
||||
ememory::SharedPtr<zeus::BufferCall> zeus::createBaseCall(uint64_t _transactionId, const uint32_t& _source, const uint32_t& _destination, const std::string& _functionName) {
|
||||
ememory::SharedPtr<zeus::BufferCall> obj = zeus::BufferCall::create();
|
||||
ememory::SharedPtr<zeus::BufferCall> zeus::createBaseCall(const ememory::SharedPtr<zeus::WebServer>& _iface, uint64_t _transactionId, const uint32_t& _source, const uint32_t& _destination, const std::string& _functionName) {
|
||||
ememory::SharedPtr<zeus::BufferCall> obj = zeus::BufferCall::create(_iface);
|
||||
if (obj == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
@ -146,6 +146,7 @@ class SendAsyncBinary {
|
||||
m_partId(1) {
|
||||
|
||||
}
|
||||
// TODO : Use shared ptr instaed of pointer ....
|
||||
bool operator() (zeus::WebServer* _interface){
|
||||
auto it = m_async.begin();
|
||||
while (it != m_async.end()) {
|
||||
@ -159,7 +160,7 @@ class SendAsyncBinary {
|
||||
m_partId++;
|
||||
}
|
||||
if (m_async.size() == 0) {
|
||||
ememory::SharedPtr<zeus::BufferData> obj = zeus::BufferData::create();
|
||||
ememory::SharedPtr<zeus::BufferData> obj = zeus::BufferData::create(_interface->sharedFromThis());
|
||||
if (obj == nullptr) {
|
||||
return true;
|
||||
}
|
||||
@ -224,7 +225,7 @@ void zeus::WebServer::onReceiveData(std::vector<uint8_t>& _frame, bool _isBinary
|
||||
disconnect(true);
|
||||
return;
|
||||
}
|
||||
ememory::SharedPtr<zeus::Buffer> dataRaw = zeus::Buffer::create(_frame);
|
||||
ememory::SharedPtr<zeus::Buffer> dataRaw = zeus::Buffer::create(sharedFromThis(), _frame);
|
||||
if (dataRaw == nullptr) {
|
||||
ZEUS_ERROR("Buffer Allocation ERROR ... ");
|
||||
disconnect(true);
|
||||
@ -250,7 +251,8 @@ void zeus::WebServer::newBuffer(ememory::SharedPtr<zeus::Buffer> _buffer) {
|
||||
// Try to find in the current call that has been done to add data in an answer :
|
||||
zeus::FutureBase future;
|
||||
uint64_t tid = _buffer->getTransactionId();
|
||||
{
|
||||
// TODO : Check the UDI reaaly utility ...
|
||||
if (_buffer->getType() == zeus::Buffer::typeMessage::answer) {
|
||||
std::unique_lock<std::mutex> lock(m_pendingCallMutex);
|
||||
auto it = m_pendingCall.begin();
|
||||
while (it != m_pendingCall.end()) {
|
||||
@ -278,6 +280,7 @@ void zeus::WebServer::newBuffer(ememory::SharedPtr<zeus::Buffer> _buffer) {
|
||||
m_processingPool.async(
|
||||
[=](){
|
||||
ememory::SharedPtr<zeus::WebObj> tmpObj = it;
|
||||
ZEUS_INFO("PROCESS : " << _buffer);
|
||||
tmpObj->receive(_buffer);
|
||||
},
|
||||
dest
|
||||
@ -298,6 +301,7 @@ void zeus::WebServer::newBuffer(ememory::SharedPtr<zeus::Buffer> _buffer) {
|
||||
m_processingPool.async(
|
||||
[=](){
|
||||
zeus::FutureBase fut = future;
|
||||
ZEUS_INFO("PROCESS FUTURE : " << _buffer);
|
||||
// add data ...
|
||||
bool ret = fut.appendData(_buffer);
|
||||
if (ret == true) {
|
||||
@ -364,7 +368,7 @@ zeus::FutureBase zeus::WebServer::callBinary(uint64_t _transactionId,
|
||||
const uint32_t& _destination) {
|
||||
if (isActive() == false) {
|
||||
ZEUS_ERROR("Send [STOP] ==> not connected (no TCP)");
|
||||
ememory::SharedPtr<zeus::BufferAnswer> obj = zeus::BufferAnswer::create();
|
||||
ememory::SharedPtr<zeus::BufferAnswer> obj = zeus::BufferAnswer::create(sharedFromThis());
|
||||
obj->addError("NOT-CONNECTED", "Client interface not connected (no TCP)");
|
||||
return zeus::FutureBase(_transactionId, obj);
|
||||
}
|
||||
@ -376,56 +380,10 @@ zeus::FutureBase zeus::WebServer::callBinary(uint64_t _transactionId,
|
||||
writeBinary(_obj);
|
||||
return tmpFuture;
|
||||
}
|
||||
/*
|
||||
zeus::FutureBase zeus::WebServer::callForward(uint16_t _srcObjectId,
|
||||
ememory::SharedPtr<zeus::Buffer> _buffer,
|
||||
uint64_t _singleReferenceId) {
|
||||
//zeus::FutureBase ret = callBinary(id, _Buffer, async, _callback);
|
||||
//ret.setSynchronous();
|
||||
|
||||
if (isActive() == false) {
|
||||
auto obj = zeus::BufferAnswer::create();
|
||||
obj->addError("NOT-CONNECTED", "Client interface not connected (no TCP)");
|
||||
return zeus::FutureBase(0, obj);
|
||||
}
|
||||
uint64_t id = getId();
|
||||
_buffer->setTransactionId(id);
|
||||
_buffer->setClientId(_srcObjectId);
|
||||
zeus::FutureBase tmpFuture(id);
|
||||
tmpFuture.setSynchronous();
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(m_pendingCallMutex);
|
||||
m_pendingCall.push_back(std::make_pair(_singleReferenceId, tmpFuture));
|
||||
}
|
||||
writeBinary(_buffer);
|
||||
return tmpFuture;
|
||||
}
|
||||
|
||||
void zeus::WebServer::callForwardMultiple(uint16_t _srcObjectId,
|
||||
ememory::SharedPtr<zeus::Buffer> _buffer,
|
||||
uint64_t _singleReferenceId){
|
||||
if (_buffer == nullptr) {
|
||||
return;
|
||||
}
|
||||
// subMessage ... ==> try to forward message:
|
||||
std::unique_lock<std::mutex> lock(m_pendingCallMutex);
|
||||
for (auto &itCall : m_pendingCall) {
|
||||
ZEUS_INFO(" compare : " << itCall.first << " =?= " << _singleReferenceId);
|
||||
if (itCall.first == _singleReferenceId) {
|
||||
// Find element ==> transmit it ...
|
||||
_buffer->setTransactionId(itCall.second.getTransactionId());
|
||||
_buffer->setClientId(_srcObjectId);
|
||||
writeBinary(_buffer);
|
||||
return;
|
||||
}
|
||||
}
|
||||
ZEUS_ERROR("Can not transfer part of a message ...");
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
void zeus::WebServer::sendCtrl(uint32_t _source, uint32_t _destination, const std::string& _ctrlValue) {
|
||||
auto ctrl = zeus::BufferCtrl::create();
|
||||
auto ctrl = zeus::BufferCtrl::create(sharedFromThis());
|
||||
if (ctrl == nullptr) {
|
||||
return;
|
||||
}
|
||||
@ -438,7 +396,7 @@ void zeus::WebServer::sendCtrl(uint32_t _source, uint32_t _destination, const st
|
||||
*/
|
||||
|
||||
void zeus::WebServer::answerError(uint32_t _clientTransactionId, uint32_t _source, uint32_t _destination, const std::string& _errorValue, const std::string& _errorHelp) {
|
||||
auto answer = zeus::BufferAnswer::create();
|
||||
auto answer = zeus::BufferAnswer::create(sharedFromThis());
|
||||
if (answer == nullptr) {
|
||||
return;
|
||||
}
|
||||
@ -451,7 +409,7 @@ void zeus::WebServer::answerError(uint32_t _clientTransactionId, uint32_t _sourc
|
||||
|
||||
|
||||
void zeus::WebServer::answerVoid(uint32_t _clientTransactionId, uint32_t _source, uint32_t _destination) {
|
||||
auto answer = zeus::BufferAnswer::create();
|
||||
auto answer = zeus::BufferAnswer::create(sharedFromThis());
|
||||
if (answer == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
@ -30,7 +30,11 @@ namespace zeus {
|
||||
* @param[in]
|
||||
* @return
|
||||
*/
|
||||
ememory::SharedPtr<zeus::BufferCall> createBaseCall(uint64_t _transactionId, const uint32_t& _source, const uint32_t& _destination, const std::string& _functionName);
|
||||
ememory::SharedPtr<zeus::BufferCall> createBaseCall(const ememory::SharedPtr<zeus::WebServer>& _iface,
|
||||
uint64_t _transactionId,
|
||||
const uint32_t& _source,
|
||||
const uint32_t& _destination,
|
||||
const std::string& _functionName);
|
||||
/**
|
||||
* @brief
|
||||
* @param[in]
|
||||
@ -76,7 +80,7 @@ namespace zeus {
|
||||
*/
|
||||
template<class... _ARGS>
|
||||
ememory::SharedPtr<zeus::BufferCall> createCall(const ememory::SharedPtr<zeus::WebServer>& _iface, uint64_t _transactionId, const uint32_t& _source, const uint32_t& _destination, const std::string& _functionName, _ARGS&&... _args) {
|
||||
ememory::SharedPtr<zeus::BufferCall> callElem = createBaseCall(_transactionId, _source, _destination, _functionName);
|
||||
ememory::SharedPtr<zeus::BufferCall> callElem = createBaseCall(_iface, _transactionId, _source, _destination, _functionName);
|
||||
if (callElem == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
@ -158,7 +162,7 @@ namespace zeus {
|
||||
* @param[in]
|
||||
* @return
|
||||
*/
|
||||
WebServer();
|
||||
WebServer(); // TODO : Set it in a factory to force the use of sharedPtr
|
||||
/**
|
||||
* @brief
|
||||
* @param[in]
|
||||
@ -325,7 +329,7 @@ namespace zeus {
|
||||
*/
|
||||
template<class ZEUS_ARG>
|
||||
void answerValue(uint32_t _clientTransactionId, uint32_t _source, uint32_t _destination, ZEUS_ARG _value) {
|
||||
ememory::SharedPtr<zeus::BufferAnswer> answer = zeus::BufferAnswer::create();
|
||||
ememory::SharedPtr<zeus::BufferAnswer> answer = zeus::BufferAnswer::create(sharedFromThis());
|
||||
answer->setTransactionId(_clientTransactionId);
|
||||
answer->setSource(_source);
|
||||
answer->setDestination(_destination);
|
||||
|
@ -5,11 +5,11 @@
|
||||
|
||||
#brief:Get size of the file
|
||||
#return:current size of the file
|
||||
uint64 size()
|
||||
uint64 getSize()
|
||||
|
||||
#brief:Get the name of the file
|
||||
#return:Full name of the file (sha512)
|
||||
string name()
|
||||
string getName()
|
||||
|
||||
#brief:Get the file "mine-type"
|
||||
#return:string of the mine-type
|
||||
|
Loading…
Reference in New Issue
Block a user