[DEV] send file is OF, not get
This commit is contained in:
parent
9f4872ba7b
commit
42e6f1da59
@ -15,6 +15,7 @@
|
||||
|
||||
#include <etk/stdTools.hpp>
|
||||
#include <zeus/service/ProxyUser.hpp>
|
||||
#include <zeus/service/ProxyPicture.hpp>
|
||||
#include <echrono/Steady.hpp>
|
||||
|
||||
|
||||
@ -93,19 +94,19 @@ int main(int _argc, const char *_argv[]) {
|
||||
APPL_INFO(" ----------------------------------");
|
||||
APPL_INFO(" -- Get service system-user");
|
||||
APPL_INFO(" ----------------------------------");
|
||||
|
||||
#if 1
|
||||
zeus::service::ProxyUser remoteServiceUser;
|
||||
remoteServiceUser = client1.getService("user");
|
||||
if (remoteServiceUser.exist() == true) {
|
||||
zeus::Future<std::vector<std::string>> retCall = remoteServiceUser.clientGroupsGet("clientTest1#atria-soft.com");
|
||||
retCall.wait();
|
||||
APPL_INFO("system-user.getGroups() = " << retCall.get());
|
||||
// system DOC
|
||||
zeus::Future<std::string> retDesc = remoteServiceUser.sys.getDescription();
|
||||
zeus::Future<std::string> retVersion = remoteServiceUser.sys.getVersion();
|
||||
zeus::Future<std::string> retType = remoteServiceUser.sys.getType();
|
||||
zeus::Future<std::vector<std::string>> retExtention = remoteServiceUser.srv.getExtention();
|
||||
zeus::Future<std::vector<std::string>> retMaintainer = remoteServiceUser.sys.getAuthors();
|
||||
//service DOC
|
||||
zeus::Future<std::vector<std::string>> retExtention = remoteServiceUser.srv.getExtention();
|
||||
retDesc.wait();
|
||||
retVersion.wait();
|
||||
retType.wait();
|
||||
@ -140,81 +141,35 @@ int main(int _argc, const char *_argv[]) {
|
||||
APPL_INFO(" IO*=" << (stop-start));
|
||||
}
|
||||
}
|
||||
#else
|
||||
zeus::ServiceRemote remoteServiceUser = client1.getService("user");
|
||||
if (remoteServiceUser.exist() == true) {
|
||||
zeus::Future<std::vector<std::string>> retCall = remoteServiceUser.call("clientGroupsGet", "clientTest1#atria-soft.com");
|
||||
retCall.wait();
|
||||
APPL_INFO("system-user.getGroups() = " << retCall.get());
|
||||
zeus::Future<std::string> retDesc = remoteServiceUser.call("sys.getDescription");
|
||||
zeus::Future<std::string> retVersion = remoteServiceUser.call("sys.getVersion");
|
||||
zeus::Future<std::string> retType = remoteServiceUser.call("sys.getType");
|
||||
zeus::Future<std::vector<std::string>> retExtention = remoteServiceUser.call("srv.getExtention");
|
||||
zeus::Future<std::vector<std::string>> retMaintainer = remoteServiceUser.call("sys.getAuthors");
|
||||
retDesc.wait();
|
||||
retVersion.wait();
|
||||
retType.wait();
|
||||
retExtention.wait();
|
||||
retMaintainer.wait();
|
||||
APPL_INFO("Service: system-user");
|
||||
APPL_INFO(" version : " << retVersion.get());
|
||||
APPL_INFO(" type : " << retType.get());
|
||||
APPL_INFO(" Extention : " << retExtention.get().size());
|
||||
for (auto &it : retExtention.get()) {
|
||||
APPL_INFO(" - " << it);
|
||||
}
|
||||
APPL_INFO(" maintainer: " << retMaintainer.get().size());
|
||||
for (auto &it : retMaintainer.get()) {
|
||||
APPL_INFO(" - " << it);
|
||||
}
|
||||
APPL_INFO(" description:");
|
||||
APPL_INFO(" " << retDesc.get());
|
||||
APPL_INFO(" Function List:");
|
||||
zeus::Future<std::vector<std::string>> retFuctions = remoteServiceUser.call("sys.getFunctions").wait();
|
||||
for (auto it : retFuctions.get()) {
|
||||
std::chrono::steady_clock::time_point start = std::chrono::steady_clock::now();
|
||||
zeus::Future<std::string> retFunctionPrototype = remoteServiceUser.call("sys.getFunctionPrototype", it);
|
||||
zeus::Future<std::string> retFunctionHelp = remoteServiceUser.call("sys.getFunctionDescription", it);
|
||||
retFunctionPrototype.wait();
|
||||
retFunctionHelp.wait();
|
||||
std::chrono::steady_clock::time_point stop = std::chrono::steady_clock::now();
|
||||
APPL_INFO(" - " << retFunctionPrototype.get());
|
||||
APPL_INFO(" " << retFunctionHelp.get());
|
||||
APPL_INFO(" IO1=" << int64_t(retFunctionPrototype.getTransmitionTime().count()/1000)/1000.0 << " ms");
|
||||
APPL_INFO(" IO2=" << int64_t(retFunctionHelp.getTransmitionTime().count()/1000)/1000.0 << " ms");
|
||||
APPL_INFO(" IO*=" << int64_t((stop-start).count()/1000)/1000.0 << " ms");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
APPL_INFO(" ----------------------------------");
|
||||
APPL_INFO(" -- Get service picture");
|
||||
APPL_INFO(" ----------------------------------");
|
||||
if (false) {
|
||||
zeus::ServiceRemote remoteServicePicture = client1.getService("picture");
|
||||
if (true) {
|
||||
zeus::service::ProxyPicture remoteServicePicture = client1.getService("picture");
|
||||
if (remoteServicePicture.exist() == true) {
|
||||
zeus::Future<std::vector<std::string>> retCall = remoteServicePicture.call("getAlbums").wait();
|
||||
zeus::Future<std::vector<std::string>> retCall = remoteServicePicture.getAlbums().wait();
|
||||
APPL_INFO(" album list: ");
|
||||
for (auto &it : retCall.get()) {
|
||||
zeus::Future<uint32_t> retCount = remoteServicePicture.call("getAlbumCount", it).wait();
|
||||
zeus::Future<uint32_t> retCount = remoteServicePicture.getAlbumCount(it).wait();
|
||||
if (retCount.get() != 0) {
|
||||
APPL_INFO(" - " << it << " / " << retCount.get() << " images");
|
||||
zeus::Future<std::vector<std::string>> retListImage = remoteServicePicture.call("getAlbumListPicture", it).wait();
|
||||
zeus::Future<std::vector<std::string>> retListImage = remoteServicePicture.getAlbumListPicture(it).wait();
|
||||
for (auto &it3 : retListImage.get()) {
|
||||
APPL_INFO(" - " << it3);
|
||||
}
|
||||
} else {
|
||||
APPL_INFO(" - " << it);
|
||||
}
|
||||
zeus::Future<std::vector<std::string>> retCall2 = remoteServicePicture.call("getSubAlbums", it).wait();
|
||||
zeus::Future<std::vector<std::string>> retCall2 = remoteServicePicture.getSubAlbums(it).wait();
|
||||
for (auto &it2 : retCall2.get()) {
|
||||
zeus::Future<uint32_t> retCount2 = remoteServicePicture.call("getAlbumCount", it2).wait();
|
||||
zeus::Future<uint32_t> retCount2 = remoteServicePicture.getAlbumCount(it2).wait();
|
||||
if (retCount2.get() != 0) {
|
||||
APPL_INFO(" - " << it2 << " / " << retCount2.get() << " images");
|
||||
zeus::Future<std::vector<std::string>> retListImage = remoteServicePicture.call("getAlbumListPicture", it2).wait();
|
||||
zeus::Future<std::vector<std::string>> retListImage = remoteServicePicture.getAlbumListPicture(it2).wait();
|
||||
for (auto &it3 : retListImage.get()) {
|
||||
APPL_INFO(" - " << it3);
|
||||
zeus::Future<zeus::File> retListImage = remoteServicePicture.call("getAlbumPicture", it3).wait();
|
||||
zeus::Future<zeus::File> retListImage = remoteServicePicture.getAlbumListPicture(it3).wait();
|
||||
zeus::File tmpFile = retListImage.get();
|
||||
APPL_INFO(" mine-type: " << tmpFile.getMineType());
|
||||
APPL_INFO(" size: " << tmpFile.getData().size());
|
||||
@ -232,12 +187,13 @@ int main(int _argc, const char *_argv[]) {
|
||||
}
|
||||
}
|
||||
#if 1
|
||||
std::chrono::steady_clock::time_point start = std::chrono::steady_clock::now();
|
||||
zeus::File tmp("./testzz.png");
|
||||
echrono::Steady start = echrono::Steady::now();
|
||||
//zeus::File tmp("./testzz.png");
|
||||
zeus::File tmp("./tmpResult.bmp");
|
||||
int32_t size = tmp.getData().size();
|
||||
zeus::FutureBase retSendImage = remoteServicePicture.call("addFile", tmp).wait();
|
||||
std::chrono::steady_clock::time_point stop = std::chrono::steady_clock::now();
|
||||
APPL_WARNING(" IO*=" << int64_t((stop-start).count()/1000)/1000.0 << " ms");
|
||||
zeus::FutureBase retSendImage = remoteServicePicture.addFile(tmp).wait();
|
||||
echrono::Steady stop = echrono::Steady::now();
|
||||
APPL_WARNING(" IO*=" << (stop-start));
|
||||
double megaParSec = double(size)/(double((stop-start).count())/1000000000.0);
|
||||
APPL_WARNING(" speed=" << int64_t(megaParSec/1024.0)/1024.0 << " Mo/s");
|
||||
#endif
|
||||
|
@ -28,7 +28,8 @@ def configure(target, my_module):
|
||||
my_module.add_path(".")
|
||||
my_module.add_depend([
|
||||
'zeus',
|
||||
'zeus-service-user'
|
||||
'zeus-service-user',
|
||||
'zeus-service-picture'
|
||||
])
|
||||
my_module.add_src_file([
|
||||
'appl/debug.cpp',
|
||||
|
@ -9,7 +9,7 @@ vector:string getSubAlbums(string)
|
||||
uint32 getAlbumCount(string)
|
||||
vector:string getAlbumListPicture(string)
|
||||
//file getAlbumPicture(string)
|
||||
//string addFile(file)
|
||||
string addFile(file)
|
||||
bool removeFile(string)
|
||||
/*
|
||||
// ----------------- Get media with their ID -----------------------
|
||||
|
@ -11,7 +11,7 @@
|
||||
namespace zeus {
|
||||
class WebServer;
|
||||
// define basic async call element ...
|
||||
using ActionAsyncClient = std::function<bool(WebServer* _interface, const uint32_t& _serviceId, uint64_t _transactionId, uint64_t _part)>;
|
||||
using ActionAsyncClient = std::function<bool(WebServer* _interface, const uint32_t& _clientId, const uint32_t& _serviceId, uint64_t _transactionId, uint64_t _part)>;
|
||||
}
|
||||
|
||||
|
||||
|
@ -327,11 +327,13 @@ namespace zeus {
|
||||
}
|
||||
bool operator() (zeus::WebServer* _interface,
|
||||
uint32_t _clientId,
|
||||
uint32_t _serviceId,
|
||||
uint32_t _transactionId,
|
||||
uint32_t _partId) {
|
||||
ememory::SharedPtr<zeus::BufferData> answer = zeus::BufferData::create();
|
||||
answer->setTransactionId(_transactionId);
|
||||
answer->setClientId(_clientId);
|
||||
answer->setServiceId(_serviceId);
|
||||
answer->setPartId(_partId);
|
||||
answer->setPartFinish(false);
|
||||
int32_t tmpSize = ZEUS_MINIMUM_SIZE_MULTIPLE;
|
||||
@ -395,6 +397,7 @@ namespace zeus {
|
||||
}
|
||||
bool operator() (zeus::WebServer* _interface,
|
||||
uint32_t _clientId,
|
||||
uint32_t _serviceId,
|
||||
uint32_t _transactionId,
|
||||
uint32_t _partId) {
|
||||
if (m_node.fileIsOpen() == false) {
|
||||
@ -403,6 +406,7 @@ namespace zeus {
|
||||
ememory::SharedPtr<zeus::BufferData> answer = zeus::BufferData::create();
|
||||
answer->setTransactionId(_transactionId);
|
||||
answer->setClientId(_clientId);
|
||||
answer->setServiceId(_serviceId);
|
||||
answer->setPartId(_partId);
|
||||
answer->setPartFinish(false);
|
||||
int32_t tmpSize = ZEUS_MINIMUM_SIZE_MULTIPLE;
|
||||
|
@ -118,12 +118,14 @@ class SendAsyncBinary {
|
||||
private:
|
||||
std::vector<zeus::ActionAsyncClient> m_async;
|
||||
uint64_t m_transactionId;
|
||||
uint32_t m_clientId;
|
||||
uint32_t m_serviceId;
|
||||
uint32_t m_partId;
|
||||
public:
|
||||
SendAsyncBinary(uint64_t _transactionId, const uint32_t& _serviceId, std::vector<zeus::ActionAsyncClient> _async) :
|
||||
SendAsyncBinary(uint64_t _transactionId, const uint32_t& _clientId, const uint32_t& _serviceId, std::vector<zeus::ActionAsyncClient> _async) :
|
||||
m_async(std::move(_async)),
|
||||
m_transactionId(_transactionId),
|
||||
m_clientId(_clientId),
|
||||
m_serviceId(_serviceId),
|
||||
m_partId(1) {
|
||||
|
||||
@ -131,7 +133,7 @@ class SendAsyncBinary {
|
||||
bool operator() (zeus::WebServer* _interface){
|
||||
auto it = m_async.begin();
|
||||
while (it != m_async.end()) {
|
||||
bool ret = (*it)(_interface, m_serviceId, m_transactionId, m_partId);
|
||||
bool ret = (*it)(_interface, m_clientId, m_serviceId, m_transactionId, m_partId);
|
||||
if (ret == true) {
|
||||
// Remove it ...
|
||||
it = m_async.erase(it);
|
||||
@ -146,6 +148,7 @@ class SendAsyncBinary {
|
||||
return true;
|
||||
}
|
||||
//obj->setInterfaceId(m_interfaceId);
|
||||
obj->setClientId(m_clientId);
|
||||
obj->setServiceId(m_serviceId);
|
||||
obj->setTransactionId(m_transactionId);
|
||||
obj->setPartId(m_partId);
|
||||
@ -173,7 +176,7 @@ int32_t zeus::WebServer::writeBinary(ememory::SharedPtr<zeus::Buffer> _obj) {
|
||||
if (_obj->writeOn(m_connection) == true) {
|
||||
m_connection.send();
|
||||
if (_obj->haveAsync() == true) {
|
||||
addAsync(SendAsyncBinary(_obj->getTransactionId(), _obj->getServiceId(), std::move(_obj->moveAsync())));
|
||||
addAsync(SendAsyncBinary(_obj->getTransactionId(), _obj->getClientId(), _obj->getServiceId(), std::move(_obj->moveAsync())));
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user