[DEV] finish chaneg in zeus and set interface with websocket
This commit is contained in:
parent
fcfffdd6b0
commit
c362381107
@ -10,7 +10,7 @@ TODO ...
|
||||
|
||||
License (APACHE v2.0)
|
||||
=====================
|
||||
Copyright jus Edouard DUPIN
|
||||
Copyright zeus Edouard DUPIN
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
@ -7,7 +7,7 @@ def get_type():
|
||||
return "LIBRARY"
|
||||
|
||||
def get_desc():
|
||||
return "Json micro-service"
|
||||
return "Zeus ewol micro-service"
|
||||
|
||||
def get_licence():
|
||||
return "APACHE-2"
|
||||
@ -28,48 +28,48 @@ def create(target, module_name):
|
||||
my_module = module.Module(__file__, module_name, get_type())
|
||||
my_module.add_module_depend(['etk', 'enet', 'ememory', 'eproperty', 'esignal'])
|
||||
my_module.add_src_file([
|
||||
'jus/debug.cpp'
|
||||
'zeus/debug.cpp'
|
||||
])
|
||||
my_module.add_path(tools.get_current_path(__file__))
|
||||
my_module.add_src_file([
|
||||
'jus/AbstractFunction.cpp',
|
||||
'jus/AbstractFunctionTypeDirect.cpp',
|
||||
'jus/AbstractFunctionTypeClass.cpp',
|
||||
'jus/FutureBase.cpp',
|
||||
'jus/Future.cpp',
|
||||
'jus/File.cpp',
|
||||
'jus/Buffer.cpp',
|
||||
'jus/ParamType.cpp',
|
||||
'jus/Client.cpp',
|
||||
'jus/GateWay.cpp',
|
||||
'jus/GateWayService.cpp',
|
||||
'jus/GateWayClient.cpp',
|
||||
'jus/RemoteProcessCall.cpp',
|
||||
'jus/Service.cpp',
|
||||
'jus/ServiceRemote.cpp',
|
||||
'jus/TcpString.cpp',
|
||||
'jus/mineType.cpp',
|
||||
'zeus/AbstractFunction.cpp',
|
||||
'zeus/AbstractFunctionTypeDirect.cpp',
|
||||
'zeus/AbstractFunctionTypeClass.cpp',
|
||||
'zeus/FutureBase.cpp',
|
||||
'zeus/Future.cpp',
|
||||
'zeus/File.cpp',
|
||||
'zeus/Buffer.cpp',
|
||||
'zeus/ParamType.cpp',
|
||||
'zeus/Client.cpp',
|
||||
'zeus/GateWay.cpp',
|
||||
'zeus/GateWayService.cpp',
|
||||
'zeus/GateWayClient.cpp',
|
||||
'zeus/RemoteProcessCall.cpp',
|
||||
'zeus/Service.cpp',
|
||||
'zeus/ServiceRemote.cpp',
|
||||
'zeus/TcpString.cpp',
|
||||
'zeus/mineType.cpp',
|
||||
])
|
||||
my_module.add_header_file([
|
||||
'jus/AbstractFunction.h',
|
||||
'jus/AbstractFunctionTypeDirect.h',
|
||||
'jus/AbstractFunctionTypeClass.h',
|
||||
'jus/FutureData.h',
|
||||
'jus/FutureBase.h',
|
||||
'jus/Future.h',
|
||||
'jus/File.h',
|
||||
'jus/Buffer.h',
|
||||
'jus/ParamType.h',
|
||||
'jus/debug.h',
|
||||
'jus/Client.h',
|
||||
'jus/GateWay.h',
|
||||
'jus/GateWayService.h',
|
||||
'jus/GateWayClient.h',
|
||||
'jus/RemoteProcessCall.h',
|
||||
'jus/Service.h',
|
||||
'jus/ServiceRemote.h',
|
||||
'jus/TcpString.h',
|
||||
'jus/mineType.h',
|
||||
'zeus/AbstractFunction.h',
|
||||
'zeus/AbstractFunctionTypeDirect.h',
|
||||
'zeus/AbstractFunctionTypeClass.h',
|
||||
'zeus/FutureData.h',
|
||||
'zeus/FutureBase.h',
|
||||
'zeus/Future.h',
|
||||
'zeus/File.h',
|
||||
'zeus/Buffer.h',
|
||||
'zeus/ParamType.h',
|
||||
'zeus/debug.h',
|
||||
'zeus/Client.h',
|
||||
'zeus/GateWay.h',
|
||||
'zeus/GateWayService.h',
|
||||
'zeus/GateWayClient.h',
|
||||
'zeus/RemoteProcessCall.h',
|
||||
'zeus/Service.h',
|
||||
'zeus/ServiceRemote.h',
|
||||
'zeus/TcpString.h',
|
||||
'zeus/mineType.h',
|
||||
])
|
||||
if target.config["compilator"] == "clang":
|
||||
my_module.add_export_flag('c++', "-Wno-unsequenced")
|
||||
|
@ -7,6 +7,6 @@
|
||||
#include <appl/debug.h>
|
||||
|
||||
int32_t appl::getLogId() {
|
||||
static int32_t g_val = elog::registerInstance("jus-test-client");
|
||||
static int32_t g_val = elog::registerInstance("zeus-test-client");
|
||||
return g_val;
|
||||
}
|
||||
|
@ -5,9 +5,9 @@
|
||||
*/
|
||||
|
||||
#include <appl/debug.h>
|
||||
#include <jus/Client.h>
|
||||
#include <jus/ServiceRemote.h>
|
||||
#include <jus/mineType.h>
|
||||
#include <zeus/Client.h>
|
||||
#include <zeus/ServiceRemote.h>
|
||||
#include <zeus/mineType.h>
|
||||
#include <etk/etk.h>
|
||||
#include <etk/os/FSNode.h>
|
||||
#include <unistd.h>
|
||||
@ -16,7 +16,7 @@
|
||||
|
||||
int main(int _argc, const char *_argv[]) {
|
||||
etk::init(_argc, _argv);
|
||||
jus::Client client1;
|
||||
zeus::Client client1;
|
||||
for (int32_t iii=0; iii<_argc ; ++iii) {
|
||||
std::string data = _argv[iii];
|
||||
if (etk::start_with(data, "--ip=") == true) {
|
||||
@ -33,11 +33,11 @@ int main(int _argc, const char *_argv[]) {
|
||||
}
|
||||
}
|
||||
APPL_INFO("==================================");
|
||||
APPL_INFO("== JUS test client start ==");
|
||||
APPL_INFO("== ZEUS test client start ==");
|
||||
APPL_INFO("==================================");
|
||||
client1.connect("test1#atria-soft.com");
|
||||
if (false) {
|
||||
jus::Future<bool> retIdentify = client1.call("identify", "clientTest1#atria-soft.com", "QSDQSDGQSF54HSXWVCSQDJ654URTDJ654NBXCDFDGAEZ51968");
|
||||
zeus::Future<bool> retIdentify = client1.call("identify", "clientTest1#atria-soft.com", "QSDQSDGQSF54HSXWVCSQDJ654URTDJ654NBXCDFDGAEZ51968");
|
||||
retIdentify.wait();
|
||||
if (retIdentify.get() == false) {
|
||||
APPL_ERROR(" ==> NOT Connected with 'clientTest1#atria-soft.com'");
|
||||
@ -46,7 +46,7 @@ int main(int _argc, const char *_argv[]) {
|
||||
APPL_INFO(" ==> Connected with 'clientTest1#atria-soft.com'");
|
||||
}
|
||||
} else if (true) {
|
||||
jus::Future<bool> retIdentify = client1.call("auth", "coucou");
|
||||
zeus::Future<bool> retIdentify = client1.call("auth", "coucou");
|
||||
retIdentify.wait();
|
||||
if (retIdentify.get() == false) {
|
||||
APPL_ERROR(" ==> NOT Authentify with 'test1#atria-soft.com'");
|
||||
@ -55,7 +55,7 @@ int main(int _argc, const char *_argv[]) {
|
||||
APPL_INFO(" ==> Authentify with 'test1#atria-soft.com'");
|
||||
}
|
||||
} else {
|
||||
jus::Future<bool> retIdentify = client1.call("anonymous");
|
||||
zeus::Future<bool> retIdentify = client1.call("anonymous");
|
||||
retIdentify.wait();
|
||||
if (retIdentify.get() == false) {
|
||||
APPL_ERROR(" ==> NOT Connected with 'anonymous'");
|
||||
@ -70,17 +70,17 @@ int main(int _argc, const char *_argv[]) {
|
||||
APPL_INFO(" ----------------------------------");
|
||||
APPL_INFO(" -- Get service count");
|
||||
APPL_INFO(" ----------------------------------");
|
||||
jus::Future<int32_t> retNbService = client1.call("getServiceCount");
|
||||
zeus::Future<int32_t> retNbService = client1.call("getServiceCount");
|
||||
retNbService.wait();
|
||||
APPL_INFO("Nb services = " << retNbService.get());
|
||||
jus::Future<std::vector<std::string>> retServiceList = client1.call("getServiceList");
|
||||
zeus::Future<std::vector<std::string>> retServiceList = client1.call("getServiceList");
|
||||
retServiceList.wait();
|
||||
APPL_INFO("List services:");
|
||||
for (auto &it: retServiceList.get()) {
|
||||
APPL_INFO(" - " << it);
|
||||
}
|
||||
/*
|
||||
jus::ServiceRemote localService = client1.getService("serviceTest1");
|
||||
zeus::ServiceRemote localService = client1.getService("serviceTest1");
|
||||
if (localService.exist() == true) {
|
||||
double retCall = localService.call_d("mul", 13.1, 2.0);
|
||||
APPL_INFO("serviceTest1.mul = " << retCall);
|
||||
@ -92,16 +92,16 @@ int main(int _argc, const char *_argv[]) {
|
||||
APPL_INFO(" -- Get service system-user");
|
||||
APPL_INFO(" ----------------------------------");
|
||||
|
||||
jus::ServiceRemote remoteServiceUser = client1.getService("system-user");
|
||||
zeus::ServiceRemote remoteServiceUser = client1.getService("system-user");
|
||||
if (remoteServiceUser.exist() == true) {
|
||||
jus::Future<std::vector<std::string>> retCall = remoteServiceUser.call("getGroups", "clientTest1#atria-soft.com");
|
||||
zeus::Future<std::vector<std::string>> retCall = remoteServiceUser.call("getGroups", "clientTest1#atria-soft.com");
|
||||
retCall.wait();
|
||||
APPL_INFO("system-user.getGroups() = " << retCall.get());
|
||||
jus::Future<std::string> retDesc = remoteServiceUser.call("sys.getDescription");
|
||||
jus::Future<std::string> retVersion = remoteServiceUser.call("sys.getVersion");
|
||||
jus::Future<std::string> retType = remoteServiceUser.call("sys.getType");
|
||||
jus::Future<std::vector<std::string>> retExtention = remoteServiceUser.call("srv.getExtention");
|
||||
jus::Future<std::vector<std::string>> retMaintainer = remoteServiceUser.call("sys.getAuthors");
|
||||
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();
|
||||
@ -121,11 +121,11 @@ int main(int _argc, const char *_argv[]) {
|
||||
APPL_INFO(" description:");
|
||||
APPL_INFO(" " << retDesc.get());
|
||||
APPL_INFO(" Function List:");
|
||||
jus::Future<std::vector<std::string>> retFuctions = remoteServiceUser.call("sys.getFunctions").wait();
|
||||
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();
|
||||
jus::Future<std::string> retFunctionPrototype = remoteServiceUser.call("sys.getFunctionPrototype", it);
|
||||
jus::Future<std::string> retFunctionHelp = remoteServiceUser.call("sys.getFunctionDescription", it);
|
||||
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();
|
||||
@ -141,36 +141,36 @@ int main(int _argc, const char *_argv[]) {
|
||||
APPL_INFO(" -- Get service picture");
|
||||
APPL_INFO(" ----------------------------------");
|
||||
if (false) {
|
||||
jus::ServiceRemote remoteServicePicture = client1.getService("picture");
|
||||
zeus::ServiceRemote remoteServicePicture = client1.getService("picture");
|
||||
if (remoteServicePicture.exist() == true) {
|
||||
/*
|
||||
jus::Future<std::vector<std::string>> retCall = remoteServicePicture.call("getAlbums").wait();
|
||||
zeus::Future<std::vector<std::string>> retCall = remoteServicePicture.call("getAlbums").wait();
|
||||
APPL_INFO(" album list: ");
|
||||
for (auto &it : retCall.get()) {
|
||||
jus::Future<uint32_t> retCount = remoteServicePicture.call("getAlbumCount", it).wait();
|
||||
zeus::Future<uint32_t> retCount = remoteServicePicture.call("getAlbumCount", it).wait();
|
||||
if (retCount.get() != 0) {
|
||||
APPL_INFO(" - " << it << " / " << retCount.get() << " images");
|
||||
jus::Future<std::vector<std::string>> retListImage = remoteServicePicture.call("getAlbumListPicture", it).wait();
|
||||
zeus::Future<std::vector<std::string>> retListImage = remoteServicePicture.call("getAlbumListPicture", it).wait();
|
||||
for (auto &it3 : retListImage.get()) {
|
||||
APPL_INFO(" - " << it3);
|
||||
}
|
||||
} else {
|
||||
APPL_INFO(" - " << it);
|
||||
}
|
||||
jus::Future<std::vector<std::string>> retCall2 = remoteServicePicture.call("getSubAlbums", it).wait();
|
||||
zeus::Future<std::vector<std::string>> retCall2 = remoteServicePicture.call("getSubAlbums", it).wait();
|
||||
for (auto &it2 : retCall2.get()) {
|
||||
jus::Future<uint32_t> retCount2 = remoteServicePicture.call("getAlbumCount", it2).wait();
|
||||
zeus::Future<uint32_t> retCount2 = remoteServicePicture.call("getAlbumCount", it2).wait();
|
||||
if (retCount2.get() != 0) {
|
||||
APPL_INFO(" - " << it2 << " / " << retCount2.get() << " images");
|
||||
jus::Future<std::vector<std::string>> retListImage = remoteServicePicture.call("getAlbumListPicture", it2).wait();
|
||||
zeus::Future<std::vector<std::string>> retListImage = remoteServicePicture.call("getAlbumListPicture", it2).wait();
|
||||
for (auto &it3 : retListImage.get()) {
|
||||
APPL_INFO(" - " << it3);
|
||||
jus::Future<jus::File> retListImage = remoteServicePicture.call("getAlbumPicture", it3).wait();
|
||||
jus::File tmpFile = retListImage.get();
|
||||
zeus::Future<zeus::File> retListImage = remoteServicePicture.call("getAlbumPicture", it3).wait();
|
||||
zeus::File tmpFile = retListImage.get();
|
||||
APPL_INFO(" mine-type: " << tmpFile.getMineType());
|
||||
APPL_INFO(" size: " << tmpFile.getData().size());
|
||||
APPL_INFO(" receive in =" << int64_t(retListImage.getTransmitionTime().count()/1000)/1000.0 << " ms");
|
||||
std::string tmpFileName = std::string("./out/") + it + "_" + it2 + "_" + it3 + "." + jus::getExtention(tmpFile.getMineType());
|
||||
std::string tmpFileName = std::string("./out/") + it + "_" + it2 + "_" + it3 + "." + zeus::getExtention(tmpFile.getMineType());
|
||||
APPL_INFO(" store in: " << tmpFileName);
|
||||
etk::FSNode node(tmpFileName);
|
||||
node.fileOpenWrite();
|
||||
@ -185,9 +185,9 @@ int main(int _argc, const char *_argv[]) {
|
||||
*/
|
||||
#if 0
|
||||
std::chrono::steady_clock::time_point start = std::chrono::steady_clock::now();
|
||||
jus::File tmp("./photo_2016_33913.bmp");//"image/jpg", {0,5,2,6,7,5,8,4,5,2,1,5,65,5,2,6,85,4,6,6,54,65,88,64,14,6,4,64,51,3,16,4});
|
||||
zeus::File tmp("./photo_2016_33913.bmp");//"image/jpg", {0,5,2,6,7,5,8,4,5,2,1,5,65,5,2,6,85,4,6,6,54,65,88,64,14,6,4,64,51,3,16,4});
|
||||
int32_t size = tmp.getData().size();
|
||||
jus::FutureBase retSendImage = remoteServicePicture.call("addFile", tmp).wait();
|
||||
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");
|
||||
double megaParSec = double(size)/(double((stop-start).count())/1000000000.0);
|
||||
@ -203,7 +203,7 @@ int main(int _argc, const char *_argv[]) {
|
||||
}
|
||||
client1.disconnect();
|
||||
APPL_INFO("==================================");
|
||||
APPL_INFO("== JUS test client stop");
|
||||
APPL_INFO("== ZEUS test client stop");
|
||||
APPL_INFO("==================================");
|
||||
return 0;
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ def get_sub_type():
|
||||
return "TOOLS"
|
||||
|
||||
def get_desc():
|
||||
return "JUS generic gateway"
|
||||
return "ZEUS generic gateway"
|
||||
|
||||
def get_licence():
|
||||
return "APACHE-2"
|
||||
@ -27,7 +27,7 @@ def get_maintainer():
|
||||
def create(target, module_name):
|
||||
my_module = module.Module(__file__, module_name, get_type())
|
||||
my_module.add_export_path(tools.get_current_path(__file__))
|
||||
my_module.add_module_depend(['jus'])
|
||||
my_module.add_module_depend(['zeus'])
|
||||
my_module.add_src_file([
|
||||
'appl/debug.cpp',
|
||||
'appl/main.cpp'
|
||||
|
@ -7,6 +7,6 @@
|
||||
#include <appl/debug.h>
|
||||
|
||||
int32_t appl::getLogId() {
|
||||
static int32_t g_val = elog::registerInstance("jus-test-service1");
|
||||
static int32_t g_val = elog::registerInstance("zeus-test-service1");
|
||||
return g_val;
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
#include <appl/debug.h>
|
||||
#include <jus/Service.h>
|
||||
#include <zeus/Service.h>
|
||||
#include <etk/etk.h>
|
||||
#include <unistd.h>
|
||||
|
||||
@ -68,7 +68,7 @@ namespace appl {
|
||||
int main(int _argc, const char *_argv[]) {
|
||||
etk::init(_argc, _argv);
|
||||
appl::UserManager userMng;
|
||||
jus::ServiceType<appl::Calculator, appl::UserManager> serviceInterface(userMng);
|
||||
zeus::ServiceType<appl::Calculator, appl::UserManager> serviceInterface(userMng);
|
||||
serviceInterface.setDescription("Calculator interface");
|
||||
serviceInterface.setVersion("0.1.1");
|
||||
serviceInterface.addAuthor("Heero Yui", "yui.heero@gmail.com");
|
||||
@ -92,7 +92,7 @@ int main(int _argc, const char *_argv[]) {
|
||||
}
|
||||
}
|
||||
APPL_INFO("==================================");
|
||||
APPL_INFO("== JUS test service1 start ==");
|
||||
APPL_INFO("== ZEUS test service1 start ==");
|
||||
APPL_INFO("==================================");
|
||||
serviceInterface.connect("serviceTest1");
|
||||
int32_t iii=0;
|
||||
@ -104,7 +104,7 @@ int main(int _argc, const char *_argv[]) {
|
||||
}
|
||||
serviceInterface.disconnect();
|
||||
APPL_INFO("==================================");
|
||||
APPL_INFO("== JUS test service1 stop ==");
|
||||
APPL_INFO("== ZEUS test service1 stop ==");
|
||||
APPL_INFO("==================================");
|
||||
return 0;
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ def get_sub_type():
|
||||
return "TOOLS"
|
||||
|
||||
def get_desc():
|
||||
return "JUS test service"
|
||||
return "ZEUS test service"
|
||||
|
||||
def get_licence():
|
||||
return "APACHE-2"
|
||||
@ -27,7 +27,7 @@ def get_maintainer():
|
||||
def create(target, module_name):
|
||||
my_module = module.Module(__file__, module_name, get_type())
|
||||
my_module.add_export_path(tools.get_current_path(__file__))
|
||||
my_module.add_module_depend(['jus'])
|
||||
my_module.add_module_depend(['zeus'])
|
||||
my_module.add_src_file([
|
||||
'appl/debug.cpp',
|
||||
'appl/main.cpp'
|
||||
|
@ -7,6 +7,6 @@
|
||||
#include <appl/debug.h>
|
||||
|
||||
int32_t appl::getLogId() {
|
||||
static int32_t g_val = elog::registerInstance("jus-picture");
|
||||
static int32_t g_val = elog::registerInstance("zeus-picture");
|
||||
return g_val;
|
||||
}
|
||||
|
@ -5,8 +5,8 @@
|
||||
*/
|
||||
|
||||
#include <appl/debug.h>
|
||||
#include <jus/Service.h>
|
||||
#include <jus/File.h>
|
||||
#include <zeus/Service.h>
|
||||
#include <zeus/File.h>
|
||||
#include <etk/etk.h>
|
||||
#include <unistd.h>
|
||||
#include <mutex>
|
||||
@ -200,7 +200,7 @@ namespace appl {
|
||||
return out;
|
||||
}
|
||||
// Return a File Data (might be a picture .tiff/.png/.jpg)
|
||||
jus::FileServer getAlbumPicture(const std::string& _pictureName) {
|
||||
zeus::FileServer getAlbumPicture(const std::string& _pictureName) {
|
||||
std::unique_lock<std::mutex> lock(m_mutex);
|
||||
// TODO : Check right ...
|
||||
uint64_t id = etk::string_to_uint64_t(_pictureName);
|
||||
@ -208,19 +208,19 @@ namespace appl {
|
||||
{
|
||||
auto it = m_listFile.find(id);
|
||||
if (it != m_listFile.end()) {
|
||||
return jus::FileServer(m_basePath + it->second);
|
||||
return zeus::FileServer(m_basePath + it->second);
|
||||
}
|
||||
}
|
||||
for (auto &it : m_listFile) {
|
||||
APPL_WARNING("compare: " << it.first << " with " << id << " " << it.second);
|
||||
if (it.first == id) {
|
||||
return jus::FileServer(m_basePath + it.second);
|
||||
return zeus::FileServer(m_basePath + it.second);
|
||||
}
|
||||
}
|
||||
APPL_ERROR(" ==> Not find ...");
|
||||
return jus::FileServer();
|
||||
return zeus::FileServer();
|
||||
}
|
||||
std::string addFile(const jus::File& _dataFile) {
|
||||
std::string addFile(const zeus::File& _dataFile) {
|
||||
std::unique_lock<std::mutex> lock(m_mutex);
|
||||
// TODO : Check right ...
|
||||
APPL_ERROR(" ==> Receive FILE " << _dataFile.getMineType() << " size=" << _dataFile.getData().size());
|
||||
@ -229,10 +229,10 @@ namespace appl {
|
||||
val << std::hex << std::setw(16) << std::setfill('0') << id;
|
||||
std::string filename = val.str();
|
||||
filename += ".";
|
||||
filename += jus::getExtention(_dataFile.getMineType());
|
||||
filename += zeus::getExtention(_dataFile.getMineType());
|
||||
_dataFile.storeIn(m_basePath + filename);
|
||||
m_listFile.insert(std::make_pair(id, filename));
|
||||
return etk::to_string(id);//jus::FileServer();
|
||||
return etk::to_string(id);//zeus::FileServer();
|
||||
}
|
||||
bool removeFile(const std::string& _file) {
|
||||
std::unique_lock<std::mutex> lock(m_mutex);
|
||||
@ -274,16 +274,16 @@ namespace appl {
|
||||
}
|
||||
/*
|
||||
// Return a global UTC time
|
||||
jus::Time getAlbumPictureTime(const std::string& _pictureName) {
|
||||
zeus::Time getAlbumPictureTime(const std::string& _pictureName) {
|
||||
std::unique_lock<std::mutex> lock(m_mutex);
|
||||
// TODO : Check right ...
|
||||
return jus::Time();
|
||||
return zeus::Time();
|
||||
}
|
||||
// Return a Geolocalization information (latitude, longitude)
|
||||
jus::Geo getAlbumPictureGeoLocalization(const std::string& _pictureName) {
|
||||
zeus::Geo getAlbumPictureGeoLocalization(const std::string& _pictureName) {
|
||||
std::unique_lock<std::mutex> lock(m_mutex);
|
||||
// TODO : Check right ...
|
||||
return jus::Geo();
|
||||
return zeus::Geo();
|
||||
}
|
||||
*/
|
||||
private:
|
||||
@ -318,12 +318,12 @@ namespace appl {
|
||||
private:
|
||||
ememory::SharedPtr<appl::User> m_user;
|
||||
private:
|
||||
ememory::SharedPtr<jus::ClientProperty> m_client;
|
||||
ememory::SharedPtr<zeus::ClientProperty> m_client;
|
||||
public:
|
||||
PictureService() {
|
||||
APPL_WARNING("New PictureService ...");
|
||||
}
|
||||
PictureService(ememory::SharedPtr<appl::User> _user, ememory::SharedPtr<jus::ClientProperty> _client) :
|
||||
PictureService(ememory::SharedPtr<appl::User> _user, ememory::SharedPtr<zeus::ClientProperty> _client) :
|
||||
m_user(_user),
|
||||
m_client(_client) {
|
||||
APPL_WARNING("New PictureService ... for user: ");
|
||||
@ -348,19 +348,19 @@ namespace appl {
|
||||
return m_user->getAlbumListPicture(_album);//, _startId, _stopId);
|
||||
}
|
||||
// Return a File Data (might be a picture .tiff/.png/.jpg)
|
||||
jus::FileServer getAlbumPicture(std::string _pictureName) {
|
||||
zeus::FileServer getAlbumPicture(std::string _pictureName) {
|
||||
return m_user->getAlbumPicture(_pictureName);
|
||||
}
|
||||
std::string addFile(jus::File _dataFile) {
|
||||
std::string addFile(zeus::File _dataFile) {
|
||||
return m_user->addFile(_dataFile);
|
||||
}
|
||||
/*
|
||||
// Return a global UTC time
|
||||
jus::Time getAlbumPictureTime(std::string _pictureName) {
|
||||
zeus::Time getAlbumPictureTime(std::string _pictureName) {
|
||||
return m_user->getAlbumPictureTime(_pictureName);
|
||||
}
|
||||
// Return a Geolocalization information (latitude, longitude)
|
||||
jus::Geo getAlbumPictureGeoLocalization(std::string _pictureName) {
|
||||
zeus::Geo getAlbumPictureGeoLocalization(std::string _pictureName) {
|
||||
return m_user->getAlbumPictureGeoLocalization(_pictureName);
|
||||
}
|
||||
*/
|
||||
@ -389,10 +389,10 @@ int main(int _argc, const char *_argv[]) {
|
||||
}
|
||||
while (true) {
|
||||
APPL_INFO("===========================================================");
|
||||
APPL_INFO("== JUS instanciate service: " << SERVICE_NAME << " [START]");
|
||||
APPL_INFO("== ZEUS instanciate service: " << SERVICE_NAME << " [START]");
|
||||
APPL_INFO("===========================================================");
|
||||
appl::UserManager userMng;
|
||||
jus::ServiceType<appl::PictureService, appl::UserManager> serviceInterface(userMng);
|
||||
zeus::ServiceType<appl::PictureService, appl::UserManager> serviceInterface(userMng);
|
||||
if (ip != "") {
|
||||
serviceInterface.propertyIp.set(ip);
|
||||
}
|
||||
@ -416,12 +416,12 @@ int main(int _argc, const char *_argv[]) {
|
||||
serviceInterface.advertise("getAlbumPictureGeoLocalization", &appl::PictureService::getAlbumPictureGeoLocalization);
|
||||
*/
|
||||
APPL_INFO("===========================================================");
|
||||
APPL_INFO("== JUS service: " << SERVICE_NAME << " [service instanciate]");
|
||||
APPL_INFO("== ZEUS service: " << SERVICE_NAME << " [service instanciate]");
|
||||
APPL_INFO("===========================================================");
|
||||
serviceInterface.connect(SERVICE_NAME);
|
||||
if (serviceInterface.GateWayAlive() == false) {
|
||||
APPL_INFO("===========================================================");
|
||||
APPL_INFO("== JUS service: " << SERVICE_NAME << " [STOP] Can not connect to the GateWay");
|
||||
APPL_INFO("== ZEUS service: " << SERVICE_NAME << " [STOP] Can not connect to the GateWay");
|
||||
APPL_INFO("===========================================================");
|
||||
APPL_INFO("wait 5 second ...");
|
||||
usleep(5000000);
|
||||
@ -440,7 +440,7 @@ int main(int _argc, const char *_argv[]) {
|
||||
}
|
||||
serviceInterface.disconnect();
|
||||
APPL_INFO("===========================================================");
|
||||
APPL_INFO("== JUS service: " << SERVICE_NAME << " [STOP] GateWay Stop");
|
||||
APPL_INFO("== ZEUS service: " << SERVICE_NAME << " [STOP] GateWay Stop");
|
||||
APPL_INFO("===========================================================");
|
||||
}
|
||||
return 0;
|
||||
|
@ -10,7 +10,7 @@ def get_sub_type():
|
||||
return "TOOLS"
|
||||
|
||||
def get_desc():
|
||||
return "JUS picture service"
|
||||
return "ZEUS picture service"
|
||||
|
||||
def get_licence():
|
||||
return "APACHE-2"
|
||||
@ -27,7 +27,7 @@ def get_maintainer():
|
||||
def create(target, module_name):
|
||||
my_module = module.Module(__file__, module_name, get_type())
|
||||
my_module.add_export_path(tools.get_current_path(__file__))
|
||||
my_module.add_module_depend(['jus', 'ejson'])
|
||||
my_module.add_module_depend(['zeus', 'ejson'])
|
||||
my_module.add_src_file([
|
||||
'appl/debug.cpp',
|
||||
'appl/main.cpp'
|
||||
|
@ -7,6 +7,6 @@
|
||||
#include <appl/debug.h>
|
||||
|
||||
int32_t appl::getLogId() {
|
||||
static int32_t g_val = elog::registerInstance("jus-gateway");
|
||||
static int32_t g_val = elog::registerInstance("zeus-gateway");
|
||||
return g_val;
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
#include <appl/debug.h>
|
||||
#include <jus/GateWay.h>
|
||||
#include <zeus/GateWay.h>
|
||||
#include <etk/etk.h>
|
||||
#include <unistd.h>
|
||||
|
||||
@ -13,7 +13,7 @@
|
||||
|
||||
int main(int _argc, const char *_argv[]) {
|
||||
etk::init(_argc, _argv);
|
||||
jus::GateWay basicGateway;
|
||||
zeus::GateWay basicGateway;
|
||||
for (int32_t iii=0; iii<_argc ; ++iii) {
|
||||
std::string data = _argv[iii];
|
||||
if (etk::start_with(data, "--client-ip=") == true) {
|
||||
@ -42,7 +42,7 @@ int main(int _argc, const char *_argv[]) {
|
||||
}
|
||||
}
|
||||
APPL_INFO("==================================");
|
||||
APPL_INFO("== JUS gateway start ==");
|
||||
APPL_INFO("== ZEUS gateway start ==");
|
||||
APPL_INFO("==================================");
|
||||
basicGateway.start();
|
||||
while (true) {
|
||||
@ -51,7 +51,7 @@ int main(int _argc, const char *_argv[]) {
|
||||
}
|
||||
basicGateway.stop();
|
||||
APPL_INFO("==================================");
|
||||
APPL_INFO("== JUS gateway stop ==");
|
||||
APPL_INFO("== ZEUS gateway stop ==");
|
||||
APPL_INFO("==================================");
|
||||
return 0;
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ def get_sub_type():
|
||||
return "TOOLS"
|
||||
|
||||
def get_desc():
|
||||
return "JUS generic gateway"
|
||||
return "ZEUS generic gateway"
|
||||
|
||||
def get_licence():
|
||||
return "APACHE-2"
|
||||
@ -27,7 +27,7 @@ def get_maintainer():
|
||||
def create(target, module_name):
|
||||
my_module = module.Module(__file__, module_name, get_type())
|
||||
my_module.add_export_path(tools.get_current_path(__file__))
|
||||
my_module.add_module_depend(['jus'])
|
||||
my_module.add_module_depend(['zeus'])
|
||||
my_module.add_src_file([
|
||||
'appl/debug.cpp',
|
||||
'appl/main.cpp'
|
||||
|
@ -7,6 +7,6 @@
|
||||
#include <appl/debug.h>
|
||||
|
||||
int32_t appl::getLogId() {
|
||||
static int32_t g_val = elog::registerInstance("jus-system-service");
|
||||
static int32_t g_val = elog::registerInstance("zeus-system-service");
|
||||
return g_val;
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
#include <appl/debug.h>
|
||||
#include <jus/Service.h>
|
||||
#include <zeus/Service.h>
|
||||
#include <etk/etk.h>
|
||||
#include <unistd.h>
|
||||
#include <mutex>
|
||||
@ -133,12 +133,12 @@ namespace appl {
|
||||
private:
|
||||
ememory::SharedPtr<appl::User> m_user;
|
||||
private:
|
||||
ememory::SharedPtr<jus::ClientProperty> m_client;
|
||||
ememory::SharedPtr<zeus::ClientProperty> m_client;
|
||||
public:
|
||||
SystemService() {
|
||||
APPL_WARNING("New SystemService ...");
|
||||
}
|
||||
SystemService(ememory::SharedPtr<appl::User> _user, ememory::SharedPtr<jus::ClientProperty> _client) :
|
||||
SystemService(ememory::SharedPtr<appl::User> _user, ememory::SharedPtr<zeus::ClientProperty> _client) :
|
||||
m_user(_user),
|
||||
m_client(_client) {
|
||||
APPL_WARNING("New SystemService ... for user: ");
|
||||
@ -196,10 +196,10 @@ int main(int _argc, const char *_argv[]) {
|
||||
}
|
||||
while (true) {
|
||||
APPL_INFO("===========================================================");
|
||||
APPL_INFO("== JUS instanciate service: " << SERVICE_NAME << " [START]");
|
||||
APPL_INFO("== ZEUS instanciate service: " << SERVICE_NAME << " [START]");
|
||||
APPL_INFO("===========================================================");
|
||||
appl::UserManager userMng;
|
||||
jus::ServiceType<appl::SystemService, appl::UserManager> serviceInterface(userMng);
|
||||
zeus::ServiceType<appl::SystemService, appl::UserManager> serviceInterface(userMng);
|
||||
if (ip != "") {
|
||||
serviceInterface.propertyIp.set(ip);
|
||||
}
|
||||
@ -225,12 +225,12 @@ int main(int _argc, const char *_argv[]) {
|
||||
serviceInterface.addLastFuncParam("clientName", "Name of the client");
|
||||
serviceInterface.addLastFuncParam("currentList", "Vector of name of the services");
|
||||
APPL_INFO("===========================================================");
|
||||
APPL_INFO("== JUS service: " << SERVICE_NAME << " [service instanciate]");
|
||||
APPL_INFO("== ZEUS service: " << SERVICE_NAME << " [service instanciate]");
|
||||
APPL_INFO("===========================================================");
|
||||
serviceInterface.connect(SERVICE_NAME);
|
||||
if (serviceInterface.GateWayAlive() == false) {
|
||||
APPL_INFO("===========================================================");
|
||||
APPL_INFO("== JUS service: " << SERVICE_NAME << " [STOP] Can not connect to the GateWay");
|
||||
APPL_INFO("== ZEUS service: " << SERVICE_NAME << " [STOP] Can not connect to the GateWay");
|
||||
APPL_INFO("===========================================================");
|
||||
APPL_INFO("wait 5 second ...");
|
||||
usleep(5000000);
|
||||
@ -245,7 +245,7 @@ int main(int _argc, const char *_argv[]) {
|
||||
}
|
||||
serviceInterface.disconnect();
|
||||
APPL_INFO("===========================================================");
|
||||
APPL_INFO("== JUS service: " << SERVICE_NAME << " [STOP] GateWay Stop");
|
||||
APPL_INFO("== ZEUS service: " << SERVICE_NAME << " [STOP] GateWay Stop");
|
||||
APPL_INFO("===========================================================");
|
||||
}
|
||||
return 0;
|
||||
|
@ -10,7 +10,7 @@ def get_sub_type():
|
||||
return "TOOLS"
|
||||
|
||||
def get_desc():
|
||||
return "JUS test service"
|
||||
return "ZEUS test service"
|
||||
|
||||
def get_licence():
|
||||
return "APACHE-2"
|
||||
@ -27,7 +27,7 @@ def get_maintainer():
|
||||
def create(target, module_name):
|
||||
my_module = module.Module(__file__, module_name, get_type())
|
||||
my_module.add_export_path(tools.get_current_path(__file__))
|
||||
my_module.add_module_depend(['jus', 'ejson'])
|
||||
my_module.add_module_depend(['zeus', 'ejson'])
|
||||
my_module.add_src_file([
|
||||
'appl/debug.cpp',
|
||||
'appl/main.cpp'
|
||||
|
@ -3,61 +3,61 @@
|
||||
* @copyright 2016, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
#include <jus/AbstractFunction.h>
|
||||
#include <jus/debug.h>
|
||||
#include <zeus/AbstractFunction.h>
|
||||
#include <zeus/debug.h>
|
||||
#include <etk/os/FSNode.h>
|
||||
|
||||
jus::Buffer jus::createBinaryCall(uint64_t _transactionId, const std::string& _functionName, const jus::Buffer& _params) {
|
||||
jus::Buffer callElem = createBinaryBaseCall(_transactionId, _functionName);
|
||||
zeus::Buffer zeus::createBinaryCall(uint64_t _transactionId, const std::string& _functionName, const zeus::Buffer& _params) {
|
||||
zeus::Buffer callElem = createBinaryBaseCall(_transactionId, _functionName);
|
||||
//callElem.add("param", _params);
|
||||
return callElem;
|
||||
}
|
||||
|
||||
jus::Buffer jus::createBinaryBaseCall(uint64_t _transactionId, const std::string& _functionName, const uint32_t& _serviceId) {
|
||||
jus::Buffer obj;
|
||||
zeus::Buffer zeus::createBinaryBaseCall(uint64_t _transactionId, const std::string& _functionName, const uint32_t& _serviceId) {
|
||||
zeus::Buffer obj;
|
||||
obj.setServiceId(_serviceId);
|
||||
obj.setCall(_functionName);
|
||||
obj.setTransactionId(_transactionId);
|
||||
return obj;
|
||||
}
|
||||
|
||||
void jus::createBinaryParam(std::vector<ActionAsyncClient>& _asyncAction, int32_t _paramId, jus::Buffer& _obj) {
|
||||
void zeus::createBinaryParam(std::vector<ActionAsyncClient>& _asyncAction, int32_t _paramId, zeus::Buffer& _obj) {
|
||||
// Finish recursive parse ...
|
||||
}
|
||||
|
||||
enum jus::AbstractFunction::type jus::AbstractFunction::getType() const {
|
||||
enum zeus::AbstractFunction::type zeus::AbstractFunction::getType() const {
|
||||
return m_type;
|
||||
}
|
||||
|
||||
void jus::AbstractFunction::setType(enum jus::AbstractFunction::type _type) {
|
||||
void zeus::AbstractFunction::setType(enum zeus::AbstractFunction::type _type) {
|
||||
m_type = _type;
|
||||
}
|
||||
|
||||
const std::string& jus::AbstractFunction::getName() const {
|
||||
const std::string& zeus::AbstractFunction::getName() const {
|
||||
return m_name;
|
||||
}
|
||||
|
||||
const std::string& jus::AbstractFunction::getDescription() const {
|
||||
const std::string& zeus::AbstractFunction::getDescription() const {
|
||||
return m_description;
|
||||
}
|
||||
|
||||
void jus::AbstractFunction::setDescription(const std::string& _desc) {
|
||||
void zeus::AbstractFunction::setDescription(const std::string& _desc) {
|
||||
m_description = _desc;
|
||||
}
|
||||
|
||||
void jus::AbstractFunction::setParam(int32_t _idParam, const std::string& _name, const std::string& _desc) {
|
||||
JUS_TODO("not implemented set param ... '" << _name << "'");
|
||||
void zeus::AbstractFunction::setParam(int32_t _idParam, const std::string& _name, const std::string& _desc) {
|
||||
ZEUS_TODO("not implemented set param ... '" << _name << "'");
|
||||
}
|
||||
|
||||
void jus::AbstractFunction::addParam(const std::string& _name, const std::string& _desc) {
|
||||
void zeus::AbstractFunction::addParam(const std::string& _name, const std::string& _desc) {
|
||||
m_paramsDescription.push_back(std::make_pair(_name, _desc));
|
||||
}
|
||||
|
||||
void jus::AbstractFunction::setReturn(const std::string& _desc) {
|
||||
void zeus::AbstractFunction::setReturn(const std::string& _desc) {
|
||||
m_returnDescription = _desc;
|
||||
}
|
||||
|
||||
std::string jus::AbstractFunction::getPrototypeFull() const {
|
||||
std::string zeus::AbstractFunction::getPrototypeFull() const {
|
||||
std::string out = getPrototypeReturn();
|
||||
out += " ";
|
||||
out += m_name;
|
||||
@ -77,16 +77,16 @@ std::string jus::AbstractFunction::getPrototypeFull() const {
|
||||
}
|
||||
|
||||
|
||||
jus::AbstractFunction::AbstractFunction(const std::string& _name,
|
||||
zeus::AbstractFunction::AbstractFunction(const std::string& _name,
|
||||
const std::string& _desc):
|
||||
m_type(jus::AbstractFunction::type::unknow),
|
||||
m_type(zeus::AbstractFunction::type::unknow),
|
||||
m_name(_name),
|
||||
m_description(_desc) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
bool jus::AbstractFunction::checkCompatibility(const ParamType& _type, const std::string& _params) {
|
||||
bool zeus::AbstractFunction::checkCompatibility(const ParamType& _type, const std::string& _params) {
|
||||
if (createType<bool>() == _type) {
|
||||
return _params == "bool";
|
||||
}
|
||||
@ -137,7 +137,7 @@ bool jus::AbstractFunction::checkCompatibility(const ParamType& _type, const std
|
||||
|| _params == "vector:double"
|
||||
|| _params == "vector:empty";
|
||||
}
|
||||
if (createType<jus::File>() == _type) {
|
||||
if (createType<zeus::File>() == _type) {
|
||||
return _params == "file";
|
||||
}
|
||||
if (createType<std::string>() == _type) {
|
||||
|
@ -5,13 +5,13 @@
|
||||
*/
|
||||
#pragma once
|
||||
#include <eproperty/Value.h>
|
||||
#include <jus/debug.h>
|
||||
#include <jus/ParamType.h>
|
||||
#include <jus/File.h>
|
||||
#include <jus/Buffer.h>
|
||||
#include <zeus/debug.h>
|
||||
#include <zeus/ParamType.h>
|
||||
#include <zeus/File.h>
|
||||
#include <zeus/Buffer.h>
|
||||
#include <ememory/memory.h>
|
||||
|
||||
namespace jus {
|
||||
namespace zeus {
|
||||
class TcpString;
|
||||
// define basic async call element ...
|
||||
using ActionAsyncClient = std::function<bool(TcpString* _interface, const uint32_t& _serviceId, uint64_t _transactionId, uint64_t _part)>;
|
||||
@ -20,7 +20,7 @@ namespace jus {
|
||||
|
||||
|
||||
|
||||
namespace jus {
|
||||
namespace zeus {
|
||||
class AbstractFunction {
|
||||
public:
|
||||
enum class type {
|
||||
@ -64,21 +64,21 @@ namespace jus {
|
||||
virtual std::string getPrototype() const = 0;
|
||||
virtual std::string getPrototypeReturn() const = 0;
|
||||
virtual std::vector<std::string> getPrototypeParam() const = 0;
|
||||
virtual void execute(const ememory::SharedPtr<jus::TcpString>& _interfaceClient, uint64_t _transactionId, uint64_t _clientId, jus::Buffer& _params, void* _class=nullptr) = 0;
|
||||
virtual void execute(const ememory::SharedPtr<zeus::TcpString>& _interfaceClient, uint64_t _transactionId, uint64_t _clientId, zeus::Buffer& _params, void* _class=nullptr) = 0;
|
||||
};
|
||||
|
||||
jus::Buffer createBinaryBaseCall(uint64_t _transactionId, const std::string& _functionName, const uint32_t& _serviceId=0);
|
||||
zeus::Buffer createBinaryBaseCall(uint64_t _transactionId, const std::string& _functionName, const uint32_t& _serviceId=0);
|
||||
void createBinaryParam(std::vector<ActionAsyncClient>& _asyncAction,
|
||||
int32_t _paramId,
|
||||
jus::Buffer& _obj);
|
||||
zeus::Buffer& _obj);
|
||||
|
||||
template<class JUS_TYPE, class... _ARGS>
|
||||
template<class ZEUS_TYPE, class... _ARGS>
|
||||
void createBinaryParam(std::vector<ActionAsyncClient>& _asyncAction,
|
||||
int32_t _paramId,
|
||||
jus::Buffer& _obj,
|
||||
const JUS_TYPE& _param,
|
||||
zeus::Buffer& _obj,
|
||||
const ZEUS_TYPE& _param,
|
||||
_ARGS&&... _args) {
|
||||
_obj.addParameter<JUS_TYPE>(/*_asyncAction, _paramId,*/ _param);
|
||||
_obj.addParameter<ZEUS_TYPE>(/*_asyncAction, _paramId,*/ _param);
|
||||
_paramId++;
|
||||
createBinaryParam(_asyncAction, _paramId, _obj, std::forward<_ARGS>(_args)...);
|
||||
}
|
||||
@ -86,27 +86,27 @@ namespace jus {
|
||||
template<class... _ARGS>
|
||||
void createBinaryParam(std::vector<ActionAsyncClient>& _asyncAction,
|
||||
int32_t _paramId,
|
||||
jus::Buffer& _obj,
|
||||
zeus::Buffer& _obj,
|
||||
const char* _param,
|
||||
_ARGS&&... _args) {
|
||||
createBinaryParam(_asyncAction, _paramId, _obj, std::string(_param), std::forward<_ARGS>(_args)...);
|
||||
}
|
||||
|
||||
template<class... _ARGS>
|
||||
jus::Buffer createBinaryCall(std::vector<ActionAsyncClient>& _asyncAction, uint64_t _transactionId, const std::string& _functionName, _ARGS&&... _args) {
|
||||
jus::Buffer callElem = createBinaryBaseCall(_transactionId, _functionName);
|
||||
zeus::Buffer createBinaryCall(std::vector<ActionAsyncClient>& _asyncAction, uint64_t _transactionId, const std::string& _functionName, _ARGS&&... _args) {
|
||||
zeus::Buffer callElem = createBinaryBaseCall(_transactionId, _functionName);
|
||||
createBinaryParam(_asyncAction, 0, callElem, std::forward<_ARGS>(_args)...);
|
||||
return callElem;
|
||||
}
|
||||
template<class... _ARGS>
|
||||
jus::Buffer createBinaryCallService(std::vector<ActionAsyncClient>& _asyncAction, uint64_t _transactionId, const uint32_t& _serviceName, const std::string& _functionName, _ARGS&&... _args) {
|
||||
jus::Buffer callElem = createBinaryBaseCall(_transactionId, _functionName, _serviceName);
|
||||
zeus::Buffer createBinaryCallService(std::vector<ActionAsyncClient>& _asyncAction, uint64_t _transactionId, const uint32_t& _serviceName, const std::string& _functionName, _ARGS&&... _args) {
|
||||
zeus::Buffer callElem = createBinaryBaseCall(_transactionId, _functionName, _serviceName);
|
||||
createBinaryParam(_asyncAction, 0, callElem, std::forward<_ARGS>(_args)...);
|
||||
return callElem;
|
||||
}
|
||||
jus::Buffer createBinaryCall(uint64_t _transactionId, const std::string& _functionName, const jus::Buffer& _params);
|
||||
zeus::Buffer createBinaryCall(uint64_t _transactionId, const std::string& _functionName, const zeus::Buffer& _params);
|
||||
|
||||
}
|
||||
|
||||
#include <jus/TcpString.h>
|
||||
#include <zeus/TcpString.h>
|
||||
|
||||
|
@ -5,38 +5,38 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <jus/TcpString.h>
|
||||
#include <zeus/TcpString.h>
|
||||
#include <eproperty/Value.h>
|
||||
#include <jus/debug.h>
|
||||
#include <jus/AbstractFunction.h>
|
||||
#include <jus/mineType.h>
|
||||
#include <zeus/debug.h>
|
||||
#include <zeus/AbstractFunction.h>
|
||||
#include <zeus/mineType.h>
|
||||
#include <etk/os/FSNode.h>
|
||||
|
||||
|
||||
namespace jus {
|
||||
template <class JUS_CLASS_TYPE, class JUS_RETURN, class... JUS_TYPES>
|
||||
void executeClassCall(const ememory::SharedPtr<jus::TcpString>& _interfaceClient,
|
||||
namespace zeus {
|
||||
template <class ZEUS_CLASS_TYPE, class ZEUS_RETURN, class... ZEUS_TYPES>
|
||||
void executeClassCall(const ememory::SharedPtr<zeus::TcpString>& _interfaceClient,
|
||||
uint64_t _transactionId,
|
||||
uint64_t _clientId,
|
||||
JUS_CLASS_TYPE* _pointer,
|
||||
JUS_RETURN (JUS_CLASS_TYPE::*_func)(JUS_TYPES...),
|
||||
jus::Buffer& _obj) {
|
||||
ZEUS_CLASS_TYPE* _pointer,
|
||||
ZEUS_RETURN (ZEUS_CLASS_TYPE::*_func)(ZEUS_TYPES...),
|
||||
zeus::Buffer& _obj) {
|
||||
std::vector<ActionAsyncClient> asyncAction;
|
||||
#if defined(__clang__)
|
||||
// clang generate a basic warning:
|
||||
// warning: multiple unsequenced modifications to 'idParam' [-Wunsequenced]
|
||||
int32_t idParam = 0;
|
||||
JUS_RETURN ret = (*_pointer.*_func)(_obj.getParameter<JUS_TYPES>(idParam++)...);
|
||||
ZEUS_RETURN ret = (*_pointer.*_func)(_obj.getParameter<ZEUS_TYPES>(idParam++)...);
|
||||
#elif defined(__GNUC__) || defined(__GNUG__) || defined(_MSC_VER)
|
||||
int32_t idParam = int32_t(sizeof...(JUS_TYPES))-1;
|
||||
JUS_RETURN ret = (*_pointer.*_func)(_obj.getParameter<JUS_TYPES>(idParam--)...);
|
||||
int32_t idParam = int32_t(sizeof...(ZEUS_TYPES))-1;
|
||||
ZEUS_RETURN ret = (*_pointer.*_func)(_obj.getParameter<ZEUS_TYPES>(idParam--)...);
|
||||
#else
|
||||
#error Must be implemented ...
|
||||
JUS_RETURN ret;
|
||||
ZEUS_RETURN ret;
|
||||
return;
|
||||
#endif
|
||||
if (asyncAction.size() != 0) {
|
||||
JUS_ERROR("Missing send async messages");
|
||||
ZEUS_ERROR("Missing send async messages");
|
||||
}
|
||||
_interfaceClient->addAsync([=](TcpString* _interface) {
|
||||
_interface->answerValue(_transactionId, ret, _clientId);
|
||||
@ -45,14 +45,14 @@ namespace jus {
|
||||
}
|
||||
class SendFile {
|
||||
private:
|
||||
jus::FileServer m_data;
|
||||
zeus::FileServer m_data;
|
||||
uint64_t m_transactionId;
|
||||
uint64_t m_clientId;
|
||||
uint32_t m_partId;
|
||||
etk::FSNode m_node;
|
||||
uint64_t m_size;
|
||||
public:
|
||||
SendFile(jus::FileServer _data,
|
||||
SendFile(zeus::FileServer _data,
|
||||
uint64_t _transactionId,
|
||||
uint64_t _clientId) :
|
||||
m_data(_data),
|
||||
@ -67,7 +67,7 @@ namespace jus {
|
||||
//m_node.fileClose();
|
||||
}
|
||||
bool operator() (TcpString* _interface) {
|
||||
jus::Buffer answer;
|
||||
zeus::Buffer answer;
|
||||
answer.setTransactionId(m_transactionId);
|
||||
answer.setClientId(m_clientId);
|
||||
answer.setPartId(m_partId);
|
||||
@ -75,9 +75,9 @@ namespace jus {
|
||||
if (m_partId == 0) {
|
||||
m_node.fileOpenRead();
|
||||
std::string extention = std::string(m_data.getFileName().begin()+m_data.getFileName().size() -3, m_data.getFileName().end());
|
||||
JUS_WARNING("send file: '" << m_data.getFileName() << "' with extention: '" << extention << "'");
|
||||
ZEUS_WARNING("send file: '" << m_data.getFileName() << "' with extention: '" << extention << "'");
|
||||
m_size = m_node.fileSize();
|
||||
jus::File tmpFile(jus::getMineType(extention), std::vector<uint8_t>(), m_size);
|
||||
zeus::File tmpFile(zeus::getMineType(extention), std::vector<uint8_t>(), m_size);
|
||||
answer.addAnswer(tmpFile);
|
||||
_interface->writeBinary(answer);
|
||||
m_partId++;
|
||||
@ -103,44 +103,44 @@ namespace jus {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
template <class JUS_CLASS_TYPE, class... JUS_TYPES>
|
||||
void executeClassCall(const ememory::SharedPtr<jus::TcpString>& _interfaceClient,
|
||||
template <class ZEUS_CLASS_TYPE, class... ZEUS_TYPES>
|
||||
void executeClassCall(const ememory::SharedPtr<zeus::TcpString>& _interfaceClient,
|
||||
uint64_t _transactionId,
|
||||
uint64_t _clientId,
|
||||
JUS_CLASS_TYPE* _pointer,
|
||||
jus::FileServer (JUS_CLASS_TYPE::*_func)(JUS_TYPES...),
|
||||
jus::Buffer& _obj) {
|
||||
ZEUS_CLASS_TYPE* _pointer,
|
||||
zeus::FileServer (ZEUS_CLASS_TYPE::*_func)(ZEUS_TYPES...),
|
||||
zeus::Buffer& _obj) {
|
||||
#if defined(__clang__)
|
||||
// clang generate a basic warning:
|
||||
// warning: multiple unsequenced modifications to 'idParam' [-Wunsequenced]
|
||||
int32_t idParam = 0;
|
||||
jus::FileServer tmpElem = (*_pointer.*_func)(_obj.getParameter<JUS_TYPES>(idParam++)...);
|
||||
zeus::FileServer tmpElem = (*_pointer.*_func)(_obj.getParameter<ZEUS_TYPES>(idParam++)...);
|
||||
#elif defined(__GNUC__) || defined(__GNUG__) || defined(_MSC_VER)
|
||||
int32_t idParam = int32_t(sizeof...(JUS_TYPES))-1;
|
||||
jus::FileServer tmpElem = (*_pointer.*_func)(_obj.getParameter<JUS_TYPES>(idParam--)...);
|
||||
int32_t idParam = int32_t(sizeof...(ZEUS_TYPES))-1;
|
||||
zeus::FileServer tmpElem = (*_pointer.*_func)(_obj.getParameter<ZEUS_TYPES>(idParam--)...);
|
||||
#else
|
||||
#error Must be implemented ...
|
||||
jus::FileServer tmpElem;
|
||||
zeus::FileServer tmpElem;
|
||||
return;
|
||||
#endif
|
||||
_interfaceClient->addAsync(SendFile(tmpElem, _transactionId, _clientId));
|
||||
}
|
||||
|
||||
template <class JUS_CLASS_TYPE, class... JUS_TYPES>
|
||||
void executeClassCall(const ememory::SharedPtr<jus::TcpString>& _interfaceClient,
|
||||
template <class ZEUS_CLASS_TYPE, class... ZEUS_TYPES>
|
||||
void executeClassCall(const ememory::SharedPtr<zeus::TcpString>& _interfaceClient,
|
||||
uint64_t _transactionId,
|
||||
uint64_t _clientId,
|
||||
JUS_CLASS_TYPE* _pointer,
|
||||
void (JUS_CLASS_TYPE::*_func)(JUS_TYPES...),
|
||||
jus::Buffer& _obj) {
|
||||
ZEUS_CLASS_TYPE* _pointer,
|
||||
void (ZEUS_CLASS_TYPE::*_func)(ZEUS_TYPES...),
|
||||
zeus::Buffer& _obj) {
|
||||
#if defined(__clang__)
|
||||
// clang generate a basic warning:
|
||||
// warning: multiple unsequenced modifications to 'idParam' [-Wunsequenced]
|
||||
int32_t idParam = 0;
|
||||
(*_pointer.*_func)(_obj.getParameter<JUS_TYPES>(idParam++)...);
|
||||
(*_pointer.*_func)(_obj.getParameter<ZEUS_TYPES>(idParam++)...);
|
||||
#elif defined(__GNUC__) || defined(__GNUG__) || defined(_MSC_VER)
|
||||
int32_t idParam = int32_t(sizeof...(JUS_TYPES))-1;
|
||||
(*_pointer.*_func)(_obj.getParameter<JUS_TYPES>(idParam--)...);
|
||||
int32_t idParam = int32_t(sizeof...(ZEUS_TYPES))-1;
|
||||
(*_pointer.*_func)(_obj.getParameter<ZEUS_TYPES>(idParam--)...);
|
||||
#else
|
||||
#error Must be implemented ...
|
||||
return;
|
||||
@ -151,13 +151,13 @@ namespace jus {
|
||||
});
|
||||
}
|
||||
|
||||
template <class JUS_RETURN, class JUS_CLASS_TYPE, class... JUS_TYPES>
|
||||
class AbstractFunctionTypeClass: public jus::AbstractFunction {
|
||||
template <class ZEUS_RETURN, class ZEUS_CLASS_TYPE, class... ZEUS_TYPES>
|
||||
class AbstractFunctionTypeClass: public zeus::AbstractFunction {
|
||||
protected:
|
||||
static const ParamType m_returnType;
|
||||
static const ParamType m_paramType[sizeof...(JUS_TYPES)];
|
||||
static const ParamType m_paramType[sizeof...(ZEUS_TYPES)];
|
||||
public:
|
||||
using functionType = JUS_RETURN (JUS_CLASS_TYPE::*)(JUS_TYPES...);
|
||||
using functionType = ZEUS_RETURN (ZEUS_CLASS_TYPE::*)(ZEUS_TYPES...);
|
||||
functionType m_function;
|
||||
AbstractFunctionTypeClass(const std::string& _name, const std::string& _desc, functionType _fptr):
|
||||
AbstractFunction(_name, _desc),
|
||||
@ -169,7 +169,7 @@ namespace jus {
|
||||
ret += " ";
|
||||
ret += m_name;
|
||||
ret += "(";
|
||||
for (size_t iii=0; iii<sizeof...(JUS_TYPES); ++iii) {
|
||||
for (size_t iii=0; iii<sizeof...(ZEUS_TYPES); ++iii) {
|
||||
if (iii != 0) {
|
||||
ret += ", ";
|
||||
}
|
||||
@ -183,28 +183,28 @@ namespace jus {
|
||||
}
|
||||
std::vector<std::string> getPrototypeParam() const override {
|
||||
std::vector<std::string> out;
|
||||
for (size_t iii=0; iii<sizeof...(JUS_TYPES); ++iii) {
|
||||
for (size_t iii=0; iii<sizeof...(ZEUS_TYPES); ++iii) {
|
||||
out.push_back(m_paramType[iii].getName());
|
||||
}
|
||||
return out;
|
||||
}
|
||||
void execute(const ememory::SharedPtr<jus::TcpString>& _interfaceClient,
|
||||
void execute(const ememory::SharedPtr<zeus::TcpString>& _interfaceClient,
|
||||
uint64_t _transactionId,
|
||||
uint64_t _clientId,
|
||||
jus::Buffer& _obj,
|
||||
zeus::Buffer& _obj,
|
||||
void* _class) override {
|
||||
JUS_CLASS_TYPE* tmpClass = nullptr;
|
||||
ZEUS_CLASS_TYPE* tmpClass = nullptr;
|
||||
if (_class != nullptr) {
|
||||
tmpClass = (JUS_CLASS_TYPE*)_class;
|
||||
tmpClass = (ZEUS_CLASS_TYPE*)_class;
|
||||
}
|
||||
|
||||
// check parameter number
|
||||
if (_obj.getNumberParameter() != sizeof...(JUS_TYPES)) {
|
||||
JUS_ERROR("Wrong number of Parameters ...");
|
||||
if (_obj.getNumberParameter() != sizeof...(ZEUS_TYPES)) {
|
||||
ZEUS_ERROR("Wrong number of Parameters ...");
|
||||
std::string help = "request ";
|
||||
help += etk::to_string(_obj.getNumberParameter());
|
||||
help += " parameters and need ";
|
||||
help += etk::to_string(sizeof...(JUS_TYPES));
|
||||
help += etk::to_string(sizeof...(ZEUS_TYPES));
|
||||
help += " parameters. prototype function:";
|
||||
help += getPrototype();
|
||||
_interfaceClient->answerError(_transactionId,
|
||||
@ -214,7 +214,7 @@ namespace jus {
|
||||
return;
|
||||
}
|
||||
// check parameter compatibility
|
||||
for (size_t iii=0; iii<sizeof...(JUS_TYPES); ++iii) {
|
||||
for (size_t iii=0; iii<sizeof...(ZEUS_TYPES); ++iii) {
|
||||
if (checkCompatibility(m_paramType[iii], _obj.getParameterType(iii)) == false) {
|
||||
_interfaceClient->answerError(_transactionId,
|
||||
"WRONG-PARAMETER-TYPE",
|
||||
@ -224,20 +224,20 @@ namespace jus {
|
||||
}
|
||||
}
|
||||
// execute cmd:
|
||||
jus::executeClassCall(_interfaceClient, _transactionId, _clientId, tmpClass, m_function, _obj);
|
||||
zeus::executeClassCall(_interfaceClient, _transactionId, _clientId, tmpClass, m_function, _obj);
|
||||
}
|
||||
};
|
||||
|
||||
template <class JUS_RETURN, class JUS_CLASS_TYPE, class... JUS_TYPES>
|
||||
const ParamType AbstractFunctionTypeClass<JUS_RETURN, JUS_CLASS_TYPE, JUS_TYPES...>::m_returnType = createType<JUS_RETURN>();
|
||||
template <class ZEUS_RETURN, class ZEUS_CLASS_TYPE, class... ZEUS_TYPES>
|
||||
const ParamType AbstractFunctionTypeClass<ZEUS_RETURN, ZEUS_CLASS_TYPE, ZEUS_TYPES...>::m_returnType = createType<ZEUS_RETURN>();
|
||||
|
||||
template <class JUS_RETURN, class JUS_CLASS_TYPE, class... JUS_TYPES>
|
||||
const ParamType AbstractFunctionTypeClass<JUS_RETURN, JUS_CLASS_TYPE, JUS_TYPES...>::m_paramType[sizeof...(JUS_TYPES)] = {createType<JUS_TYPES>()...};
|
||||
template <class ZEUS_RETURN, class ZEUS_CLASS_TYPE, class... ZEUS_TYPES>
|
||||
const ParamType AbstractFunctionTypeClass<ZEUS_RETURN, ZEUS_CLASS_TYPE, ZEUS_TYPES...>::m_paramType[sizeof...(ZEUS_TYPES)] = {createType<ZEUS_TYPES>()...};
|
||||
|
||||
|
||||
template <typename JUS_RETURN, class JUS_CLASS_TYPE, typename... JUS_TYPES>
|
||||
AbstractFunction* createAbstractFunctionClass(const std::string& _name, const std::string& _desc, JUS_RETURN (JUS_CLASS_TYPE::*_fffp)(JUS_TYPES...)) {
|
||||
return new AbstractFunctionTypeClass<JUS_RETURN, JUS_CLASS_TYPE, JUS_TYPES...>(_name, _desc, _fffp);
|
||||
template <typename ZEUS_RETURN, class ZEUS_CLASS_TYPE, typename... ZEUS_TYPES>
|
||||
AbstractFunction* createAbstractFunctionClass(const std::string& _name, const std::string& _desc, ZEUS_RETURN (ZEUS_CLASS_TYPE::*_fffp)(ZEUS_TYPES...)) {
|
||||
return new AbstractFunctionTypeClass<ZEUS_RETURN, ZEUS_CLASS_TYPE, ZEUS_TYPES...>(_name, _desc, _fffp);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,25 +5,25 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <jus/TcpString.h>
|
||||
#include <zeus/TcpString.h>
|
||||
#include <eproperty/Value.h>
|
||||
#include <jus/debug.h>
|
||||
#include <jus/AbstractFunction.h>
|
||||
namespace jus {
|
||||
template <class JUS_RETURN, class... JUS_TYPES>
|
||||
void executeCall(const ememory::SharedPtr<jus::TcpString>& _interfaceClient,
|
||||
#include <zeus/debug.h>
|
||||
#include <zeus/AbstractFunction.h>
|
||||
namespace zeus {
|
||||
template <class ZEUS_RETURN, class... ZEUS_TYPES>
|
||||
void executeCall(const ememory::SharedPtr<zeus::TcpString>& _interfaceClient,
|
||||
uint64_t _transactionId,
|
||||
uint64_t _clientId,
|
||||
JUS_RETURN (*_func)(JUS_TYPES...),
|
||||
jus::Buffer& _obj) {
|
||||
ZEUS_RETURN (*_func)(ZEUS_TYPES...),
|
||||
zeus::Buffer& _obj) {
|
||||
#if defined(__clang__)
|
||||
// clang generate a basic warning:
|
||||
// warning: multiple unsequenced modifications to 'idParam' [-Wunsequenced]
|
||||
int32_t idParam = 0;
|
||||
JUS_RETURN ret = _func(_obj.getParameter<JUS_TYPES>(idParam++)...);
|
||||
ZEUS_RETURN ret = _func(_obj.getParameter<ZEUS_TYPES>(idParam++)...);
|
||||
#elif defined(__GNUC__) || defined(__GNUG__) || defined(_MSC_VER)
|
||||
int32_t idParam = int32_t(sizeof...(JUS_TYPES))-1;
|
||||
JUS_RETURN ret = _func(_obj.getParameter<JUS_TYPES>(idParam--)...);
|
||||
int32_t idParam = int32_t(sizeof...(ZEUS_TYPES))-1;
|
||||
ZEUS_RETURN ret = _func(_obj.getParameter<ZEUS_TYPES>(idParam--)...);
|
||||
#else
|
||||
#error Must be implemented ...
|
||||
#endif
|
||||
@ -33,20 +33,20 @@ namespace jus {
|
||||
});
|
||||
}
|
||||
|
||||
template <class... JUS_TYPES>
|
||||
void executeCall(const ememory::SharedPtr<jus::TcpString>& _interfaceClient,
|
||||
template <class... ZEUS_TYPES>
|
||||
void executeCall(const ememory::SharedPtr<zeus::TcpString>& _interfaceClient,
|
||||
uint64_t _transactionId,
|
||||
uint64_t _clientId,
|
||||
void (*_func)(JUS_TYPES...),
|
||||
jus::Buffer& _obj) {
|
||||
void (*_func)(ZEUS_TYPES...),
|
||||
zeus::Buffer& _obj) {
|
||||
#if defined(__clang__)
|
||||
// clang generate a basic warning:
|
||||
// warning: multiple unsequenced modifications to 'idParam' [-Wunsequenced]
|
||||
int32_t idParam = 0;
|
||||
_func(_obj.getParameter<JUS_TYPES>(idParam++)...);
|
||||
_func(_obj.getParameter<ZEUS_TYPES>(idParam++)...);
|
||||
#elif defined(__GNUC__) || defined(__GNUG__) || defined(_MSC_VER)
|
||||
int32_t idParam = int32_t(sizeof...(JUS_TYPES))-1;
|
||||
_func(_obj.getParameter<JUS_TYPES>(idParam--)...);
|
||||
int32_t idParam = int32_t(sizeof...(ZEUS_TYPES))-1;
|
||||
_func(_obj.getParameter<ZEUS_TYPES>(idParam--)...);
|
||||
#else
|
||||
#error Must be implemented ...
|
||||
#endif
|
||||
@ -56,13 +56,13 @@ namespace jus {
|
||||
});
|
||||
}
|
||||
|
||||
template <class JUS_RETURN, class... JUS_TYPES>
|
||||
class AbstractFunctionTypeDirect: public jus::AbstractFunction {
|
||||
template <class ZEUS_RETURN, class... ZEUS_TYPES>
|
||||
class AbstractFunctionTypeDirect: public zeus::AbstractFunction {
|
||||
protected:
|
||||
static const ParamType m_returnType;
|
||||
static const ParamType m_paramType[sizeof...(JUS_TYPES)];
|
||||
static const ParamType m_paramType[sizeof...(ZEUS_TYPES)];
|
||||
public:
|
||||
using functionType = JUS_RETURN (*)(JUS_TYPES...);
|
||||
using functionType = ZEUS_RETURN (*)(ZEUS_TYPES...);
|
||||
functionType m_function;
|
||||
AbstractFunctionTypeDirect(const std::string& _name, const std::string& _desc, functionType _fptr):
|
||||
AbstractFunction(_name, _desc),
|
||||
@ -74,7 +74,7 @@ namespace jus {
|
||||
ret += " ";
|
||||
ret += m_name;
|
||||
ret += "(";
|
||||
for (size_t iii=0; iii<sizeof...(JUS_TYPES); ++iii) {
|
||||
for (size_t iii=0; iii<sizeof...(ZEUS_TYPES); ++iii) {
|
||||
if (iii != 0) {
|
||||
ret += ", ";
|
||||
}
|
||||
@ -88,22 +88,22 @@ namespace jus {
|
||||
}
|
||||
std::vector<std::string> getPrototypeParam() const override {
|
||||
std::vector<std::string> out;
|
||||
for (size_t iii=0; iii<sizeof...(JUS_TYPES); ++iii) {
|
||||
for (size_t iii=0; iii<sizeof...(ZEUS_TYPES); ++iii) {
|
||||
out.push_back(m_paramType[iii].getName());
|
||||
}
|
||||
return out;
|
||||
}
|
||||
void execute(const ememory::SharedPtr<jus::TcpString>& _interfaceClient,
|
||||
void execute(const ememory::SharedPtr<zeus::TcpString>& _interfaceClient,
|
||||
uint64_t _transactionId,
|
||||
uint64_t _clientId,
|
||||
jus::Buffer& _obj,
|
||||
zeus::Buffer& _obj,
|
||||
void* _class) override {
|
||||
// check parameter number
|
||||
if (_obj.getNumberParameter() != sizeof...(JUS_TYPES)) {
|
||||
if (_obj.getNumberParameter() != sizeof...(ZEUS_TYPES)) {
|
||||
std::string help = "request ";
|
||||
help += etk::to_string(_obj.getNumberParameter());
|
||||
help += " parameters and need ";
|
||||
help += etk::to_string(sizeof...(JUS_TYPES));
|
||||
help += etk::to_string(sizeof...(ZEUS_TYPES));
|
||||
help += " parameters. prototype function:";
|
||||
help += getPrototype();
|
||||
_interfaceClient->answerError(_transactionId,
|
||||
@ -113,7 +113,7 @@ namespace jus {
|
||||
return;
|
||||
}
|
||||
// check parameter compatibility
|
||||
for (size_t iii=0; iii<sizeof...(JUS_TYPES); ++iii) {
|
||||
for (size_t iii=0; iii<sizeof...(ZEUS_TYPES); ++iii) {
|
||||
if (checkCompatibility(m_paramType[iii], _obj.getParameterType(iii)) == false) {
|
||||
_interfaceClient->answerError(_transactionId,
|
||||
"WRONG-PARAMETER-TYPE",
|
||||
@ -123,19 +123,19 @@ namespace jus {
|
||||
}
|
||||
}
|
||||
// execute cmd:
|
||||
jus::executeCall(_interfaceClient, _transactionId, _clientId, m_function, _obj);
|
||||
zeus::executeCall(_interfaceClient, _transactionId, _clientId, m_function, _obj);
|
||||
}
|
||||
};
|
||||
|
||||
template <class JUS_RETURN, class... JUS_TYPES>
|
||||
const ParamType AbstractFunctionTypeDirect<JUS_RETURN, JUS_TYPES...>::m_returnType = createType<JUS_RETURN>();
|
||||
template <class ZEUS_RETURN, class... ZEUS_TYPES>
|
||||
const ParamType AbstractFunctionTypeDirect<ZEUS_RETURN, ZEUS_TYPES...>::m_returnType = createType<ZEUS_RETURN>();
|
||||
|
||||
template <class JUS_RETURN, class... JUS_TYPES>
|
||||
const ParamType AbstractFunctionTypeDirect<JUS_RETURN, JUS_TYPES...>::m_paramType[sizeof...(JUS_TYPES)] = {createType<JUS_TYPES>()...};
|
||||
template <class ZEUS_RETURN, class... ZEUS_TYPES>
|
||||
const ParamType AbstractFunctionTypeDirect<ZEUS_RETURN, ZEUS_TYPES...>::m_paramType[sizeof...(ZEUS_TYPES)] = {createType<ZEUS_TYPES>()...};
|
||||
|
||||
|
||||
template <typename JUS_RETURN, typename... JUS_TYPES>
|
||||
AbstractFunction* createAbstractFunctionDirect(const std::string& _name, const std::string& _desc, JUS_RETURN (*_fffp)(JUS_TYPES...)) {
|
||||
return new AbstractFunctionTypeDirect<JUS_RETURN, JUS_TYPES...>(_name, _desc, _fffp);
|
||||
template <typename ZEUS_RETURN, typename... ZEUS_TYPES>
|
||||
AbstractFunction* createAbstractFunctionDirect(const std::string& _name, const std::string& _desc, ZEUS_RETURN (*_fffp)(ZEUS_TYPES...)) {
|
||||
return new AbstractFunctionTypeDirect<ZEUS_RETURN, ZEUS_TYPES...>(_name, _desc, _fffp);
|
||||
}
|
||||
}
|
||||
|
353
zeus/Buffer.cpp
353
zeus/Buffer.cpp
@ -4,57 +4,56 @@
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
#include <etk/types.h>
|
||||
#include <jus/Buffer.h>
|
||||
#include <jus/debug.h>
|
||||
#include <jus/ParamType.h>
|
||||
#include <zeus/Buffer.h>
|
||||
#include <zeus/debug.h>
|
||||
#include <zeus/ParamType.h>
|
||||
#include <etk/stdTools.h>
|
||||
#include <jus/AbstractFunction.h>
|
||||
#include <zeus/AbstractFunction.h>
|
||||
#include <climits>
|
||||
|
||||
namespace etk {
|
||||
template<> std::string to_string<enum jus::Buffer::typeMessage>(const enum jus::Buffer::typeMessage& _value) {
|
||||
template<> std::string to_string<enum zeus::Buffer::typeMessage>(const enum zeus::Buffer::typeMessage& _value) {
|
||||
switch (_value) {
|
||||
case jus::Buffer::typeMessage::call:
|
||||
case zeus::Buffer::typeMessage::call:
|
||||
return "call";
|
||||
case jus::Buffer::typeMessage::answer:
|
||||
case zeus::Buffer::typeMessage::answer:
|
||||
return "answer";
|
||||
case jus::Buffer::typeMessage::event:
|
||||
case zeus::Buffer::typeMessage::event:
|
||||
return "event";
|
||||
case jus::Buffer::typeMessage::data:
|
||||
case zeus::Buffer::typeMessage::data:
|
||||
return "event";
|
||||
}
|
||||
return "???";
|
||||
}
|
||||
}
|
||||
std::ostream& jus::operator <<(std::ostream& _os, enum jus::Buffer::typeMessage _value) {
|
||||
std::ostream& zeus::operator <<(std::ostream& _os, enum zeus::Buffer::typeMessage _value) {
|
||||
_os << etk::to_string(_value);
|
||||
return _os;
|
||||
}
|
||||
|
||||
static enum jus::Buffer::typeMessage getTypeType(uint16_t _value) {
|
||||
static enum zeus::Buffer::typeMessage getTypeType(uint16_t _value) {
|
||||
switch (_value) {
|
||||
case 1:
|
||||
return jus::Buffer::typeMessage::call;
|
||||
return zeus::Buffer::typeMessage::call;
|
||||
case 2:
|
||||
return jus::Buffer::typeMessage::answer;
|
||||
return zeus::Buffer::typeMessage::answer;
|
||||
case 4:
|
||||
return jus::Buffer::typeMessage::event;
|
||||
return zeus::Buffer::typeMessage::event;
|
||||
case 8:
|
||||
return jus::Buffer::typeMessage::data;
|
||||
return zeus::Buffer::typeMessage::data;
|
||||
}
|
||||
return jus::Buffer::typeMessage::call;
|
||||
return zeus::Buffer::typeMessage::call;
|
||||
}
|
||||
|
||||
jus::Buffer::Buffer() {
|
||||
zeus::Buffer::Buffer() {
|
||||
clear();
|
||||
}
|
||||
|
||||
void jus::Buffer::internalComposeWith(const uint8_t* _buffer, uint32_t _lenght) {
|
||||
void zeus::Buffer::internalComposeWith(const uint8_t* _buffer, uint32_t _lenght) {
|
||||
clear();
|
||||
m_header.lenght = _lenght;
|
||||
uint32_t offset = 0;
|
||||
memcpy(reinterpret_cast<char*>(&m_header) + sizeof(uint32_t), &_buffer[offset], sizeof(headerBin)-sizeof(uint32_t));
|
||||
offset += sizeof(headerBin)-sizeof(uint32_t);
|
||||
memcpy(reinterpret_cast<char*>(&m_header), &_buffer[offset], sizeof(headerBin));
|
||||
offset += sizeof(headerBin);
|
||||
if (m_header.numberOfParameter != 0) {
|
||||
m_paramOffset.resize(m_header.numberOfParameter);
|
||||
memcpy(&m_paramOffset[0], &_buffer[offset], m_header.numberOfParameter * sizeof(uint16_t));
|
||||
@ -64,18 +63,17 @@ void jus::Buffer::internalComposeWith(const uint8_t* _buffer, uint32_t _lenght)
|
||||
} else {
|
||||
// TODO : check size ...
|
||||
}
|
||||
JUS_DEBUG("Get binary messages " << generateHumanString());
|
||||
ZEUS_DEBUG("Get binary messages " << generateHumanString());
|
||||
}
|
||||
|
||||
void jus::Buffer::composeWith(const std::vector<uint8_t>& _buffer) {
|
||||
void zeus::Buffer::composeWith(const std::vector<uint8_t>& _buffer) {
|
||||
internalComposeWith(&_buffer[0], _buffer.size());
|
||||
}
|
||||
|
||||
void jus::Buffer::clear() {
|
||||
JUS_VERBOSE("clear buffer");
|
||||
void zeus::Buffer::clear() {
|
||||
ZEUS_VERBOSE("clear buffer");
|
||||
m_data.clear();
|
||||
m_paramOffset.clear();
|
||||
m_header.lenght = 0;
|
||||
m_header.versionProtocol = 1;
|
||||
m_header.transactionID = 1;
|
||||
m_header.clientID = 0;
|
||||
@ -83,22 +81,21 @@ void jus::Buffer::clear() {
|
||||
m_header.typeMessage = 1;
|
||||
m_header.numberOfParameter = 1;
|
||||
}
|
||||
std::string jus::Buffer::generateHumanString() {
|
||||
std::string out = "jus::Buffer Lenght=: ";
|
||||
out += etk::to_string(m_header.lenght);
|
||||
std::string zeus::Buffer::generateHumanString() {
|
||||
std::string out = "zeus::Buffer Lenght=: ";
|
||||
out += " v=" + etk::to_string(m_header.versionProtocol);
|
||||
out += " id=" + etk::to_string(m_header.transactionID);
|
||||
out += " cId=" + etk::to_string(m_header.clientID);
|
||||
out += " pId=" + etk::to_string(getPartId());
|
||||
out += " finish=" + etk::to_string(getPartFinish());
|
||||
enum jus::Buffer::typeMessage type = getTypeType(m_header.typeMessage);
|
||||
enum zeus::Buffer::typeMessage type = getTypeType(m_header.typeMessage);
|
||||
out += " type=" + etk::to_string(type);
|
||||
switch (type) {
|
||||
case jus::Buffer::typeMessage::call:
|
||||
case zeus::Buffer::typeMessage::call:
|
||||
out += " nbParam=" + etk::to_string(getNumberParameter());
|
||||
out += " call='" + getCall() + "'";
|
||||
break;
|
||||
case jus::Buffer::typeMessage::answer:
|
||||
case zeus::Buffer::typeMessage::answer:
|
||||
if (m_paramOffset.size() == 1) {
|
||||
out += " mode=Value";
|
||||
} else if (m_paramOffset.size() == 2) {
|
||||
@ -109,10 +106,10 @@ std::string jus::Buffer::generateHumanString() {
|
||||
out += " mode=???";
|
||||
}
|
||||
break;
|
||||
case jus::Buffer::typeMessage::event:
|
||||
case zeus::Buffer::typeMessage::event:
|
||||
|
||||
break;
|
||||
case jus::Buffer::typeMessage::data:
|
||||
case zeus::Buffer::typeMessage::data:
|
||||
|
||||
break;
|
||||
}
|
||||
@ -129,49 +126,49 @@ std::string jus::Buffer::generateHumanString() {
|
||||
return out;
|
||||
}
|
||||
|
||||
uint16_t jus::Buffer::getProtocalVersion() const {
|
||||
uint16_t zeus::Buffer::getProtocalVersion() const {
|
||||
return m_header.versionProtocol;
|
||||
}
|
||||
|
||||
void jus::Buffer::setProtocolVersion(uint16_t _value) {
|
||||
JUS_VERBOSE("setProtocolVersion :" << _value);
|
||||
void zeus::Buffer::setProtocolVersion(uint16_t _value) {
|
||||
ZEUS_VERBOSE("setProtocolVersion :" << _value);
|
||||
m_header.versionProtocol = _value;
|
||||
}
|
||||
|
||||
uint32_t jus::Buffer::getTransactionId() const {
|
||||
uint32_t zeus::Buffer::getTransactionId() const {
|
||||
return m_header.transactionID;
|
||||
}
|
||||
|
||||
void jus::Buffer::setTransactionId(uint32_t _value) {
|
||||
JUS_VERBOSE("setTransactionId :" << _value);
|
||||
void zeus::Buffer::setTransactionId(uint32_t _value) {
|
||||
ZEUS_VERBOSE("setTransactionId :" << _value);
|
||||
m_header.transactionID = _value;
|
||||
}
|
||||
|
||||
uint32_t jus::Buffer::getClientId() const {
|
||||
uint32_t zeus::Buffer::getClientId() const {
|
||||
return m_header.clientID;
|
||||
}
|
||||
|
||||
void jus::Buffer::setClientId(uint32_t _value) {
|
||||
JUS_VERBOSE("setClientId :" << _value);
|
||||
void zeus::Buffer::setClientId(uint32_t _value) {
|
||||
ZEUS_VERBOSE("setClientId :" << _value);
|
||||
m_header.clientID = _value;
|
||||
}
|
||||
|
||||
// note limited 15 bits
|
||||
uint16_t jus::Buffer::getPartId() const {
|
||||
uint16_t zeus::Buffer::getPartId() const {
|
||||
return uint16_t(m_header.partID & 0x7FFF);
|
||||
}
|
||||
|
||||
void jus::Buffer::setPartId(uint16_t _value) {
|
||||
JUS_VERBOSE("setPartId :" << _value);
|
||||
void zeus::Buffer::setPartId(uint16_t _value) {
|
||||
ZEUS_VERBOSE("setPartId :" << _value);
|
||||
m_header.partID = (m_header.partID&0x8000) | (_value & 0x7FFF);
|
||||
}
|
||||
|
||||
bool jus::Buffer::getPartFinish() const {
|
||||
bool zeus::Buffer::getPartFinish() const {
|
||||
return m_header.partID<0;
|
||||
}
|
||||
|
||||
void jus::Buffer::setPartFinish(bool _value) {
|
||||
JUS_VERBOSE("setPartFinish :" << _value);
|
||||
void zeus::Buffer::setPartFinish(bool _value) {
|
||||
ZEUS_VERBOSE("setPartFinish :" << _value);
|
||||
if (_value == true) {
|
||||
m_header.partID = (m_header.partID & 0x7FFF) | 0x8000;
|
||||
} else {
|
||||
@ -179,35 +176,35 @@ void jus::Buffer::setPartFinish(bool _value) {
|
||||
}
|
||||
}
|
||||
|
||||
enum jus::Buffer::typeMessage jus::Buffer::getType() const {
|
||||
return (enum jus::Buffer::typeMessage)m_header.typeMessage;
|
||||
enum zeus::Buffer::typeMessage zeus::Buffer::getType() const {
|
||||
return (enum zeus::Buffer::typeMessage)m_header.typeMessage;
|
||||
}
|
||||
|
||||
void jus::Buffer::setType(enum typeMessage _value) {
|
||||
JUS_VERBOSE("setType :" << _value);
|
||||
void zeus::Buffer::setType(enum typeMessage _value) {
|
||||
ZEUS_VERBOSE("setType :" << _value);
|
||||
m_header.typeMessage = uint16_t(_value);
|
||||
}
|
||||
|
||||
uint16_t jus::Buffer::getNumberParameter() const {
|
||||
uint16_t zeus::Buffer::getNumberParameter() const {
|
||||
return m_paramOffset.size()-1;
|
||||
}
|
||||
std::string jus::Buffer::internalGetParameterType(int32_t _id) const {
|
||||
std::string zeus::Buffer::internalGetParameterType(int32_t _id) const {
|
||||
std::string out;
|
||||
if (m_paramOffset.size() <= _id) {
|
||||
JUS_ERROR("out of range Id for parameter ... " << _id << " have " << m_paramOffset.size());
|
||||
ZEUS_ERROR("out of range Id for parameter ... " << _id << " have " << m_paramOffset.size());
|
||||
return out;
|
||||
}
|
||||
out = reinterpret_cast<const char*>(&m_data[m_paramOffset[_id]]);
|
||||
return out;
|
||||
}
|
||||
std::string jus::Buffer::getParameterType(int32_t _id) const {
|
||||
std::string zeus::Buffer::getParameterType(int32_t _id) const {
|
||||
return internalGetParameterType(_id + 1);
|
||||
}
|
||||
|
||||
const uint8_t* jus::Buffer::internalGetParameterPointer(int32_t _id) const {
|
||||
const uint8_t* zeus::Buffer::internalGetParameterPointer(int32_t _id) const {
|
||||
const uint8_t* out = nullptr;
|
||||
if (m_paramOffset.size() <= _id) {
|
||||
JUS_ERROR("out of range Id for parameter ... " << _id << " have " << m_paramOffset.size());
|
||||
ZEUS_ERROR("out of range Id for parameter ... " << _id << " have " << m_paramOffset.size());
|
||||
return out;
|
||||
}
|
||||
out = reinterpret_cast<const uint8_t*>(&m_data[m_paramOffset[_id]]);
|
||||
@ -222,14 +219,14 @@ const uint8_t* jus::Buffer::internalGetParameterPointer(int32_t _id) const {
|
||||
return out;
|
||||
}
|
||||
|
||||
const uint8_t* jus::Buffer::getParameterPointer(int32_t _id) const {
|
||||
const uint8_t* zeus::Buffer::getParameterPointer(int32_t _id) const {
|
||||
return internalGetParameterPointer(_id + 1);
|
||||
}
|
||||
|
||||
uint32_t jus::Buffer::internalGetParameterSize(int32_t _id) const {
|
||||
uint32_t zeus::Buffer::internalGetParameterSize(int32_t _id) const {
|
||||
int32_t out = 0;
|
||||
if (m_paramOffset.size() <= _id) {
|
||||
JUS_ERROR("out of range Id for parameter ... " << _id << " have " << m_paramOffset.size());
|
||||
ZEUS_ERROR("out of range Id for parameter ... " << _id << " have " << m_paramOffset.size());
|
||||
return out;
|
||||
}
|
||||
int32_t startPos = m_paramOffset[_id];
|
||||
@ -245,7 +242,7 @@ uint32_t jus::Buffer::internalGetParameterSize(int32_t _id) const {
|
||||
out = endPos - startPos;
|
||||
out --;
|
||||
if (out < 0) {
|
||||
JUS_ERROR("Get size < 0 : " << out);
|
||||
ZEUS_ERROR("Get size < 0 : " << out);
|
||||
out = 0;
|
||||
}
|
||||
return out;
|
||||
@ -253,19 +250,19 @@ uint32_t jus::Buffer::internalGetParameterSize(int32_t _id) const {
|
||||
|
||||
|
||||
|
||||
void jus::Buffer::addData(void* _data, uint32_t _size) {
|
||||
void zeus::Buffer::addData(void* _data, uint32_t _size) {
|
||||
m_paramOffset.clear();
|
||||
setType(jus::Buffer::typeMessage::data);
|
||||
setType(zeus::Buffer::typeMessage::data);
|
||||
m_data.resize(_size);
|
||||
memcpy(&m_data[0], _data, _size);
|
||||
}
|
||||
|
||||
|
||||
uint32_t jus::Buffer::getParameterSize(int32_t _id) const {
|
||||
uint32_t zeus::Buffer::getParameterSize(int32_t _id) const {
|
||||
return internalGetParameterSize(_id + 1);
|
||||
}
|
||||
|
||||
void jus::Buffer::addParameter() {
|
||||
void zeus::Buffer::addParameter() {
|
||||
int32_t currentOffset = m_data.size();
|
||||
m_paramOffset.push_back(currentOffset);
|
||||
m_data.push_back('v');
|
||||
@ -274,7 +271,7 @@ void jus::Buffer::addParameter() {
|
||||
m_data.push_back('d');
|
||||
m_data.push_back('\0');
|
||||
}
|
||||
void jus::Buffer::addParameterEmptyVector() {
|
||||
void zeus::Buffer::addParameterEmptyVector() {
|
||||
int32_t currentOffset = m_data.size();
|
||||
m_paramOffset.push_back(currentOffset);
|
||||
m_data.push_back('v');
|
||||
@ -292,7 +289,7 @@ void jus::Buffer::addParameterEmptyVector() {
|
||||
m_data.push_back('\0');
|
||||
}
|
||||
template<>
|
||||
void jus::Buffer::addParameter<std::string>(const std::string& _value) {
|
||||
void zeus::Buffer::addParameter<std::string>(const std::string& _value) {
|
||||
int32_t currentOffset = m_data.size();
|
||||
m_paramOffset.push_back(currentOffset);
|
||||
m_data.push_back('s');
|
||||
@ -307,7 +304,7 @@ void jus::Buffer::addParameter<std::string>(const std::string& _value) {
|
||||
memcpy(&m_data[currentOffset], &_value[0], _value.size());
|
||||
}
|
||||
template<>
|
||||
void jus::Buffer::addParameter<std::vector<std::string>>(const std::vector<std::string>& _value) {
|
||||
void zeus::Buffer::addParameter<std::vector<std::string>>(const std::vector<std::string>& _value) {
|
||||
int32_t currentOffset = m_data.size();
|
||||
m_paramOffset.push_back(currentOffset);
|
||||
m_data.push_back('v');
|
||||
@ -343,7 +340,7 @@ void jus::Buffer::addParameter<std::vector<std::string>>(const std::vector<std::
|
||||
}
|
||||
|
||||
template<>
|
||||
void jus::Buffer::addParameter<std::vector<bool>>(const std::vector<bool>& _value) {
|
||||
void zeus::Buffer::addParameter<std::vector<bool>>(const std::vector<bool>& _value) {
|
||||
int32_t currentOffset = m_data.size();
|
||||
m_paramOffset.push_back(currentOffset);
|
||||
m_data.push_back('v');
|
||||
@ -373,7 +370,7 @@ void jus::Buffer::addParameter<std::vector<bool>>(const std::vector<bool>& _valu
|
||||
}
|
||||
|
||||
template<>
|
||||
void jus::Buffer::addParameter<std::vector<int8_t>>(const std::vector<int8_t>& _value) {
|
||||
void zeus::Buffer::addParameter<std::vector<int8_t>>(const std::vector<int8_t>& _value) {
|
||||
int32_t currentOffset = m_data.size();
|
||||
m_paramOffset.push_back(currentOffset);
|
||||
m_data.push_back('v');
|
||||
@ -394,7 +391,7 @@ void jus::Buffer::addParameter<std::vector<int8_t>>(const std::vector<int8_t>& _
|
||||
memcpy(&m_data[currentOffset], &_value[0], sizeof(int8_t)*_value.size());
|
||||
}
|
||||
template<>
|
||||
void jus::Buffer::addParameter<std::vector<int16_t>>(const std::vector<int16_t>& _value) {
|
||||
void zeus::Buffer::addParameter<std::vector<int16_t>>(const std::vector<int16_t>& _value) {
|
||||
int32_t currentOffset = m_data.size();
|
||||
m_paramOffset.push_back(currentOffset);
|
||||
m_data.push_back('v');
|
||||
@ -416,7 +413,7 @@ void jus::Buffer::addParameter<std::vector<int16_t>>(const std::vector<int16_t>&
|
||||
memcpy(&m_data[currentOffset], &_value[0], sizeof(int16_t)*_value.size());
|
||||
}
|
||||
template<>
|
||||
void jus::Buffer::addParameter<std::vector<int32_t>>(const std::vector<int32_t>& _value) {
|
||||
void zeus::Buffer::addParameter<std::vector<int32_t>>(const std::vector<int32_t>& _value) {
|
||||
int32_t currentOffset = m_data.size();
|
||||
m_paramOffset.push_back(currentOffset);
|
||||
m_data.push_back('v');
|
||||
@ -438,7 +435,7 @@ void jus::Buffer::addParameter<std::vector<int32_t>>(const std::vector<int32_t>&
|
||||
memcpy(&m_data[currentOffset], &_value[0], sizeof(int32_t)*_value.size());
|
||||
}
|
||||
template<>
|
||||
void jus::Buffer::addParameter<std::vector<int64_t>>(const std::vector<int64_t>& _value) {
|
||||
void zeus::Buffer::addParameter<std::vector<int64_t>>(const std::vector<int64_t>& _value) {
|
||||
int32_t currentOffset = m_data.size();
|
||||
m_paramOffset.push_back(currentOffset);
|
||||
m_data.push_back('v');
|
||||
@ -461,7 +458,7 @@ void jus::Buffer::addParameter<std::vector<int64_t>>(const std::vector<int64_t>&
|
||||
}
|
||||
|
||||
template<>
|
||||
void jus::Buffer::addParameter<std::vector<uint8_t>>(const std::vector<uint8_t>& _value) {
|
||||
void zeus::Buffer::addParameter<std::vector<uint8_t>>(const std::vector<uint8_t>& _value) {
|
||||
int32_t currentOffset = m_data.size();
|
||||
m_paramOffset.push_back(currentOffset);
|
||||
m_data.push_back('v');
|
||||
@ -483,7 +480,7 @@ void jus::Buffer::addParameter<std::vector<uint8_t>>(const std::vector<uint8_t>&
|
||||
memcpy(&m_data[currentOffset], &_value[0], sizeof(uint8_t)*_value.size());
|
||||
}
|
||||
template<>
|
||||
void jus::Buffer::addParameter<std::vector<uint16_t>>(const std::vector<uint16_t>& _value) {
|
||||
void zeus::Buffer::addParameter<std::vector<uint16_t>>(const std::vector<uint16_t>& _value) {
|
||||
int32_t currentOffset = m_data.size();
|
||||
m_paramOffset.push_back(currentOffset);
|
||||
m_data.push_back('v');
|
||||
@ -506,7 +503,7 @@ void jus::Buffer::addParameter<std::vector<uint16_t>>(const std::vector<uint16_t
|
||||
memcpy(&m_data[currentOffset], &_value[0], sizeof(uint16_t)*_value.size());
|
||||
}
|
||||
template<>
|
||||
void jus::Buffer::addParameter<std::vector<uint32_t>>(const std::vector<uint32_t>& _value) {
|
||||
void zeus::Buffer::addParameter<std::vector<uint32_t>>(const std::vector<uint32_t>& _value) {
|
||||
int32_t currentOffset = m_data.size();
|
||||
m_paramOffset.push_back(currentOffset);
|
||||
m_data.push_back('v');
|
||||
@ -529,7 +526,7 @@ void jus::Buffer::addParameter<std::vector<uint32_t>>(const std::vector<uint32_t
|
||||
memcpy(&m_data[currentOffset], &_value[0], sizeof(uint32_t)*_value.size());
|
||||
}
|
||||
template<>
|
||||
void jus::Buffer::addParameter<std::vector<uint64_t>>(const std::vector<uint64_t>& _value) {
|
||||
void zeus::Buffer::addParameter<std::vector<uint64_t>>(const std::vector<uint64_t>& _value) {
|
||||
int32_t currentOffset = m_data.size();
|
||||
m_paramOffset.push_back(currentOffset);
|
||||
m_data.push_back('v');
|
||||
@ -553,7 +550,7 @@ void jus::Buffer::addParameter<std::vector<uint64_t>>(const std::vector<uint64_t
|
||||
}
|
||||
|
||||
template<>
|
||||
void jus::Buffer::addParameter<std::vector<float>>(const std::vector<float>& _value) {
|
||||
void zeus::Buffer::addParameter<std::vector<float>>(const std::vector<float>& _value) {
|
||||
int32_t currentOffset = m_data.size();
|
||||
m_paramOffset.push_back(currentOffset);
|
||||
m_data.push_back('v');
|
||||
@ -576,7 +573,7 @@ void jus::Buffer::addParameter<std::vector<float>>(const std::vector<float>& _va
|
||||
}
|
||||
|
||||
template<>
|
||||
void jus::Buffer::addParameter<std::vector<double>>(const std::vector<double>& _value) {
|
||||
void zeus::Buffer::addParameter<std::vector<double>>(const std::vector<double>& _value) {
|
||||
int32_t currentOffset = m_data.size();
|
||||
m_paramOffset.push_back(currentOffset);
|
||||
m_data.push_back('v');
|
||||
@ -600,7 +597,7 @@ void jus::Buffer::addParameter<std::vector<double>>(const std::vector<double>& _
|
||||
}
|
||||
|
||||
template<>
|
||||
void jus::Buffer::addParameter<int8_t>(const int8_t& _value) {
|
||||
void zeus::Buffer::addParameter<int8_t>(const int8_t& _value) {
|
||||
int32_t currentOffset = m_data.size();
|
||||
m_paramOffset.push_back(currentOffset);
|
||||
m_data.push_back('i');
|
||||
@ -611,7 +608,7 @@ void jus::Buffer::addParameter<int8_t>(const int8_t& _value) {
|
||||
m_data.push_back(uint8_t(_value));
|
||||
}
|
||||
template<>
|
||||
void jus::Buffer::addParameter<uint8_t>(const uint8_t& _value) {
|
||||
void zeus::Buffer::addParameter<uint8_t>(const uint8_t& _value) {
|
||||
int32_t currentOffset = m_data.size();
|
||||
m_paramOffset.push_back(currentOffset);
|
||||
m_data.push_back('u');
|
||||
@ -623,7 +620,7 @@ void jus::Buffer::addParameter<uint8_t>(const uint8_t& _value) {
|
||||
m_data.push_back(_value);
|
||||
}
|
||||
template<>
|
||||
void jus::Buffer::addParameter<int16_t>(const int16_t& _value) {
|
||||
void zeus::Buffer::addParameter<int16_t>(const int16_t& _value) {
|
||||
int32_t currentOffset = m_data.size();
|
||||
m_paramOffset.push_back(currentOffset);
|
||||
m_data.push_back('i');
|
||||
@ -637,7 +634,7 @@ void jus::Buffer::addParameter<int16_t>(const int16_t& _value) {
|
||||
memcpy(&m_data[currentOffset], &_value, 2);
|
||||
}
|
||||
template<>
|
||||
void jus::Buffer::addParameter<uint16_t>(const uint16_t& _value) {
|
||||
void zeus::Buffer::addParameter<uint16_t>(const uint16_t& _value) {
|
||||
int32_t currentOffset = m_data.size();
|
||||
m_paramOffset.push_back(currentOffset);
|
||||
m_data.push_back('u');
|
||||
@ -652,7 +649,7 @@ void jus::Buffer::addParameter<uint16_t>(const uint16_t& _value) {
|
||||
memcpy(&m_data[currentOffset], &_value, 2);
|
||||
}
|
||||
template<>
|
||||
void jus::Buffer::addParameter<int32_t>(const int32_t& _value) {
|
||||
void zeus::Buffer::addParameter<int32_t>(const int32_t& _value) {
|
||||
int32_t currentOffset = m_data.size();
|
||||
m_paramOffset.push_back(currentOffset);
|
||||
m_data.push_back('i');
|
||||
@ -666,7 +663,7 @@ void jus::Buffer::addParameter<int32_t>(const int32_t& _value) {
|
||||
memcpy(&m_data[currentOffset], &_value, 4);
|
||||
}
|
||||
template<>
|
||||
void jus::Buffer::addParameter<uint32_t>(const uint32_t& _value) {
|
||||
void zeus::Buffer::addParameter<uint32_t>(const uint32_t& _value) {
|
||||
int32_t currentOffset = m_data.size();
|
||||
m_paramOffset.push_back(currentOffset);
|
||||
m_data.push_back('u');
|
||||
@ -681,7 +678,7 @@ void jus::Buffer::addParameter<uint32_t>(const uint32_t& _value) {
|
||||
memcpy(&m_data[currentOffset], &_value, 4);
|
||||
}
|
||||
template<>
|
||||
void jus::Buffer::addParameter<int64_t>(const int64_t& _value) {
|
||||
void zeus::Buffer::addParameter<int64_t>(const int64_t& _value) {
|
||||
int32_t currentOffset = m_data.size();
|
||||
m_paramOffset.push_back(currentOffset);
|
||||
m_data.push_back('i');
|
||||
@ -695,7 +692,7 @@ void jus::Buffer::addParameter<int64_t>(const int64_t& _value) {
|
||||
memcpy(&m_data[currentOffset], &_value, 8);
|
||||
}
|
||||
template<>
|
||||
void jus::Buffer::addParameter<uint64_t>(const uint64_t& _value) {
|
||||
void zeus::Buffer::addParameter<uint64_t>(const uint64_t& _value) {
|
||||
int32_t currentOffset = m_data.size();
|
||||
m_paramOffset.push_back(currentOffset);
|
||||
m_data.push_back('u');
|
||||
@ -710,7 +707,7 @@ void jus::Buffer::addParameter<uint64_t>(const uint64_t& _value) {
|
||||
memcpy(&m_data[currentOffset], &_value, 8);
|
||||
}
|
||||
template<>
|
||||
void jus::Buffer::addParameter<float>(const float& _value) {
|
||||
void zeus::Buffer::addParameter<float>(const float& _value) {
|
||||
int32_t currentOffset = m_data.size();
|
||||
m_paramOffset.push_back(currentOffset);
|
||||
m_data.push_back('f');
|
||||
@ -724,7 +721,7 @@ void jus::Buffer::addParameter<float>(const float& _value) {
|
||||
memcpy(&m_data[currentOffset], &_value, 4);
|
||||
}
|
||||
template<>
|
||||
void jus::Buffer::addParameter<double>(const double& _value) {
|
||||
void zeus::Buffer::addParameter<double>(const double& _value) {
|
||||
int32_t currentOffset = m_data.size();
|
||||
m_paramOffset.push_back(currentOffset);
|
||||
m_data.push_back('d');
|
||||
@ -739,7 +736,7 @@ void jus::Buffer::addParameter<double>(const double& _value) {
|
||||
memcpy(&m_data[currentOffset], &_value, 8);
|
||||
}
|
||||
template<>
|
||||
void jus::Buffer::addParameter<bool>(const bool& _value) {
|
||||
void zeus::Buffer::addParameter<bool>(const bool& _value) {
|
||||
int32_t currentOffset = m_data.size();
|
||||
m_paramOffset.push_back(currentOffset);
|
||||
m_data.push_back('b');
|
||||
@ -754,9 +751,20 @@ void jus::Buffer::addParameter<bool>(const bool& _value) {
|
||||
}
|
||||
}
|
||||
|
||||
template<>
|
||||
void zeus::Buffer::addParameter<zeus::File>(const zeus::File& _value) {
|
||||
int32_t currentOffset = m_data.size();
|
||||
m_paramOffset.push_back(currentOffset);
|
||||
m_data.push_back('f');
|
||||
m_data.push_back('i');
|
||||
m_data.push_back('l');
|
||||
m_data.push_back('e');
|
||||
m_data.push_back('\0');
|
||||
ZEUS_TODO("Send file in output ...");
|
||||
}
|
||||
|
||||
template<>
|
||||
bool jus::Buffer::internalGetParameter<bool>(int32_t _id) const {
|
||||
bool zeus::Buffer::internalGetParameter<bool>(int32_t _id) const {
|
||||
std::string type = internalGetParameterType(_id);
|
||||
const uint8_t* pointer = internalGetParameterPointer(_id);
|
||||
uint32_t dataSize = internalGetParameterSize(_id);
|
||||
@ -773,7 +781,7 @@ bool jus::Buffer::internalGetParameter<bool>(int32_t _id) const {
|
||||
}
|
||||
|
||||
template<>
|
||||
std::string jus::Buffer::internalGetParameter<std::string>(int32_t _id) const {
|
||||
std::string zeus::Buffer::internalGetParameter<std::string>(int32_t _id) const {
|
||||
std::string out;
|
||||
std::string type = internalGetParameterType(_id);
|
||||
const uint8_t* pointer = internalGetParameterPointer(_id);
|
||||
@ -785,7 +793,7 @@ std::string jus::Buffer::internalGetParameter<std::string>(int32_t _id) const {
|
||||
|
||||
|
||||
template<>
|
||||
uint8_t jus::Buffer::internalGetParameter<uint8_t>(int32_t _id) const {
|
||||
uint8_t zeus::Buffer::internalGetParameter<uint8_t>(int32_t _id) const {
|
||||
std::string type = internalGetParameterType(_id);
|
||||
const uint8_t* pointer = internalGetParameterPointer(_id);
|
||||
uint32_t dataSize = internalGetParameterSize(_id);
|
||||
@ -821,11 +829,11 @@ uint8_t jus::Buffer::internalGetParameter<uint8_t>(int32_t _id) const {
|
||||
const double* tmp = reinterpret_cast<const double*>(pointer);
|
||||
return uint8_t(etk::avg(double(0), *tmp, double(UCHAR_MAX)));
|
||||
}
|
||||
JUS_ERROR("Can not get type from '" << type << "'");
|
||||
ZEUS_ERROR("Can not get type from '" << type << "'");
|
||||
return 0;
|
||||
}
|
||||
template<>
|
||||
uint16_t jus::Buffer::internalGetParameter<uint16_t>(int32_t _id) const {
|
||||
uint16_t zeus::Buffer::internalGetParameter<uint16_t>(int32_t _id) const {
|
||||
std::string type = internalGetParameterType(_id);
|
||||
const uint8_t* pointer = internalGetParameterPointer(_id);
|
||||
uint32_t dataSize = internalGetParameterSize(_id);
|
||||
@ -861,12 +869,12 @@ uint16_t jus::Buffer::internalGetParameter<uint16_t>(int32_t _id) const {
|
||||
const double* tmp = reinterpret_cast<const double*>(pointer);
|
||||
return uint16_t(etk::avg(double(0), *tmp, double(USHRT_MAX)));
|
||||
}
|
||||
JUS_ERROR("Can not get type from '" << type << "'");
|
||||
ZEUS_ERROR("Can not get type from '" << type << "'");
|
||||
return 0;
|
||||
}
|
||||
|
||||
template<>
|
||||
uint32_t jus::Buffer::internalGetParameter<uint32_t>(int32_t _id) const {
|
||||
uint32_t zeus::Buffer::internalGetParameter<uint32_t>(int32_t _id) const {
|
||||
std::string type = internalGetParameterType(_id);
|
||||
const uint8_t* pointer = internalGetParameterPointer(_id);
|
||||
uint32_t dataSize = internalGetParameterSize(_id);
|
||||
@ -902,12 +910,12 @@ uint32_t jus::Buffer::internalGetParameter<uint32_t>(int32_t _id) const {
|
||||
const double* tmp = reinterpret_cast<const double*>(pointer);
|
||||
return uint32_t(etk::avg(double(0), *tmp, double(ULONG_MAX)));
|
||||
}
|
||||
JUS_ERROR("Can not get type from '" << type << "'");
|
||||
ZEUS_ERROR("Can not get type from '" << type << "'");
|
||||
return 0;
|
||||
}
|
||||
|
||||
template<>
|
||||
uint64_t jus::Buffer::internalGetParameter<uint64_t>(int32_t _id) const {
|
||||
uint64_t zeus::Buffer::internalGetParameter<uint64_t>(int32_t _id) const {
|
||||
std::string type = internalGetParameterType(_id);
|
||||
const uint8_t* pointer = internalGetParameterPointer(_id);
|
||||
uint32_t dataSize = internalGetParameterSize(_id);
|
||||
@ -943,12 +951,12 @@ uint64_t jus::Buffer::internalGetParameter<uint64_t>(int32_t _id) const {
|
||||
const double* tmp = reinterpret_cast<const double*>(pointer);
|
||||
return uint64_t(etk::avg(double(0), *tmp, double(ULONG_MAX)));
|
||||
}
|
||||
JUS_ERROR("Can not get type from '" << type << "'");
|
||||
ZEUS_ERROR("Can not get type from '" << type << "'");
|
||||
return 0;
|
||||
}
|
||||
|
||||
template<>
|
||||
int8_t jus::Buffer::internalGetParameter<int8_t>(int32_t _id) const {
|
||||
int8_t zeus::Buffer::internalGetParameter<int8_t>(int32_t _id) const {
|
||||
std::string type = internalGetParameterType(_id);
|
||||
const uint8_t* pointer = internalGetParameterPointer(_id);
|
||||
uint32_t dataSize = internalGetParameterSize(_id);
|
||||
@ -984,12 +992,12 @@ int8_t jus::Buffer::internalGetParameter<int8_t>(int32_t _id) const {
|
||||
const double* tmp = reinterpret_cast<const double*>(pointer);
|
||||
return int8_t(etk::avg(double(SCHAR_MIN), *tmp, double(SCHAR_MAX)));
|
||||
}
|
||||
JUS_ERROR("Can not get type from '" << type << "'");
|
||||
ZEUS_ERROR("Can not get type from '" << type << "'");
|
||||
return 0;
|
||||
}
|
||||
|
||||
template<>
|
||||
int16_t jus::Buffer::internalGetParameter<int16_t>(int32_t _id) const {
|
||||
int16_t zeus::Buffer::internalGetParameter<int16_t>(int32_t _id) const {
|
||||
std::string type = internalGetParameterType(_id);
|
||||
const uint8_t* pointer = internalGetParameterPointer(_id);
|
||||
uint32_t dataSize = internalGetParameterSize(_id);
|
||||
@ -1025,12 +1033,12 @@ int16_t jus::Buffer::internalGetParameter<int16_t>(int32_t _id) const {
|
||||
const double* tmp = reinterpret_cast<const double*>(pointer);
|
||||
return int16_t(etk::avg(double(SHRT_MIN), *tmp, double(SHRT_MAX)));
|
||||
}
|
||||
JUS_ERROR("Can not get type from '" << type << "'");
|
||||
ZEUS_ERROR("Can not get type from '" << type << "'");
|
||||
return 0;
|
||||
}
|
||||
|
||||
template<>
|
||||
int32_t jus::Buffer::internalGetParameter<int32_t>(int32_t _id) const {
|
||||
int32_t zeus::Buffer::internalGetParameter<int32_t>(int32_t _id) const {
|
||||
std::string type = internalGetParameterType(_id);
|
||||
const uint8_t* pointer = internalGetParameterPointer(_id);
|
||||
uint32_t dataSize = internalGetParameterSize(_id);
|
||||
@ -1066,12 +1074,12 @@ int32_t jus::Buffer::internalGetParameter<int32_t>(int32_t _id) const {
|
||||
const double* tmp = reinterpret_cast<const double*>(pointer);
|
||||
return int32_t(etk::avg(double(LONG_MIN), *tmp, double(LONG_MAX)));
|
||||
}
|
||||
JUS_ERROR("Can not get type from '" << type << "'");
|
||||
ZEUS_ERROR("Can not get type from '" << type << "'");
|
||||
return 0;
|
||||
}
|
||||
|
||||
template<>
|
||||
int64_t jus::Buffer::internalGetParameter<int64_t>(int32_t _id) const {
|
||||
int64_t zeus::Buffer::internalGetParameter<int64_t>(int32_t _id) const {
|
||||
std::string type = internalGetParameterType(_id);
|
||||
const uint8_t* pointer = internalGetParameterPointer(_id);
|
||||
uint32_t dataSize = internalGetParameterSize(_id);
|
||||
@ -1107,12 +1115,12 @@ int64_t jus::Buffer::internalGetParameter<int64_t>(int32_t _id) const {
|
||||
const double* tmp = reinterpret_cast<const double*>(pointer);
|
||||
return int64_t(etk::avg(double(LLONG_MIN), *tmp, double(LLONG_MAX)));
|
||||
}
|
||||
JUS_ERROR("Can not get type from '" << type << "'");
|
||||
ZEUS_ERROR("Can not get type from '" << type << "'");
|
||||
return 0;
|
||||
}
|
||||
|
||||
template<>
|
||||
float jus::Buffer::internalGetParameter<float>(int32_t _id) const {
|
||||
float zeus::Buffer::internalGetParameter<float>(int32_t _id) const {
|
||||
std::string type = internalGetParameterType(_id);
|
||||
const uint8_t* pointer = internalGetParameterPointer(_id);
|
||||
uint32_t dataSize = internalGetParameterSize(_id);
|
||||
@ -1148,11 +1156,11 @@ float jus::Buffer::internalGetParameter<float>(int32_t _id) const {
|
||||
const double* tmp = reinterpret_cast<const double*>(pointer);
|
||||
return *tmp;
|
||||
}
|
||||
JUS_ERROR("Can not get type from '" << type << "'");
|
||||
ZEUS_ERROR("Can not get type from '" << type << "'");
|
||||
return 0.0f;
|
||||
}
|
||||
template<>
|
||||
double jus::Buffer::internalGetParameter<double>(int32_t _id) const {
|
||||
double zeus::Buffer::internalGetParameter<double>(int32_t _id) const {
|
||||
std::string type = internalGetParameterType(_id);
|
||||
const uint8_t* pointer = internalGetParameterPointer(_id);
|
||||
uint32_t dataSize = internalGetParameterSize(_id);
|
||||
@ -1188,7 +1196,7 @@ double jus::Buffer::internalGetParameter<double>(int32_t _id) const {
|
||||
const double* tmp = reinterpret_cast<const double*>(pointer);
|
||||
return *tmp;
|
||||
}
|
||||
JUS_ERROR("Can not get type from '" << type << "'");
|
||||
ZEUS_ERROR("Can not get type from '" << type << "'");
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
@ -1216,7 +1224,7 @@ double jus::Buffer::internalGetParameter<double>(int32_t _id) const {
|
||||
|
||||
|
||||
template<>
|
||||
std::vector<uint8_t> jus::Buffer::internalGetParameter<std::vector<uint8_t>>(int32_t _id) const {
|
||||
std::vector<uint8_t> zeus::Buffer::internalGetParameter<std::vector<uint8_t>>(int32_t _id) const {
|
||||
std::vector<uint8_t> out;
|
||||
std::string type = internalGetParameterType(_id);
|
||||
const uint8_t* pointer = internalGetParameterPointer(_id);
|
||||
@ -1302,11 +1310,11 @@ std::vector<uint8_t> jus::Buffer::internalGetParameter<std::vector<uint8_t>>(int
|
||||
}
|
||||
return out;
|
||||
}
|
||||
JUS_ERROR("Can not get type from '" << type << "'");
|
||||
ZEUS_ERROR("Can not get type from '" << type << "'");
|
||||
return out;
|
||||
}
|
||||
template<>
|
||||
std::vector<uint16_t> jus::Buffer::internalGetParameter<std::vector<uint16_t>>(int32_t _id) const {
|
||||
std::vector<uint16_t> zeus::Buffer::internalGetParameter<std::vector<uint16_t>>(int32_t _id) const {
|
||||
std::vector<uint16_t> out;
|
||||
std::string type = internalGetParameterType(_id);
|
||||
const uint8_t* pointer = internalGetParameterPointer(_id);
|
||||
@ -1392,12 +1400,12 @@ std::vector<uint16_t> jus::Buffer::internalGetParameter<std::vector<uint16_t>>(i
|
||||
}
|
||||
return out;
|
||||
}
|
||||
JUS_ERROR("Can not get type from '" << type << "'");
|
||||
ZEUS_ERROR("Can not get type from '" << type << "'");
|
||||
return out;
|
||||
}
|
||||
|
||||
template<>
|
||||
std::vector<uint32_t> jus::Buffer::internalGetParameter<std::vector<uint32_t>>(int32_t _id) const {
|
||||
std::vector<uint32_t> zeus::Buffer::internalGetParameter<std::vector<uint32_t>>(int32_t _id) const {
|
||||
std::vector<uint32_t> out;
|
||||
std::string type = internalGetParameterType(_id);
|
||||
const uint8_t* pointer = internalGetParameterPointer(_id);
|
||||
@ -1483,12 +1491,12 @@ std::vector<uint32_t> jus::Buffer::internalGetParameter<std::vector<uint32_t>>(i
|
||||
}
|
||||
return out;
|
||||
}
|
||||
JUS_ERROR("Can not get type from '" << type << "'");
|
||||
ZEUS_ERROR("Can not get type from '" << type << "'");
|
||||
return out;
|
||||
}
|
||||
|
||||
template<>
|
||||
std::vector<uint64_t> jus::Buffer::internalGetParameter<std::vector<uint64_t>>(int32_t _id) const {
|
||||
std::vector<uint64_t> zeus::Buffer::internalGetParameter<std::vector<uint64_t>>(int32_t _id) const {
|
||||
std::vector<uint64_t> out;
|
||||
std::string type = internalGetParameterType(_id);
|
||||
const uint8_t* pointer = internalGetParameterPointer(_id);
|
||||
@ -1574,12 +1582,12 @@ std::vector<uint64_t> jus::Buffer::internalGetParameter<std::vector<uint64_t>>(i
|
||||
}
|
||||
return out;
|
||||
}
|
||||
JUS_ERROR("Can not get type from '" << type << "'");
|
||||
ZEUS_ERROR("Can not get type from '" << type << "'");
|
||||
return out;
|
||||
}
|
||||
|
||||
template<>
|
||||
std::vector<int8_t> jus::Buffer::internalGetParameter<std::vector<int8_t>>(int32_t _id) const {
|
||||
std::vector<int8_t> zeus::Buffer::internalGetParameter<std::vector<int8_t>>(int32_t _id) const {
|
||||
std::vector<int8_t> out;
|
||||
std::string type = internalGetParameterType(_id);
|
||||
const uint8_t* pointer = internalGetParameterPointer(_id);
|
||||
@ -1665,12 +1673,12 @@ std::vector<int8_t> jus::Buffer::internalGetParameter<std::vector<int8_t>>(int32
|
||||
}
|
||||
return out;
|
||||
}
|
||||
JUS_ERROR("Can not get type from '" << type << "'");
|
||||
ZEUS_ERROR("Can not get type from '" << type << "'");
|
||||
return out;
|
||||
}
|
||||
|
||||
template<>
|
||||
std::vector<int16_t> jus::Buffer::internalGetParameter<std::vector<int16_t>>(int32_t _id) const {
|
||||
std::vector<int16_t> zeus::Buffer::internalGetParameter<std::vector<int16_t>>(int32_t _id) const {
|
||||
std::vector<int16_t> out;
|
||||
std::string type = internalGetParameterType(_id);
|
||||
const uint8_t* pointer = internalGetParameterPointer(_id);
|
||||
@ -1756,12 +1764,12 @@ std::vector<int16_t> jus::Buffer::internalGetParameter<std::vector<int16_t>>(int
|
||||
}
|
||||
return out;
|
||||
}
|
||||
JUS_ERROR("Can not get type from '" << type << "'");
|
||||
ZEUS_ERROR("Can not get type from '" << type << "'");
|
||||
return out;
|
||||
}
|
||||
|
||||
template<>
|
||||
std::vector<int32_t> jus::Buffer::internalGetParameter<std::vector<int32_t>>(int32_t _id) const {
|
||||
std::vector<int32_t> zeus::Buffer::internalGetParameter<std::vector<int32_t>>(int32_t _id) const {
|
||||
std::vector<int32_t> out;
|
||||
std::string type = internalGetParameterType(_id);
|
||||
const uint8_t* pointer = internalGetParameterPointer(_id);
|
||||
@ -1847,12 +1855,12 @@ std::vector<int32_t> jus::Buffer::internalGetParameter<std::vector<int32_t>>(int
|
||||
}
|
||||
return out;
|
||||
}
|
||||
JUS_ERROR("Can not get type from '" << type << "'");
|
||||
ZEUS_ERROR("Can not get type from '" << type << "'");
|
||||
return out;
|
||||
}
|
||||
|
||||
template<>
|
||||
std::vector<int64_t> jus::Buffer::internalGetParameter<std::vector<int64_t>>(int32_t _id) const {
|
||||
std::vector<int64_t> zeus::Buffer::internalGetParameter<std::vector<int64_t>>(int32_t _id) const {
|
||||
std::vector<int64_t> out;
|
||||
std::string type = internalGetParameterType(_id);
|
||||
const uint8_t* pointer = internalGetParameterPointer(_id);
|
||||
@ -1938,12 +1946,12 @@ std::vector<int64_t> jus::Buffer::internalGetParameter<std::vector<int64_t>>(int
|
||||
}
|
||||
return out;
|
||||
}
|
||||
JUS_ERROR("Can not get type from '" << type << "'");
|
||||
ZEUS_ERROR("Can not get type from '" << type << "'");
|
||||
return out;
|
||||
}
|
||||
|
||||
template<>
|
||||
std::vector<float> jus::Buffer::internalGetParameter<std::vector<float>>(int32_t _id) const {
|
||||
std::vector<float> zeus::Buffer::internalGetParameter<std::vector<float>>(int32_t _id) const {
|
||||
std::vector<float> out;
|
||||
std::string type = internalGetParameterType(_id);
|
||||
const uint8_t* pointer = internalGetParameterPointer(_id);
|
||||
@ -2029,12 +2037,12 @@ std::vector<float> jus::Buffer::internalGetParameter<std::vector<float>>(int32_t
|
||||
}
|
||||
return out;
|
||||
}
|
||||
JUS_ERROR("Can not get type from '" << type << "'");
|
||||
ZEUS_ERROR("Can not get type from '" << type << "'");
|
||||
return out;
|
||||
}
|
||||
|
||||
template<>
|
||||
std::vector<double> jus::Buffer::internalGetParameter<std::vector<double>>(int32_t _id) const {
|
||||
std::vector<double> zeus::Buffer::internalGetParameter<std::vector<double>>(int32_t _id) const {
|
||||
std::vector<double> out;
|
||||
std::string type = internalGetParameterType(_id);
|
||||
const uint8_t* pointer = internalGetParameterPointer(_id);
|
||||
@ -2120,12 +2128,12 @@ std::vector<double> jus::Buffer::internalGetParameter<std::vector<double>>(int32
|
||||
memcpy(&out, pointer, nbElement * sizeof(double));
|
||||
return out;
|
||||
}
|
||||
JUS_ERROR("Can not get type from '" << type << "'");
|
||||
ZEUS_ERROR("Can not get type from '" << type << "'");
|
||||
return out;
|
||||
}
|
||||
|
||||
template<>
|
||||
std::vector<bool> jus::Buffer::internalGetParameter<std::vector<bool>>(int32_t _id) const {
|
||||
std::vector<bool> zeus::Buffer::internalGetParameter<std::vector<bool>>(int32_t _id) const {
|
||||
std::vector<bool> out;
|
||||
std::string type = internalGetParameterType(_id);
|
||||
const uint8_t* pointer = internalGetParameterPointer(_id);
|
||||
@ -2142,12 +2150,12 @@ std::vector<bool> jus::Buffer::internalGetParameter<std::vector<bool>>(int32_t _
|
||||
}
|
||||
return out;
|
||||
}
|
||||
JUS_ERROR("Can not get type from '" << type << "'");
|
||||
ZEUS_ERROR("Can not get type from '" << type << "'");
|
||||
return out;
|
||||
}
|
||||
|
||||
template<>
|
||||
std::vector<std::string> jus::Buffer::internalGetParameter<std::vector<std::string>>(int32_t _id) const {
|
||||
std::vector<std::string> zeus::Buffer::internalGetParameter<std::vector<std::string>>(int32_t _id) const {
|
||||
std::vector<std::string> out;
|
||||
std::string type = internalGetParameterType(_id);
|
||||
const uint8_t* pointer = internalGetParameterPointer(_id);
|
||||
@ -2159,62 +2167,87 @@ std::vector<std::string> jus::Buffer::internalGetParameter<std::vector<std::stri
|
||||
const uint16_t* tmp = reinterpret_cast<const uint16_t*>(pointer);
|
||||
out.resize(*tmp);
|
||||
pointer += sizeof(uint16_t);
|
||||
JUS_DEBUG("Parse list of string: Find " << out.size() << " elements");
|
||||
ZEUS_DEBUG("Parse list of string: Find " << out.size() << " elements");
|
||||
//each string is separated with a \0:
|
||||
for (int32_t iii=0; iii<out.size(); ++iii) {
|
||||
const char* tmp2 = reinterpret_cast<const char*>(pointer);
|
||||
out[iii] = tmp2;
|
||||
pointer += out[iii].size() + 1;
|
||||
JUS_DEBUG(" value: '" << out[iii] << "'");
|
||||
ZEUS_DEBUG(" value: '" << out[iii] << "'");
|
||||
}
|
||||
return out;
|
||||
}
|
||||
JUS_ERROR("Can not get type from '" << type << "'");
|
||||
ZEUS_ERROR("Can not get type from '" << type << "'");
|
||||
return out;
|
||||
}
|
||||
|
||||
void jus::Buffer::addError(const std::string& _value, const std::string& _comment) {
|
||||
template<>
|
||||
zeus::File zeus::Buffer::internalGetParameter<zeus::File>(int32_t _id) const {
|
||||
zeus::File out;
|
||||
std::string type = internalGetParameterType(_id);
|
||||
const uint8_t* pointer = internalGetParameterPointer(_id);
|
||||
uint32_t dataSize = internalGetParameterSize(_id);
|
||||
// TODO : Check size ...
|
||||
if (createType<zeus::File>() == type) {
|
||||
/*
|
||||
const uint8_t* tmp = reinterpret_cast<const uint8_t*>(pointer);
|
||||
int32_t nbElement = dataSize / sizeof(uint8_t);
|
||||
out.resize(nbElement);
|
||||
for (size_t iii=0; iii<nbElement; ++iii) {
|
||||
out[iii] = tmp[iii] == 'T';
|
||||
}
|
||||
*/
|
||||
ZEUS_TODO("Generate retrun of file...");
|
||||
return out;
|
||||
}
|
||||
ZEUS_ERROR("Can not get type from '" << type << "'");
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
void zeus::Buffer::addError(const std::string& _value, const std::string& _comment) {
|
||||
addParameter(_value);
|
||||
addParameter(_comment);
|
||||
}
|
||||
|
||||
std::string jus::Buffer::getCall() const {
|
||||
std::string zeus::Buffer::getCall() const {
|
||||
std::string out;
|
||||
switch(getType()) {
|
||||
case jus::Buffer::typeMessage::call:
|
||||
case zeus::Buffer::typeMessage::call:
|
||||
return internalGetParameter<std::string>(0);
|
||||
break;
|
||||
case jus::Buffer::typeMessage::answer:
|
||||
JUS_WARNING("get 'call' with an input type: 'answer'");
|
||||
case zeus::Buffer::typeMessage::answer:
|
||||
ZEUS_WARNING("get 'call' with an input type: 'answer'");
|
||||
break;
|
||||
case jus::Buffer::typeMessage::event:
|
||||
JUS_WARNING("get 'call' with an input type: 'event'");
|
||||
case zeus::Buffer::typeMessage::event:
|
||||
ZEUS_WARNING("get 'call' with an input type: 'event'");
|
||||
break;
|
||||
default:
|
||||
JUS_ERROR("unknow type: " << uint16_t(getType()));
|
||||
ZEUS_ERROR("unknow type: " << uint16_t(getType()));
|
||||
break;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
void jus::Buffer::setCall(std::string _value) {
|
||||
void zeus::Buffer::setCall(std::string _value) {
|
||||
if (m_paramOffset.size() != 0) {
|
||||
JUS_ERROR("Clear Buffer of parameter ==> set the call type in first ...");
|
||||
ZEUS_ERROR("Clear Buffer of parameter ==> set the call type in first ...");
|
||||
m_paramOffset.clear();
|
||||
m_data.clear();
|
||||
}
|
||||
addParameter(_value);
|
||||
}
|
||||
|
||||
void jus::Buffer::prepare() {
|
||||
uint64_t zeus::Buffer::prepare() {
|
||||
m_header.numberOfParameter = m_paramOffset.size();
|
||||
m_header.lenght = sizeof(headerBin) - sizeof(uint32_t);
|
||||
m_header.lenght += m_paramOffset.size() * sizeof(uint16_t); // param list
|
||||
m_header.lenght += m_data.size();
|
||||
uint64_t size = sizeof(headerBin);
|
||||
size += m_paramOffset.size() * sizeof(uint16_t); // param list
|
||||
size += m_data.size();
|
||||
return size;
|
||||
}
|
||||
|
||||
bool jus::Buffer::hasError() {
|
||||
if (getType() != jus::Buffer::typeMessage::answer) {
|
||||
bool zeus::Buffer::hasError() {
|
||||
if (getType() != zeus::Buffer::typeMessage::answer) {
|
||||
return false;
|
||||
}
|
||||
if (m_paramOffset.size() == 2) {
|
||||
@ -2225,8 +2258,8 @@ bool jus::Buffer::hasError() {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string jus::Buffer::getError() {
|
||||
if (getType() != jus::Buffer::typeMessage::answer) {
|
||||
std::string zeus::Buffer::getError() {
|
||||
if (getType() != zeus::Buffer::typeMessage::answer) {
|
||||
return "";
|
||||
}
|
||||
if (m_paramOffset.size() == 2) {
|
||||
@ -2237,8 +2270,8 @@ std::string jus::Buffer::getError() {
|
||||
return "";
|
||||
}
|
||||
|
||||
std::string jus::Buffer::getErrorHelp() {
|
||||
if (getType() != jus::Buffer::typeMessage::answer) {
|
||||
std::string zeus::Buffer::getErrorHelp() {
|
||||
if (getType() != zeus::Buffer::typeMessage::answer) {
|
||||
return "";
|
||||
}
|
||||
if (m_paramOffset.size() == 2) {
|
||||
|
@ -6,11 +6,10 @@
|
||||
#pragma once
|
||||
#include <etk/types.h>
|
||||
|
||||
namespace jus {
|
||||
namespace zeus {
|
||||
//U32 message lenght
|
||||
#pragma pack(push,1)
|
||||
struct headerBin {
|
||||
uint32_t lenght;
|
||||
uint16_t versionProtocol; // protocol Version (might be 1)
|
||||
uint32_t transactionID;
|
||||
uint32_t clientID; // same as sevice ID
|
||||
@ -142,8 +141,8 @@ namespace jus {
|
||||
// == Section call
|
||||
// ===============================================
|
||||
private:
|
||||
template<class JUS_TYPE_DATA>
|
||||
JUS_TYPE_DATA internalGetParameter(int32_t _id) const;
|
||||
template<class ZEUS_TYPE_DATA>
|
||||
ZEUS_TYPE_DATA internalGetParameter(int32_t _id) const;
|
||||
std::string internalGetParameterType(int32_t _id) const;
|
||||
const uint8_t* internalGetParameterPointer(int32_t _id) const;
|
||||
uint32_t internalGetParameterSize(int32_t _id) const;
|
||||
@ -156,14 +155,14 @@ namespace jus {
|
||||
uint32_t getParameterSize(int32_t _id) const;
|
||||
|
||||
public:
|
||||
template<class JUS_TYPE_DATA>
|
||||
void addParameter(const JUS_TYPE_DATA& _value);
|
||||
template<class ZEUS_TYPE_DATA>
|
||||
void addParameter(const ZEUS_TYPE_DATA& _value);
|
||||
void addParameterEmptyVector();
|
||||
void addParameter();
|
||||
|
||||
template<class JUS_TYPE_DATA>
|
||||
JUS_TYPE_DATA getParameter(int32_t _id) const {
|
||||
return internalGetParameter<JUS_TYPE_DATA>(_id+1);
|
||||
template<class ZEUS_TYPE_DATA>
|
||||
ZEUS_TYPE_DATA getParameter(int32_t _id) const {
|
||||
return internalGetParameter<ZEUS_TYPE_DATA>(_id+1);
|
||||
}
|
||||
|
||||
|
||||
@ -171,14 +170,14 @@ namespace jus {
|
||||
// == Section Answer
|
||||
// ===============================================
|
||||
public:
|
||||
template<class JUS_TYPE_DATA>
|
||||
void addAnswer(const JUS_TYPE_DATA& _value) {
|
||||
template<class ZEUS_TYPE_DATA>
|
||||
void addAnswer(const ZEUS_TYPE_DATA& _value) {
|
||||
addParameter(_value);
|
||||
}
|
||||
// TODO : Do it better check error ... ==> can be good ...
|
||||
template<class JUS_TYPE_DATA>
|
||||
JUS_TYPE_DATA getAnswer() const {
|
||||
return internalGetParameter<JUS_TYPE_DATA>(0);
|
||||
template<class ZEUS_TYPE_DATA>
|
||||
ZEUS_TYPE_DATA getAnswer() const {
|
||||
return internalGetParameter<ZEUS_TYPE_DATA>(0);
|
||||
}
|
||||
void addError(const std::string& _value, const std::string& _comment);
|
||||
bool hasError();
|
||||
@ -189,8 +188,8 @@ namespace jus {
|
||||
//multiple section of data (part ...)
|
||||
void addData(void* _data, uint32_t _size);
|
||||
|
||||
void prepare();
|
||||
uint64_t prepare();
|
||||
};
|
||||
std::ostream& operator <<(std::ostream& _os, enum jus::Buffer::typeMessage _value);
|
||||
std::ostream& operator <<(std::ostream& _os, enum zeus::Buffer::typeMessage _value);
|
||||
}
|
||||
|
||||
|
@ -5,73 +5,73 @@
|
||||
*/
|
||||
|
||||
#include <enet/TcpClient.h>
|
||||
#include <jus/Client.h>
|
||||
#include <jus/debug.h>
|
||||
#include <zeus/Client.h>
|
||||
#include <zeus/debug.h>
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
jus::Client::Client() :
|
||||
propertyIp(this, "ip", "127.0.0.1", "Ip to connect server", &jus::Client::onPropertyChangeIp),
|
||||
propertyPort(this, "port", 1983, "Port to connect server", &jus::Client::onPropertyChangePort) {
|
||||
zeus::Client::Client() :
|
||||
propertyIp(this, "ip", "127.0.0.1", "Ip to connect server", &zeus::Client::onPropertyChangeIp),
|
||||
propertyPort(this, "port", 1983, "Port to connect server", &zeus::Client::onPropertyChangePort) {
|
||||
|
||||
}
|
||||
|
||||
jus::Client::~Client() {
|
||||
zeus::Client::~Client() {
|
||||
|
||||
}
|
||||
|
||||
void jus::Client::onClientData(jus::Buffer& _value) {
|
||||
JUS_ERROR("Get Data On the Communication interface that is not understand ... : " << _value.generateHumanString());
|
||||
void zeus::Client::onClientData(zeus::Buffer& _value) {
|
||||
ZEUS_ERROR("Get Data On the Communication interface that is not understand ... : " << _value.generateHumanString());
|
||||
}
|
||||
|
||||
jus::ServiceRemote jus::Client::getService(const std::string& _name) {
|
||||
return jus::ServiceRemote(m_interfaceClient, _name);
|
||||
zeus::ServiceRemote zeus::Client::getService(const std::string& _name) {
|
||||
return zeus::ServiceRemote(m_interfaceClient, _name);
|
||||
}
|
||||
|
||||
void jus::Client::onPropertyChangeIp() {
|
||||
void zeus::Client::onPropertyChangeIp() {
|
||||
disconnect();
|
||||
}
|
||||
|
||||
void jus::Client::onPropertyChangePort(){
|
||||
void zeus::Client::onPropertyChangePort(){
|
||||
disconnect();
|
||||
}
|
||||
|
||||
|
||||
bool jus::Client::connect(const std::string& _remoteUserToConnect){
|
||||
JUS_DEBUG("connect [START]");
|
||||
bool zeus::Client::connect(const std::string& _remoteUserToConnect){
|
||||
ZEUS_DEBUG("connect [START]");
|
||||
disconnect();
|
||||
enet::Tcp connection = std::move(enet::connectTcpClient(*propertyIp, *propertyPort));
|
||||
m_interfaceClient = std::make_shared<jus::TcpString>();
|
||||
m_interfaceClient = std::make_shared<zeus::TcpString>();
|
||||
if (m_interfaceClient == nullptr) {
|
||||
JUS_ERROR("Allocate connection error");
|
||||
ZEUS_ERROR("Allocate connection error");
|
||||
return false;
|
||||
}
|
||||
m_interfaceClient->connect(this, &jus::Client::onClientData);
|
||||
m_interfaceClient->setInterface(std::move(connection));
|
||||
m_interfaceClient->connect(this, &zeus::Client::onClientData);
|
||||
m_interfaceClient->setInterface(std::move(connection), false);
|
||||
m_interfaceClient->connect();
|
||||
|
||||
JUS_WARNING("Request connect user " << _remoteUserToConnect);
|
||||
jus::Future<bool> ret = call("connectToUser", _remoteUserToConnect, "jus-client");
|
||||
ZEUS_WARNING("Request connect user " << _remoteUserToConnect);
|
||||
zeus::Future<bool> ret = call("connectToUser", _remoteUserToConnect, "zeus-client");
|
||||
ret.wait();
|
||||
if (ret.hasError() == true) {
|
||||
JUS_WARNING("Can not connect to user named: '" << _remoteUserToConnect << "' ==> return error");
|
||||
ZEUS_WARNING("Can not connect to user named: '" << _remoteUserToConnect << "' ==> return error");
|
||||
return false;
|
||||
}
|
||||
if (ret.get() == true) {
|
||||
JUS_WARNING(" ==> accepted connection");
|
||||
ZEUS_WARNING(" ==> accepted connection");
|
||||
} else {
|
||||
JUS_WARNING(" ==> Refuse connection");
|
||||
ZEUS_WARNING(" ==> Refuse connection");
|
||||
}
|
||||
return ret.get();
|
||||
}
|
||||
|
||||
void jus::Client::disconnect() {
|
||||
JUS_DEBUG("disconnect [START]");
|
||||
void zeus::Client::disconnect() {
|
||||
ZEUS_DEBUG("disconnect [START]");
|
||||
if (m_interfaceClient != nullptr) {
|
||||
m_interfaceClient->disconnect();
|
||||
m_interfaceClient.reset();
|
||||
} else {
|
||||
JUS_VERBOSE("Nothing to disconnect ...");
|
||||
ZEUS_VERBOSE("Nothing to disconnect ...");
|
||||
}
|
||||
JUS_DEBUG("disconnect [STOP]");
|
||||
ZEUS_DEBUG("disconnect [STOP]");
|
||||
}
|
||||
|
@ -5,22 +5,22 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <jus/TcpString.h>
|
||||
#include <zeus/TcpString.h>
|
||||
#include <eproperty/Value.h>
|
||||
#include <jus/debug.h>
|
||||
#include <zeus/debug.h>
|
||||
#include <chrono>
|
||||
#include <unistd.h>
|
||||
#include <jus/Future.h>
|
||||
#include <jus/ServiceRemote.h>
|
||||
#include <zeus/Future.h>
|
||||
#include <zeus/ServiceRemote.h>
|
||||
|
||||
namespace jus {
|
||||
namespace zeus {
|
||||
class Client : public eproperty::Interface {
|
||||
friend class ServiceRemote;
|
||||
public:
|
||||
eproperty::Value<std::string> propertyIp;
|
||||
eproperty::Value<uint16_t> propertyPort;
|
||||
private:
|
||||
ememory::SharedPtr<jus::TcpString> m_interfaceClient;
|
||||
ememory::SharedPtr<zeus::TcpString> m_interfaceClient;
|
||||
public:
|
||||
/**
|
||||
* @brief Create a client on a specific user in a client mode with the tocken associated
|
||||
@ -46,30 +46,30 @@ namespace jus {
|
||||
bool connect(const std::string& _remoteUserToConnect);
|
||||
void disconnect();
|
||||
public:
|
||||
jus::ServiceRemote getService(const std::string& _serviceName);
|
||||
zeus::ServiceRemote getService(const std::string& _serviceName);
|
||||
|
||||
// Connect that is not us
|
||||
//bool identify("clientTest1#atria-soft.com", "QSDQSDGQSF54HSXWVCSQDJ654URTDJ654NBXCDFDGAEZ51968");
|
||||
// Connect to ourself:
|
||||
//client1.authentificate("coucou");
|
||||
private:
|
||||
void onClientData(jus::Buffer& _value);
|
||||
void onClientData(zeus::Buffer& _value);
|
||||
public:
|
||||
template<class... _ARGS>
|
||||
jus::FutureBase call(const std::string& _functionName, _ARGS&&... _args) {
|
||||
zeus::FutureBase call(const std::string& _functionName, _ARGS&&... _args) {
|
||||
if (m_interfaceClient == nullptr) {
|
||||
jus::Buffer ret;
|
||||
zeus::Buffer ret;
|
||||
ret.addError("NULLPTR", "call " + _functionName + " with no interface open");
|
||||
return jus::FutureBase(0, true, ret);
|
||||
return zeus::FutureBase(0, true, ret);
|
||||
}
|
||||
return m_interfaceClient->call(_functionName, _args...);
|
||||
}
|
||||
template<class... _ARGS>
|
||||
jus::FutureBase callAction(const std::string& _functionName, _ARGS&&... _args, jus::FutureData::ObserverFinish _callback) {
|
||||
zeus::FutureBase callAction(const std::string& _functionName, _ARGS&&... _args, zeus::FutureData::ObserverFinish _callback) {
|
||||
if (m_interfaceClient == nullptr) {
|
||||
jus::Buffer ret;
|
||||
zeus::Buffer ret;
|
||||
ret.addError("NULLPTR", "call " + _functionName + " with no interface open");
|
||||
return jus::FutureBase(0, true, ret, _callback);
|
||||
return zeus::FutureBase(0, true, ret, _callback);
|
||||
}
|
||||
return m_interfaceClient->callAction(_functionName, _args..., _callback);
|
||||
}
|
||||
|
@ -3,31 +3,31 @@
|
||||
* @copyright 2016, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
#include <jus/File.h>
|
||||
#include <jus/debug.h>
|
||||
#include <zeus/File.h>
|
||||
#include <zeus/debug.h>
|
||||
#include <etk/types.h>
|
||||
#include <etk/stdTools.h>
|
||||
#include <jus/mineType.h>
|
||||
#include <zeus/mineType.h>
|
||||
#include <etk/os/FSNode.h>
|
||||
|
||||
|
||||
|
||||
jus::File::File() {
|
||||
zeus::File::File() {
|
||||
|
||||
}
|
||||
|
||||
jus::File::File(const std::string& _filename) {
|
||||
zeus::File::File(const std::string& _filename) {
|
||||
m_data = etk::FSNodeReadAllDataType<uint8_t>(_filename);
|
||||
std::string extention = std::string(_filename.begin()+_filename.size() -3, _filename.end());
|
||||
JUS_WARNING("send file: '" << _filename << "' with extention: '" << extention << "'");
|
||||
m_mineType = jus::getMineType(extention);
|
||||
ZEUS_WARNING("send file: '" << _filename << "' with extention: '" << extention << "'");
|
||||
m_mineType = zeus::getMineType(extention);
|
||||
}
|
||||
|
||||
void jus::File::storeIn(const std::string& _filename) const {
|
||||
void zeus::File::storeIn(const std::string& _filename) const {
|
||||
etk::FSNodeWriteAllDataType(_filename, m_data);
|
||||
}
|
||||
|
||||
jus::File::File(const std::string& _mineType, std::vector<uint8_t> _data, int32_t _fileSize):
|
||||
zeus::File::File(const std::string& _mineType, std::vector<uint8_t> _data, int32_t _fileSize):
|
||||
m_mineType(_mineType),
|
||||
m_data(_data) {
|
||||
if (_fileSize < 0){
|
||||
@ -37,16 +37,16 @@ jus::File::File(const std::string& _mineType, std::vector<uint8_t> _data, int32_
|
||||
}
|
||||
}
|
||||
|
||||
void jus::File::setData(uint64_t _offset, const std::vector<uint8_t>& _data) {
|
||||
void zeus::File::setData(uint64_t _offset, const std::vector<uint8_t>& _data) {
|
||||
// TODO : Check size/offset before set
|
||||
memcpy(&m_data[_offset], &_data[0], _data.size());
|
||||
}
|
||||
|
||||
|
||||
jus::FileServer::FileServer() {
|
||||
zeus::FileServer::FileServer() {
|
||||
|
||||
}
|
||||
jus::FileServer::FileServer(const std::string& _filename) :
|
||||
zeus::FileServer::FileServer(const std::string& _filename) :
|
||||
m_name(_filename) {
|
||||
|
||||
}
|
||||
@ -54,7 +54,7 @@ jus::FileServer::FileServer(const std::string& _filename) :
|
||||
|
||||
namespace etk {
|
||||
template<>
|
||||
std::string to_string<jus::FileServer>(jus::FileServer const& _obj) {
|
||||
std::string to_string<zeus::FileServer>(zeus::FileServer const& _obj) {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
#pragma once
|
||||
#include <etk/types.h>
|
||||
|
||||
namespace jus {
|
||||
namespace zeus {
|
||||
class File {
|
||||
private:
|
||||
std::string m_mineType;
|
||||
|
162
zeus/Future.cpp
162
zeus/Future.cpp
@ -3,319 +3,319 @@
|
||||
* @copyright 2014, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
#include <jus/Future.h>
|
||||
#include <jus/debug.h>
|
||||
#include <zeus/Future.h>
|
||||
#include <zeus/debug.h>
|
||||
#include <unistd.h>
|
||||
#include <jus/File.h>
|
||||
#include <zeus/File.h>
|
||||
|
||||
namespace jus {
|
||||
namespace zeus {
|
||||
template<>
|
||||
bool jus::Future<bool>::get() {
|
||||
bool zeus::Future<bool>::get() {
|
||||
if (m_data == nullptr) {
|
||||
return false;
|
||||
}
|
||||
if (m_data->m_returnData.getType() != jus::Buffer::typeMessage::answer) {
|
||||
JUS_WARNING("No Return value ...");
|
||||
if (m_data->m_returnData.getType() != zeus::Buffer::typeMessage::answer) {
|
||||
ZEUS_WARNING("No Return value ...");
|
||||
return false;
|
||||
}
|
||||
return m_data->m_returnData.getAnswer<bool>();
|
||||
}
|
||||
template<>
|
||||
int64_t jus::Future<int64_t>::get() {
|
||||
int64_t zeus::Future<int64_t>::get() {
|
||||
if (m_data == nullptr) {
|
||||
return 0;
|
||||
}
|
||||
if (m_data->m_returnData.getType() != jus::Buffer::typeMessage::answer) {
|
||||
JUS_WARNING("No Return value ...");
|
||||
if (m_data->m_returnData.getType() != zeus::Buffer::typeMessage::answer) {
|
||||
ZEUS_WARNING("No Return value ...");
|
||||
return 0;
|
||||
}
|
||||
return m_data->m_returnData.getAnswer<bool>();
|
||||
}
|
||||
template<>
|
||||
int32_t jus::Future<int32_t>::get() {
|
||||
int32_t zeus::Future<int32_t>::get() {
|
||||
if (m_data == nullptr) {
|
||||
return 0;
|
||||
}
|
||||
if (m_data->m_returnData.getType() != jus::Buffer::typeMessage::answer) {
|
||||
JUS_WARNING("No Return value ...");
|
||||
if (m_data->m_returnData.getType() != zeus::Buffer::typeMessage::answer) {
|
||||
ZEUS_WARNING("No Return value ...");
|
||||
return 0;
|
||||
}
|
||||
return m_data->m_returnData.getAnswer<int32_t>();
|
||||
}
|
||||
template<>
|
||||
int16_t jus::Future<int16_t>::get() {
|
||||
int16_t zeus::Future<int16_t>::get() {
|
||||
if (m_data == nullptr) {
|
||||
return 0;
|
||||
}
|
||||
if (m_data->m_returnData.getType() != jus::Buffer::typeMessage::answer) {
|
||||
JUS_WARNING("No Return value ...");
|
||||
if (m_data->m_returnData.getType() != zeus::Buffer::typeMessage::answer) {
|
||||
ZEUS_WARNING("No Return value ...");
|
||||
return 0;
|
||||
}
|
||||
return m_data->m_returnData.getAnswer<int16_t>();
|
||||
}
|
||||
template<>
|
||||
int8_t jus::Future<int8_t>::get() {
|
||||
int8_t zeus::Future<int8_t>::get() {
|
||||
if (m_data == nullptr) {
|
||||
return 0;
|
||||
}
|
||||
if (m_data->m_returnData.getType() != jus::Buffer::typeMessage::answer) {
|
||||
JUS_WARNING("No Return value ...");
|
||||
if (m_data->m_returnData.getType() != zeus::Buffer::typeMessage::answer) {
|
||||
ZEUS_WARNING("No Return value ...");
|
||||
return 0;
|
||||
}
|
||||
return m_data->m_returnData.getAnswer<int8_t>();
|
||||
}
|
||||
template<>
|
||||
uint64_t jus::Future<uint64_t>::get() {
|
||||
uint64_t zeus::Future<uint64_t>::get() {
|
||||
if (m_data == nullptr) {
|
||||
return 0;
|
||||
}
|
||||
if (m_data->m_returnData.getType() != jus::Buffer::typeMessage::answer) {
|
||||
JUS_WARNING("No Return value ...");
|
||||
if (m_data->m_returnData.getType() != zeus::Buffer::typeMessage::answer) {
|
||||
ZEUS_WARNING("No Return value ...");
|
||||
return 0;
|
||||
}
|
||||
return m_data->m_returnData.getAnswer<int64_t>();
|
||||
}
|
||||
template<>
|
||||
uint32_t jus::Future<uint32_t>::get() {
|
||||
uint32_t zeus::Future<uint32_t>::get() {
|
||||
if (m_data == nullptr) {
|
||||
return 0;
|
||||
}
|
||||
if (m_data->m_returnData.getType() != jus::Buffer::typeMessage::answer) {
|
||||
JUS_WARNING("No Return value ...");
|
||||
if (m_data->m_returnData.getType() != zeus::Buffer::typeMessage::answer) {
|
||||
ZEUS_WARNING("No Return value ...");
|
||||
return 0;
|
||||
}
|
||||
return m_data->m_returnData.getAnswer<uint32_t>();
|
||||
}
|
||||
template<>
|
||||
uint16_t jus::Future<uint16_t>::get() {
|
||||
uint16_t zeus::Future<uint16_t>::get() {
|
||||
if (m_data == nullptr) {
|
||||
return 0;
|
||||
}
|
||||
if (m_data->m_returnData.getType() != jus::Buffer::typeMessage::answer) {
|
||||
JUS_WARNING("No Return value ...");
|
||||
if (m_data->m_returnData.getType() != zeus::Buffer::typeMessage::answer) {
|
||||
ZEUS_WARNING("No Return value ...");
|
||||
return 0;
|
||||
}
|
||||
return m_data->m_returnData.getAnswer<uint16_t>();
|
||||
}
|
||||
template<>
|
||||
uint8_t jus::Future<uint8_t>::get() {
|
||||
uint8_t zeus::Future<uint8_t>::get() {
|
||||
if (m_data == nullptr) {
|
||||
return 0;
|
||||
}
|
||||
if (m_data->m_returnData.getType() != jus::Buffer::typeMessage::answer) {
|
||||
JUS_WARNING("No Return value ...");
|
||||
if (m_data->m_returnData.getType() != zeus::Buffer::typeMessage::answer) {
|
||||
ZEUS_WARNING("No Return value ...");
|
||||
return 0;
|
||||
}
|
||||
return m_data->m_returnData.getAnswer<uint8_t>();
|
||||
}
|
||||
template<>
|
||||
double jus::Future<double>::get() {
|
||||
double zeus::Future<double>::get() {
|
||||
if (m_data == nullptr) {
|
||||
return 0;
|
||||
}
|
||||
if (m_data->m_returnData.getType() != jus::Buffer::typeMessage::answer) {
|
||||
JUS_WARNING("No Return value ...");
|
||||
if (m_data->m_returnData.getType() != zeus::Buffer::typeMessage::answer) {
|
||||
ZEUS_WARNING("No Return value ...");
|
||||
return 0.0;
|
||||
}
|
||||
return m_data->m_returnData.getAnswer<double>();
|
||||
}
|
||||
template<>
|
||||
float jus::Future<float>::get() {
|
||||
float zeus::Future<float>::get() {
|
||||
if (m_data == nullptr) {
|
||||
return 0.0f;
|
||||
}
|
||||
if (m_data->m_returnData.getType() != jus::Buffer::typeMessage::answer) {
|
||||
JUS_WARNING("No Return value ...");
|
||||
if (m_data->m_returnData.getType() != zeus::Buffer::typeMessage::answer) {
|
||||
ZEUS_WARNING("No Return value ...");
|
||||
return 0.0f;
|
||||
}
|
||||
return m_data->m_returnData.getAnswer<float>();
|
||||
}
|
||||
template<>
|
||||
std::string jus::Future<std::string>::get() {
|
||||
std::string zeus::Future<std::string>::get() {
|
||||
if (m_data == nullptr) {
|
||||
return "";
|
||||
}
|
||||
if (m_data->m_returnData.getType() != jus::Buffer::typeMessage::answer) {
|
||||
JUS_WARNING("No Return value ...");
|
||||
if (m_data->m_returnData.getType() != zeus::Buffer::typeMessage::answer) {
|
||||
ZEUS_WARNING("No Return value ...");
|
||||
return "";
|
||||
}
|
||||
return m_data->m_returnData.getAnswer<std::string>();
|
||||
}
|
||||
template<>
|
||||
std::vector<int64_t> jus::Future<std::vector<int64_t>>::get() {
|
||||
std::vector<int64_t> zeus::Future<std::vector<int64_t>>::get() {
|
||||
std::vector<int64_t> out;
|
||||
if (m_data == nullptr) {
|
||||
return out;
|
||||
}
|
||||
if (m_data->m_returnData.getType() != jus::Buffer::typeMessage::answer) {
|
||||
JUS_WARNING("No Return value ...");
|
||||
if (m_data->m_returnData.getType() != zeus::Buffer::typeMessage::answer) {
|
||||
ZEUS_WARNING("No Return value ...");
|
||||
return out;
|
||||
}
|
||||
out = m_data->m_returnData.getAnswer<std::vector<int64_t>>();
|
||||
return out;
|
||||
}
|
||||
template<>
|
||||
std::vector<int32_t> jus::Future<std::vector<int32_t>>::get() {
|
||||
std::vector<int32_t> zeus::Future<std::vector<int32_t>>::get() {
|
||||
std::vector<int32_t> out;
|
||||
if (m_data == nullptr) {
|
||||
return out;
|
||||
}
|
||||
if (m_data->m_returnData.getType() != jus::Buffer::typeMessage::answer) {
|
||||
JUS_WARNING("No Return value ...");
|
||||
if (m_data->m_returnData.getType() != zeus::Buffer::typeMessage::answer) {
|
||||
ZEUS_WARNING("No Return value ...");
|
||||
return out;
|
||||
}
|
||||
out = m_data->m_returnData.getAnswer<std::vector<int32_t>>();
|
||||
return out;
|
||||
}
|
||||
template<>
|
||||
std::vector<int16_t> jus::Future<std::vector<int16_t>>::get() {
|
||||
std::vector<int16_t> zeus::Future<std::vector<int16_t>>::get() {
|
||||
std::vector<int16_t> out;
|
||||
if (m_data == nullptr) {
|
||||
return out;
|
||||
}
|
||||
if (m_data->m_returnData.getType() != jus::Buffer::typeMessage::answer) {
|
||||
JUS_WARNING("No Return value ...");
|
||||
if (m_data->m_returnData.getType() != zeus::Buffer::typeMessage::answer) {
|
||||
ZEUS_WARNING("No Return value ...");
|
||||
return out;
|
||||
}
|
||||
out = m_data->m_returnData.getAnswer<std::vector<int16_t>>();
|
||||
return out;
|
||||
}
|
||||
template<>
|
||||
std::vector<int8_t> jus::Future<std::vector<int8_t>>::get() {
|
||||
std::vector<int8_t> zeus::Future<std::vector<int8_t>>::get() {
|
||||
std::vector<int8_t> out;
|
||||
if (m_data == nullptr) {
|
||||
return out;
|
||||
}
|
||||
if (m_data->m_returnData.getType() != jus::Buffer::typeMessage::answer) {
|
||||
JUS_WARNING("No Return value ...");
|
||||
if (m_data->m_returnData.getType() != zeus::Buffer::typeMessage::answer) {
|
||||
ZEUS_WARNING("No Return value ...");
|
||||
return out;
|
||||
}
|
||||
out = m_data->m_returnData.getAnswer<std::vector<int8_t>>();
|
||||
return out;
|
||||
}
|
||||
template<>
|
||||
std::vector<uint64_t> jus::Future<std::vector<uint64_t>>::get() {
|
||||
std::vector<uint64_t> zeus::Future<std::vector<uint64_t>>::get() {
|
||||
std::vector<uint64_t> out;
|
||||
if (m_data == nullptr) {
|
||||
return out;
|
||||
}
|
||||
if (m_data->m_returnData.getType() != jus::Buffer::typeMessage::answer) {
|
||||
JUS_WARNING("No Return value ...");
|
||||
if (m_data->m_returnData.getType() != zeus::Buffer::typeMessage::answer) {
|
||||
ZEUS_WARNING("No Return value ...");
|
||||
return out;
|
||||
}
|
||||
out = m_data->m_returnData.getAnswer<std::vector<uint64_t>>();
|
||||
return out;
|
||||
}
|
||||
template<>
|
||||
std::vector<uint32_t> jus::Future<std::vector<uint32_t>>::get() {
|
||||
std::vector<uint32_t> zeus::Future<std::vector<uint32_t>>::get() {
|
||||
std::vector<uint32_t> out;
|
||||
if (m_data == nullptr) {
|
||||
return out;
|
||||
}
|
||||
if (m_data->m_returnData.getType() != jus::Buffer::typeMessage::answer) {
|
||||
JUS_WARNING("No Return value ...");
|
||||
if (m_data->m_returnData.getType() != zeus::Buffer::typeMessage::answer) {
|
||||
ZEUS_WARNING("No Return value ...");
|
||||
return out;
|
||||
}
|
||||
out = m_data->m_returnData.getAnswer<std::vector<uint32_t>>();
|
||||
return out;
|
||||
}
|
||||
template<>
|
||||
std::vector<uint16_t> jus::Future<std::vector<uint16_t>>::get() {
|
||||
std::vector<uint16_t> zeus::Future<std::vector<uint16_t>>::get() {
|
||||
std::vector<uint16_t> out;
|
||||
if (m_data == nullptr) {
|
||||
return out;
|
||||
}
|
||||
if (m_data->m_returnData.getType() != jus::Buffer::typeMessage::answer) {
|
||||
JUS_WARNING("No Return value ...");
|
||||
if (m_data->m_returnData.getType() != zeus::Buffer::typeMessage::answer) {
|
||||
ZEUS_WARNING("No Return value ...");
|
||||
return out;
|
||||
}
|
||||
out = m_data->m_returnData.getAnswer<std::vector<uint16_t>>();
|
||||
return out;
|
||||
}
|
||||
template<>
|
||||
std::vector<uint8_t> jus::Future<std::vector<uint8_t>>::get() {
|
||||
std::vector<uint8_t> zeus::Future<std::vector<uint8_t>>::get() {
|
||||
std::vector<uint8_t> out;
|
||||
if (m_data == nullptr) {
|
||||
return out;
|
||||
}
|
||||
if (m_data->m_returnData.getType() != jus::Buffer::typeMessage::answer) {
|
||||
JUS_WARNING("No Return value ...");
|
||||
if (m_data->m_returnData.getType() != zeus::Buffer::typeMessage::answer) {
|
||||
ZEUS_WARNING("No Return value ...");
|
||||
return out;
|
||||
}
|
||||
out = m_data->m_returnData.getAnswer<std::vector<uint8_t>>();
|
||||
return out;
|
||||
}
|
||||
template<>
|
||||
std::vector<double> jus::Future<std::vector<double>>::get() {
|
||||
std::vector<double> zeus::Future<std::vector<double>>::get() {
|
||||
std::vector<double> out;
|
||||
if (m_data == nullptr) {
|
||||
return out;
|
||||
}
|
||||
if (m_data->m_returnData.getType() != jus::Buffer::typeMessage::answer) {
|
||||
JUS_WARNING("No Return value ...");
|
||||
if (m_data->m_returnData.getType() != zeus::Buffer::typeMessage::answer) {
|
||||
ZEUS_WARNING("No Return value ...");
|
||||
return out;
|
||||
}
|
||||
out = m_data->m_returnData.getAnswer<std::vector<double>>();
|
||||
return out;
|
||||
}
|
||||
template<>
|
||||
std::vector<float> jus::Future<std::vector<float>>::get() {
|
||||
std::vector<float> zeus::Future<std::vector<float>>::get() {
|
||||
std::vector<float> out;
|
||||
if (m_data == nullptr) {
|
||||
return out;
|
||||
}
|
||||
if (m_data->m_returnData.getType() != jus::Buffer::typeMessage::answer) {
|
||||
JUS_WARNING("No Return value ...");
|
||||
if (m_data->m_returnData.getType() != zeus::Buffer::typeMessage::answer) {
|
||||
ZEUS_WARNING("No Return value ...");
|
||||
return out;
|
||||
}
|
||||
out = m_data->m_returnData.getAnswer<std::vector<float>>();
|
||||
return out;
|
||||
}
|
||||
template<>
|
||||
std::vector<std::string> jus::Future<std::vector<std::string>>::get() {
|
||||
std::vector<std::string> zeus::Future<std::vector<std::string>>::get() {
|
||||
std::vector<std::string> out;
|
||||
if (m_data == nullptr) {
|
||||
return out;
|
||||
}
|
||||
if (m_data->m_returnData.getType() != jus::Buffer::typeMessage::answer) {
|
||||
JUS_WARNING("No Return value ...");
|
||||
if (m_data->m_returnData.getType() != zeus::Buffer::typeMessage::answer) {
|
||||
ZEUS_WARNING("No Return value ...");
|
||||
return out;
|
||||
}
|
||||
out = m_data->m_returnData.getAnswer<std::vector<std::string>>();
|
||||
return out;
|
||||
}
|
||||
template<>
|
||||
std::vector<bool> jus::Future<std::vector<bool>>::get() {
|
||||
std::vector<bool> zeus::Future<std::vector<bool>>::get() {
|
||||
std::vector<bool> out;
|
||||
if (m_data == nullptr) {
|
||||
return out;
|
||||
}
|
||||
if (m_data->m_returnData.getType() != jus::Buffer::typeMessage::answer) {
|
||||
JUS_WARNING("No Return value ...");
|
||||
if (m_data->m_returnData.getType() != zeus::Buffer::typeMessage::answer) {
|
||||
ZEUS_WARNING("No Return value ...");
|
||||
return out;
|
||||
}
|
||||
out = m_data->m_returnData.getAnswer<std::vector<bool>>();
|
||||
return out;
|
||||
}
|
||||
template<>
|
||||
jus::File jus::Future<jus::File>::get() {
|
||||
jus::File out;
|
||||
zeus::File zeus::Future<zeus::File>::get() {
|
||||
zeus::File out;
|
||||
if (m_data == nullptr) {
|
||||
return out;
|
||||
}
|
||||
/* TODO : ...
|
||||
ejson::Value val = m_data->m_returnData["return"];
|
||||
if (val.exist() == false) {
|
||||
JUS_WARNING("No Return value ...");
|
||||
ZEUS_WARNING("No Return value ...");
|
||||
return out;
|
||||
}
|
||||
if (val.isObject() == false) {
|
||||
JUS_WARNING("Wrong return Type get '" << val.getType() << " instead of 'Object'");
|
||||
ZEUS_WARNING("Wrong return Type get '" << val.getType() << " instead of 'Object'");
|
||||
return out;
|
||||
}
|
||||
ejson::Object retVal = val.toObject();
|
||||
if (retVal["type"].toString().get() != "file") {
|
||||
JUS_WARNING("Wrong return object-type get '" << retVal["type"].toString().get() << " instead of 'file'");
|
||||
ZEUS_WARNING("Wrong return object-type get '" << retVal["type"].toString().get() << " instead of 'file'");
|
||||
return out;
|
||||
}
|
||||
out.setMineType(retVal["mine-type"].toString().get());
|
||||
|
@ -5,30 +5,30 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <jus/FutureBase.h>
|
||||
#include <zeus/FutureBase.h>
|
||||
|
||||
namespace jus {
|
||||
template<class JUS_RETURN>
|
||||
class Future : public jus::FutureBase {
|
||||
namespace zeus {
|
||||
template<class ZEUS_RETURN>
|
||||
class Future : public zeus::FutureBase {
|
||||
public:
|
||||
Future(const jus::FutureBase& _base):
|
||||
jus::FutureBase(_base) {
|
||||
Future(const zeus::FutureBase& _base):
|
||||
zeus::FutureBase(_base) {
|
||||
|
||||
}
|
||||
jus::Future<JUS_RETURN>& operator= (const jus::FutureBase& _base) {
|
||||
zeus::Future<ZEUS_RETURN>& operator= (const zeus::FutureBase& _base) {
|
||||
m_data = _base.m_data;
|
||||
return *this;
|
||||
}
|
||||
JUS_RETURN get();
|
||||
ZEUS_RETURN get();
|
||||
};
|
||||
template<>
|
||||
class Future<void> : public jus::FutureBase {
|
||||
class Future<void> : public zeus::FutureBase {
|
||||
public:
|
||||
Future(const jus::FutureBase& _base):
|
||||
jus::FutureBase(_base) {
|
||||
Future(const zeus::FutureBase& _base):
|
||||
zeus::FutureBase(_base) {
|
||||
|
||||
}
|
||||
jus::Future<void>& operator= (const jus::FutureBase& _base) {
|
||||
zeus::Future<void>& operator= (const zeus::FutureBase& _base) {
|
||||
m_data = _base.m_data;
|
||||
return *this;
|
||||
}
|
||||
|
@ -3,21 +3,21 @@
|
||||
* @copyright 2014, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
#include <jus/FutureBase.h>
|
||||
#include <jus/debug.h>
|
||||
#include <zeus/FutureBase.h>
|
||||
#include <zeus/debug.h>
|
||||
#include <unistd.h>
|
||||
|
||||
jus::FutureBase::FutureBase(const jus::FutureBase& _base):
|
||||
zeus::FutureBase::FutureBase(const zeus::FutureBase& _base):
|
||||
m_data(_base.m_data) {
|
||||
|
||||
}
|
||||
|
||||
jus::FutureBase::FutureBase() {
|
||||
zeus::FutureBase::FutureBase() {
|
||||
m_data = nullptr;
|
||||
}
|
||||
|
||||
jus::FutureBase::FutureBase(uint64_t _transactionId, jus::FutureData::ObserverFinish _callback) {
|
||||
m_data = std::make_shared<jus::FutureData>();
|
||||
zeus::FutureBase::FutureBase(uint64_t _transactionId, zeus::FutureData::ObserverFinish _callback) {
|
||||
m_data = std::make_shared<zeus::FutureData>();
|
||||
if (m_data == nullptr) {
|
||||
return;
|
||||
}
|
||||
@ -28,16 +28,16 @@ jus::FutureBase::FutureBase(uint64_t _transactionId, jus::FutureData::ObserverFi
|
||||
m_data->m_callbackFinish = _callback;
|
||||
}
|
||||
|
||||
const jus::Buffer& jus::FutureBase::getRaw() {
|
||||
const zeus::Buffer& zeus::FutureBase::getRaw() {
|
||||
if (m_data == nullptr) {
|
||||
static jus::Buffer tmpp;
|
||||
static zeus::Buffer tmpp;
|
||||
return tmpp;
|
||||
}
|
||||
return m_data->m_returnData;
|
||||
}
|
||||
|
||||
jus::FutureBase::FutureBase(uint64_t _transactionId, bool _isFinished, jus::Buffer _returnData, jus::FutureData::ObserverFinish _callback) {
|
||||
m_data = std::make_shared<jus::FutureData>();
|
||||
zeus::FutureBase::FutureBase(uint64_t _transactionId, bool _isFinished, zeus::Buffer _returnData, zeus::FutureData::ObserverFinish _callback) {
|
||||
m_data = std::make_shared<zeus::FutureData>();
|
||||
if (m_data == nullptr) {
|
||||
return;
|
||||
}
|
||||
@ -54,7 +54,7 @@ jus::FutureBase::FutureBase(uint64_t _transactionId, bool _isFinished, jus::Buff
|
||||
}
|
||||
}
|
||||
}
|
||||
std::chrono::nanoseconds jus::FutureBase::getTransmitionTime() {
|
||||
std::chrono::nanoseconds zeus::FutureBase::getTransmitionTime() {
|
||||
if (m_data == nullptr) {
|
||||
return std::chrono::nanoseconds(0);
|
||||
}
|
||||
@ -64,14 +64,14 @@ std::chrono::nanoseconds jus::FutureBase::getTransmitionTime() {
|
||||
return m_data->m_receiveTime - m_data->m_sendTime;
|
||||
}
|
||||
|
||||
jus::FutureBase jus::FutureBase::operator= (const jus::FutureBase& _base) {
|
||||
zeus::FutureBase zeus::FutureBase::operator= (const zeus::FutureBase& _base) {
|
||||
m_data = _base.m_data;
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool jus::FutureBase::setAnswer(const jus::Buffer& _returnValue) {
|
||||
bool zeus::FutureBase::setAnswer(const zeus::Buffer& _returnValue) {
|
||||
if (m_data == nullptr) {
|
||||
JUS_ERROR(" Not a valid future ...");
|
||||
ZEUS_ERROR(" Not a valid future ...");
|
||||
return true;
|
||||
}
|
||||
m_data->m_receiveTime = std::chrono::steady_clock::now();
|
||||
@ -109,53 +109,53 @@ bool jus::FutureBase::setAnswer(const jus::Buffer& _returnValue) {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
void jus::FutureBase::setSynchronous() {
|
||||
void zeus::FutureBase::setSynchronous() {
|
||||
if (m_data == nullptr) {
|
||||
return;
|
||||
}
|
||||
m_data->m_isSynchronous = true;
|
||||
}
|
||||
|
||||
uint64_t jus::FutureBase::getTransactionId() {
|
||||
uint64_t zeus::FutureBase::getTransactionId() {
|
||||
if (m_data == nullptr) {
|
||||
return 0;
|
||||
}
|
||||
return m_data->m_transactionId;
|
||||
}
|
||||
|
||||
bool jus::FutureBase::hasError() {
|
||||
bool zeus::FutureBase::hasError() {
|
||||
if (m_data == nullptr) {
|
||||
return true;
|
||||
}
|
||||
return m_data->m_returnData.hasError();
|
||||
}
|
||||
|
||||
std::string jus::FutureBase::getErrorType() {
|
||||
std::string zeus::FutureBase::getErrorType() {
|
||||
if (m_data == nullptr) {
|
||||
return "NULL_PTR";
|
||||
}
|
||||
return m_data->m_returnData.getError();
|
||||
}
|
||||
|
||||
std::string jus::FutureBase::getErrorHelp() {
|
||||
std::string zeus::FutureBase::getErrorHelp() {
|
||||
if (m_data == nullptr) {
|
||||
return "Thsi is a nullptr future";
|
||||
}
|
||||
return m_data->m_returnData.getErrorHelp();
|
||||
}
|
||||
|
||||
bool jus::FutureBase::isValid() {
|
||||
bool zeus::FutureBase::isValid() {
|
||||
return m_data != nullptr;
|
||||
}
|
||||
|
||||
bool jus::FutureBase::isFinished() {
|
||||
bool zeus::FutureBase::isFinished() {
|
||||
if (m_data == nullptr) {
|
||||
return true;
|
||||
}
|
||||
return m_data->m_isFinished;
|
||||
}
|
||||
|
||||
jus::FutureBase& jus::FutureBase::wait() {
|
||||
zeus::FutureBase& zeus::FutureBase::wait() {
|
||||
while (isFinished() == false) {
|
||||
// TODO : Do it better ... like messaging/mutex_locked ...
|
||||
usleep(10000);
|
||||
@ -163,7 +163,7 @@ jus::FutureBase& jus::FutureBase::wait() {
|
||||
return *this;
|
||||
}
|
||||
|
||||
jus::FutureBase& jus::FutureBase::waitFor(std::chrono::microseconds _delta) {
|
||||
zeus::FutureBase& zeus::FutureBase::waitFor(std::chrono::microseconds _delta) {
|
||||
std::chrono::steady_clock::time_point start = std::chrono::steady_clock::now();
|
||||
while ( std::chrono::steady_clock::now() - start < _delta
|
||||
&& isFinished() == false) {
|
||||
@ -174,7 +174,7 @@ jus::FutureBase& jus::FutureBase::waitFor(std::chrono::microseconds _delta) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
jus::FutureBase& jus::FutureBase::waitUntil(std::chrono::steady_clock::time_point _endTime) {
|
||||
zeus::FutureBase& zeus::FutureBase::waitUntil(std::chrono::steady_clock::time_point _endTime) {
|
||||
while ( std::chrono::steady_clock::now() < _endTime
|
||||
&& isFinished() == false) {
|
||||
// TODO : Do it better ... like messaging/mutex_locked ...
|
||||
@ -184,7 +184,7 @@ jus::FutureBase& jus::FutureBase::waitUntil(std::chrono::steady_clock::time_poin
|
||||
}
|
||||
|
||||
|
||||
jus::FutureCall::FutureCall(uint64_t _clientId, uint64_t _transactionId, jus::Buffer& _callValue) :
|
||||
zeus::FutureCall::FutureCall(uint64_t _clientId, uint64_t _transactionId, zeus::Buffer& _callValue) :
|
||||
m_transactionId(_transactionId),
|
||||
m_clientId(_clientId),
|
||||
m_isFinished(false) {
|
||||
@ -192,27 +192,27 @@ jus::FutureCall::FutureCall(uint64_t _clientId, uint64_t _transactionId, jus::Bu
|
||||
m_isFinished = m_data.getPartFinish();
|
||||
}
|
||||
|
||||
void jus::FutureCall::appendData(jus::Buffer& _callValue) {
|
||||
void zeus::FutureCall::appendData(zeus::Buffer& _callValue) {
|
||||
m_dataMultiplePack.push_back(_callValue);
|
||||
m_isFinished = _callValue.getPartFinish();
|
||||
}
|
||||
|
||||
uint64_t jus::FutureCall::getTransactionId() {
|
||||
uint64_t zeus::FutureCall::getTransactionId() {
|
||||
return m_transactionId;
|
||||
}
|
||||
|
||||
uint64_t jus::FutureCall::getClientId() {
|
||||
uint64_t zeus::FutureCall::getClientId() {
|
||||
return m_clientId;
|
||||
}
|
||||
|
||||
bool jus::FutureCall::isFinished() {
|
||||
bool zeus::FutureCall::isFinished() {
|
||||
return m_isFinished;
|
||||
}
|
||||
|
||||
jus::Buffer& jus::FutureCall::getRaw() {
|
||||
zeus::Buffer& zeus::FutureCall::getRaw() {
|
||||
return m_data;
|
||||
}
|
||||
|
||||
std::chrono::nanoseconds jus::FutureCall::getTransmitionTime() {
|
||||
std::chrono::nanoseconds zeus::FutureCall::getTransmitionTime() {
|
||||
return m_answerTime - m_receiveTime;
|
||||
}
|
||||
|
@ -5,19 +5,19 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <jus/FutureData.h>
|
||||
#include <zeus/FutureData.h>
|
||||
|
||||
namespace jus {
|
||||
namespace zeus {
|
||||
class FutureBase {
|
||||
public:
|
||||
ememory::SharedPtr<jus::FutureData> m_data;
|
||||
ememory::SharedPtr<zeus::FutureData> m_data;
|
||||
public:
|
||||
FutureBase(const jus::FutureBase& _base);
|
||||
FutureBase(const zeus::FutureBase& _base);
|
||||
FutureBase();
|
||||
FutureBase(uint64_t _transactionId, jus::FutureData::ObserverFinish _callback=nullptr);
|
||||
FutureBase(uint64_t _transactionId, bool _isFinished, jus::Buffer _returnData, jus::FutureData::ObserverFinish _callback=nullptr);
|
||||
jus::FutureBase operator= (const jus::FutureBase& _base);
|
||||
bool setAnswer(const jus::Buffer& _returnValue);
|
||||
FutureBase(uint64_t _transactionId, zeus::FutureData::ObserverFinish _callback=nullptr);
|
||||
FutureBase(uint64_t _transactionId, bool _isFinished, zeus::Buffer _returnData, zeus::FutureData::ObserverFinish _callback=nullptr);
|
||||
zeus::FutureBase operator= (const zeus::FutureBase& _base);
|
||||
bool setAnswer(const zeus::Buffer& _returnValue);
|
||||
void setSynchronous();
|
||||
uint64_t getTransactionId();
|
||||
bool hasError();
|
||||
@ -28,7 +28,7 @@ namespace jus {
|
||||
FutureBase& wait();
|
||||
FutureBase& waitFor(std::chrono::microseconds _delta = std::chrono::seconds(30));
|
||||
FutureBase& waitUntil(std::chrono::steady_clock::time_point _endTime);
|
||||
const jus::Buffer& getRaw();
|
||||
const zeus::Buffer& getRaw();
|
||||
std::chrono::nanoseconds getTransmitionTime();
|
||||
};
|
||||
class FutureCall {
|
||||
@ -36,18 +36,18 @@ namespace jus {
|
||||
uint64_t m_transactionId;
|
||||
uint64_t m_clientId;
|
||||
bool m_isFinished;
|
||||
jus::Buffer m_data;
|
||||
std::vector<jus::Buffer> m_dataMultiplePack;
|
||||
zeus::Buffer m_data;
|
||||
std::vector<zeus::Buffer> m_dataMultiplePack;
|
||||
std::chrono::steady_clock::time_point m_receiveTime;
|
||||
std::chrono::steady_clock::time_point m_answerTime;
|
||||
public:
|
||||
FutureCall(uint64_t _clientId, uint64_t _transactionId, jus::Buffer& _callValue);
|
||||
void appendData(jus::Buffer& _callValue);
|
||||
FutureCall(uint64_t _clientId, uint64_t _transactionId, zeus::Buffer& _callValue);
|
||||
void appendData(zeus::Buffer& _callValue);
|
||||
uint64_t getTransactionId();
|
||||
uint64_t getClientId();
|
||||
bool isFinished();
|
||||
std::chrono::nanoseconds getTransmitionTime();
|
||||
jus::Buffer& getRaw();
|
||||
zeus::Buffer& getRaw();
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -6,21 +6,21 @@
|
||||
#pragma once
|
||||
|
||||
#include <etk/types.h>
|
||||
#include <jus/Buffer.h>
|
||||
#include <zeus/Buffer.h>
|
||||
#include <functional>
|
||||
#include <ememory/memory.h>
|
||||
|
||||
|
||||
namespace jus {
|
||||
namespace zeus {
|
||||
class FutureBase;
|
||||
class FutureData {
|
||||
public:
|
||||
using ObserverFinish = std::function<bool(jus::FutureBase)>; //!< Define an Observer: function pointer
|
||||
using ObserverFinish = std::function<bool(zeus::FutureBase)>; //!< Define an Observer: function pointer
|
||||
public:
|
||||
uint64_t m_transactionId;
|
||||
bool m_isSynchronous;
|
||||
bool m_isFinished;
|
||||
jus::Buffer m_returnData;
|
||||
zeus::Buffer m_returnData;
|
||||
ObserverFinish m_callbackFinish;
|
||||
std::chrono::steady_clock::time_point m_sendTime;
|
||||
std::chrono::steady_clock::time_point m_receiveTime;
|
||||
|
@ -4,21 +4,21 @@
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <jus/GateWay.h>
|
||||
#include <jus/debug.h>
|
||||
#include <zeus/GateWay.h>
|
||||
#include <zeus/debug.h>
|
||||
#include <enet/TcpServer.h>
|
||||
|
||||
|
||||
namespace jus {
|
||||
namespace zeus {
|
||||
class TcpServerInput {
|
||||
private:
|
||||
enet::TcpServer m_interface;
|
||||
std::thread* m_thread;
|
||||
bool m_threadRunning;
|
||||
jus::GateWay* m_gateway;
|
||||
zeus::GateWay* m_gateway;
|
||||
bool m_service;
|
||||
public:
|
||||
TcpServerInput(jus::GateWay* _gateway, bool _service) :
|
||||
TcpServerInput(zeus::GateWay* _gateway, bool _service) :
|
||||
m_thread(nullptr),
|
||||
m_threadRunning(false),
|
||||
m_gateway(_gateway),
|
||||
@ -34,7 +34,7 @@ namespace jus {
|
||||
m_thread = new std::thread([&](void *){ this->threadCallback();}, nullptr);
|
||||
if (m_thread == nullptr) {
|
||||
m_threadRunning = false;
|
||||
JUS_ERROR("creating callback thread!");
|
||||
ZEUS_ERROR("creating callback thread!");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -54,7 +54,7 @@ namespace jus {
|
||||
while (m_threadRunning == true) {
|
||||
// READ section data:
|
||||
enet::Tcp data = std::move(m_interface.waitNext());
|
||||
JUS_VERBOSE("New connection");
|
||||
ZEUS_VERBOSE("New connection");
|
||||
if (m_service == true) {
|
||||
m_gateway->newService(std::move(data));
|
||||
} else {
|
||||
@ -65,46 +65,46 @@ namespace jus {
|
||||
};
|
||||
}
|
||||
|
||||
void jus::GateWay::newService(enet::Tcp _connection) {
|
||||
JUS_WARNING("New TCP connection (service)");
|
||||
ememory::SharedPtr<jus::GateWayService> tmp = std::make_shared<jus::GateWayService>(std::move(_connection), this);
|
||||
void zeus::GateWay::newService(enet::Tcp _connection) {
|
||||
ZEUS_WARNING("New TCP connection (service)");
|
||||
ememory::SharedPtr<zeus::GateWayService> tmp = std::make_shared<zeus::GateWayService>(std::move(_connection), this);
|
||||
tmp->start();
|
||||
m_serviceList.push_back(tmp);
|
||||
}
|
||||
|
||||
void jus::GateWay::newClient(enet::Tcp _connection) {
|
||||
JUS_WARNING("New TCP connection (client)");
|
||||
ememory::SharedPtr<jus::GateWayClient> tmp = std::make_shared<jus::GateWayClient>(std::move(_connection), this);
|
||||
void zeus::GateWay::newClient(enet::Tcp _connection) {
|
||||
ZEUS_WARNING("New TCP connection (client)");
|
||||
ememory::SharedPtr<zeus::GateWayClient> tmp = std::make_shared<zeus::GateWayClient>(std::move(_connection), this);
|
||||
tmp->start(m_clientUID++, m_clientUID++);
|
||||
m_clientList.push_back(tmp);
|
||||
}
|
||||
|
||||
jus::GateWay::GateWay() :
|
||||
zeus::GateWay::GateWay() :
|
||||
m_clientUID(1),
|
||||
propertyClientIp(this, "client-ip", "127.0.0.1", "Ip to listen client", &jus::GateWay::onPropertyChangeClientIp),
|
||||
propertyClientPort(this, "client-port", 1983, "Port to listen client", &jus::GateWay::onPropertyChangeClientPort),
|
||||
propertyClientMax(this, "client-max", 80, "Maximum of client at the same time", &jus::GateWay::onPropertyChangeClientMax),
|
||||
propertyServiceIp(this, "service-ip", "127.0.0.1", "Ip to listen client", &jus::GateWay::onPropertyChangeServiceIp),
|
||||
propertyServicePort(this, "service-port", 1982, "Port to listen client", &jus::GateWay::onPropertyChangeServicePort),
|
||||
propertyServiceMax(this, "service-max", 80, "Maximum of client at the same time", &jus::GateWay::onPropertyChangeServiceMax) {
|
||||
m_interfaceClientServer = std::make_shared<jus::TcpServerInput>(this, false);
|
||||
m_interfaceServiceServer = std::make_shared<jus::TcpServerInput>(this, true);
|
||||
propertyClientIp(this, "client-ip", "127.0.0.1", "Ip to listen client", &zeus::GateWay::onPropertyChangeClientIp),
|
||||
propertyClientPort(this, "client-port", 1983, "Port to listen client", &zeus::GateWay::onPropertyChangeClientPort),
|
||||
propertyClientMax(this, "client-max", 80, "Maximum of client at the same time", &zeus::GateWay::onPropertyChangeClientMax),
|
||||
propertyServiceIp(this, "service-ip", "127.0.0.1", "Ip to listen client", &zeus::GateWay::onPropertyChangeServiceIp),
|
||||
propertyServicePort(this, "service-port", 1982, "Port to listen client", &zeus::GateWay::onPropertyChangeServicePort),
|
||||
propertyServiceMax(this, "service-max", 80, "Maximum of client at the same time", &zeus::GateWay::onPropertyChangeServiceMax) {
|
||||
m_interfaceClientServer = std::make_shared<zeus::TcpServerInput>(this, false);
|
||||
m_interfaceServiceServer = std::make_shared<zeus::TcpServerInput>(this, true);
|
||||
}
|
||||
|
||||
jus::GateWay::~GateWay() {
|
||||
zeus::GateWay::~GateWay() {
|
||||
|
||||
}
|
||||
|
||||
void jus::GateWay::start() {
|
||||
void zeus::GateWay::start() {
|
||||
m_interfaceClientServer->start(*propertyClientIp, *propertyClientPort);
|
||||
m_interfaceServiceServer->start(*propertyServiceIp, *propertyServicePort);
|
||||
}
|
||||
|
||||
void jus::GateWay::stop() {
|
||||
void zeus::GateWay::stop() {
|
||||
|
||||
}
|
||||
|
||||
ememory::SharedPtr<jus::GateWayService> jus::GateWay::get(const std::string& _serviceName) {
|
||||
ememory::SharedPtr<zeus::GateWayService> zeus::GateWay::get(const std::string& _serviceName) {
|
||||
for (auto &it : m_serviceList) {
|
||||
if (it == nullptr) {
|
||||
continue;
|
||||
@ -117,7 +117,7 @@ ememory::SharedPtr<jus::GateWayService> jus::GateWay::get(const std::string& _se
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::vector<std::string> jus::GateWay::getAllServiceName() {
|
||||
std::vector<std::string> zeus::GateWay::getAllServiceName() {
|
||||
std::vector<std::string> out;
|
||||
for (auto &it : m_serviceList) {
|
||||
if (it == nullptr) {
|
||||
@ -129,7 +129,7 @@ std::vector<std::string> jus::GateWay::getAllServiceName() {
|
||||
}
|
||||
|
||||
|
||||
void jus::GateWay::answer(uint64_t _userSessionId, jus::Buffer& _data) {
|
||||
void zeus::GateWay::answer(uint64_t _userSessionId, zeus::Buffer& _data) {
|
||||
for (auto &it : m_clientList) {
|
||||
if (it == nullptr) {
|
||||
continue;
|
||||
@ -142,7 +142,7 @@ void jus::GateWay::answer(uint64_t _userSessionId, jus::Buffer& _data) {
|
||||
}
|
||||
}
|
||||
|
||||
void jus::GateWay::cleanIO() {
|
||||
void zeus::GateWay::cleanIO() {
|
||||
|
||||
auto it = m_serviceList.begin();
|
||||
while (it != m_serviceList.end()) {
|
||||
@ -173,34 +173,34 @@ void jus::GateWay::cleanIO() {
|
||||
}
|
||||
}
|
||||
|
||||
void jus::GateWay::onClientConnect(const bool& _value) {
|
||||
JUS_TODO("Client connection: " << _value);
|
||||
void zeus::GateWay::onClientConnect(const bool& _value) {
|
||||
ZEUS_TODO("Client connection: " << _value);
|
||||
}
|
||||
|
||||
void jus::GateWay::onServiceConnect(const bool& _value) {
|
||||
JUS_TODO("Service connection: " << _value);
|
||||
void zeus::GateWay::onServiceConnect(const bool& _value) {
|
||||
ZEUS_TODO("Service connection: " << _value);
|
||||
}
|
||||
|
||||
void jus::GateWay::onPropertyChangeClientIp() {
|
||||
void zeus::GateWay::onPropertyChangeClientIp() {
|
||||
|
||||
}
|
||||
|
||||
void jus::GateWay::onPropertyChangeClientPort() {
|
||||
void zeus::GateWay::onPropertyChangeClientPort() {
|
||||
|
||||
}
|
||||
|
||||
void jus::GateWay::onPropertyChangeClientMax() {
|
||||
void zeus::GateWay::onPropertyChangeClientMax() {
|
||||
|
||||
}
|
||||
|
||||
void jus::GateWay::onPropertyChangeServiceIp() {
|
||||
void zeus::GateWay::onPropertyChangeServiceIp() {
|
||||
|
||||
}
|
||||
|
||||
void jus::GateWay::onPropertyChangeServicePort() {
|
||||
void zeus::GateWay::onPropertyChangeServicePort() {
|
||||
|
||||
}
|
||||
|
||||
void jus::GateWay::onPropertyChangeServiceMax() {
|
||||
void zeus::GateWay::onPropertyChangeServiceMax() {
|
||||
|
||||
}
|
||||
|
@ -4,20 +4,20 @@
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
#pragma once
|
||||
#include <jus/GateWayService.h>
|
||||
#include <jus/GateWayClient.h>
|
||||
#include <zeus/GateWayService.h>
|
||||
#include <zeus/GateWayClient.h>
|
||||
|
||||
namespace jus {
|
||||
namespace zeus {
|
||||
class TcpServerInput;
|
||||
class GateWay : public eproperty::Interface {
|
||||
private:
|
||||
uint64_t m_clientUID;
|
||||
private:
|
||||
std::vector<ememory::SharedPtr<jus::GateWayService>> m_serviceList; //!< List of all service availlable with their specific connection interface
|
||||
std::vector<ememory::SharedPtr<jus::GateWayClient>> m_clientList; //!< List of all Client interface with their own connection
|
||||
//TODO: std::vector<jus::GateWayServer> m_ServerList; //!< List of all Server connected to this gateway
|
||||
ememory::SharedPtr<jus::TcpServerInput> m_interfaceClientServer;
|
||||
ememory::SharedPtr<jus::TcpServerInput> m_interfaceServiceServer;
|
||||
std::vector<ememory::SharedPtr<zeus::GateWayService>> m_serviceList; //!< List of all service availlable with their specific connection interface
|
||||
std::vector<ememory::SharedPtr<zeus::GateWayClient>> m_clientList; //!< List of all Client interface with their own connection
|
||||
//TODO: std::vector<zeus::GateWayServer> m_ServerList; //!< List of all Server connected to this gateway
|
||||
ememory::SharedPtr<zeus::TcpServerInput> m_interfaceClientServer;
|
||||
ememory::SharedPtr<zeus::TcpServerInput> m_interfaceServiceServer;
|
||||
public:
|
||||
eproperty::Value<std::string> propertyClientIp;
|
||||
eproperty::Value<uint16_t> propertyClientPort;
|
||||
@ -30,9 +30,9 @@ namespace jus {
|
||||
virtual ~GateWay();
|
||||
void start();
|
||||
void stop();
|
||||
ememory::SharedPtr<jus::GateWayService> get(const std::string& _serviceName);
|
||||
ememory::SharedPtr<zeus::GateWayService> get(const std::string& _serviceName);
|
||||
std::vector<std::string> getAllServiceName();
|
||||
void answer(uint64_t _userSessionId, jus::Buffer& _data);
|
||||
void answer(uint64_t _userSessionId, zeus::Buffer& _data);
|
||||
void newService(enet::Tcp _connection);
|
||||
void newClient(enet::Tcp _connection);
|
||||
void cleanIO();
|
||||
|
@ -4,43 +4,43 @@
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <jus/debug.h>
|
||||
#include <jus/GateWayClient.h>
|
||||
#include <jus/GateWay.h>
|
||||
#include <zeus/debug.h>
|
||||
#include <zeus/GateWayClient.h>
|
||||
#include <zeus/GateWay.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <jus/AbstractFunction.h>
|
||||
#include <zeus/AbstractFunction.h>
|
||||
|
||||
|
||||
static const std::string protocolError = "PROTOCOL-ERROR";
|
||||
|
||||
jus::GateWayClient::GateWayClient(enet::Tcp _connection, jus::GateWay* _gatewayInterface) :
|
||||
m_state(jus::GateWayClient::state::unconnect),
|
||||
zeus::GateWayClient::GateWayClient(enet::Tcp _connection, zeus::GateWay* _gatewayInterface) :
|
||||
m_state(zeus::GateWayClient::state::unconnect),
|
||||
m_gatewayInterface(_gatewayInterface),
|
||||
m_interfaceClient(std::move(_connection)) {
|
||||
JUS_INFO("----------------");
|
||||
JUS_INFO("-- NEW Client --");
|
||||
JUS_INFO("----------------");
|
||||
m_interfaceClient(std::move(_connection), true) {
|
||||
ZEUS_INFO("----------------");
|
||||
ZEUS_INFO("-- NEW Client --");
|
||||
ZEUS_INFO("----------------");
|
||||
}
|
||||
|
||||
jus::GateWayClient::~GateWayClient() {
|
||||
JUS_TODO("Call All unlink ...");
|
||||
zeus::GateWayClient::~GateWayClient() {
|
||||
ZEUS_TODO("Call All unlink ...");
|
||||
stop();
|
||||
JUS_INFO("-------------------");
|
||||
JUS_INFO("-- DELETE Client --");
|
||||
JUS_INFO("-------------------");
|
||||
ZEUS_INFO("-------------------");
|
||||
ZEUS_INFO("-- DELETE Client --");
|
||||
ZEUS_INFO("-------------------");
|
||||
}
|
||||
|
||||
void jus::GateWayClient::start(uint64_t _uid, uint64_t _uid2) {
|
||||
void zeus::GateWayClient::start(uint64_t _uid, uint64_t _uid2) {
|
||||
m_uid = _uid;
|
||||
m_uid2 = _uid2;
|
||||
m_state = jus::GateWayClient::state::connect;
|
||||
m_interfaceClient.connect(this, &jus::GateWayClient::onClientData);
|
||||
m_state = zeus::GateWayClient::state::connect;
|
||||
m_interfaceClient.connect(this, &zeus::GateWayClient::onClientData);
|
||||
m_interfaceClient.connect(true);
|
||||
m_interfaceClient.setInterfaceName("cli-" + etk::to_string(m_uid));
|
||||
}
|
||||
|
||||
void jus::GateWayClient::stop() {
|
||||
void zeus::GateWayClient::stop() {
|
||||
for (auto &it : m_listConnectedService) {
|
||||
if (it == nullptr) {
|
||||
continue;
|
||||
@ -55,39 +55,39 @@ void jus::GateWayClient::stop() {
|
||||
m_interfaceClient.disconnect();
|
||||
}
|
||||
|
||||
bool jus::GateWayClient::isAlive() {
|
||||
bool zeus::GateWayClient::isAlive() {
|
||||
return m_interfaceClient.isActive();
|
||||
}
|
||||
|
||||
void jus::GateWayClient::answerProtocolError(uint32_t _transactionId, const std::string& _errorHelp) {
|
||||
void zeus::GateWayClient::answerProtocolError(uint32_t _transactionId, const std::string& _errorHelp) {
|
||||
m_interfaceClient.answerError(_transactionId, protocolError, _errorHelp);
|
||||
m_state = jus::GateWayClient::state::disconnect;
|
||||
m_state = zeus::GateWayClient::state::disconnect;
|
||||
m_interfaceClient.disconnect(true);
|
||||
}
|
||||
|
||||
|
||||
void jus::GateWayClient::onClientData(jus::Buffer& _value) {
|
||||
void zeus::GateWayClient::onClientData(zeus::Buffer& _value) {
|
||||
uint32_t transactionId = _value.getTransactionId();
|
||||
if (transactionId == 0) {
|
||||
JUS_ERROR("Protocol error ==>missing id");
|
||||
ZEUS_ERROR("Protocol error ==>missing id");
|
||||
answerProtocolError(transactionId, "missing parameter: 'id'");
|
||||
return;
|
||||
}
|
||||
if (_value.getType() != jus::Buffer::typeMessage::call) {
|
||||
JUS_ERROR("Protocol error ==>missing 'call'");
|
||||
if (_value.getType() != zeus::Buffer::typeMessage::call) {
|
||||
ZEUS_ERROR("Protocol error ==>missing 'call'");
|
||||
answerProtocolError(transactionId, "missing parameter: 'call' / wrong type 'call'");
|
||||
return;
|
||||
}
|
||||
std::string callFunction = _value.getCall();
|
||||
switch (m_state) {
|
||||
case jus::GateWayClient::state::disconnect:
|
||||
case jus::GateWayClient::state::unconnect:
|
||||
case zeus::GateWayClient::state::disconnect:
|
||||
case zeus::GateWayClient::state::unconnect:
|
||||
{
|
||||
JUS_ERROR("Must never appear");
|
||||
ZEUS_ERROR("Must never appear");
|
||||
answerProtocolError(transactionId, "Gateway internal error");
|
||||
return;
|
||||
}
|
||||
case jus::GateWayClient::state::connect:
|
||||
case zeus::GateWayClient::state::connect:
|
||||
{
|
||||
if (m_userConnectionName != "") {
|
||||
answerProtocolError(transactionId, "Gateway internal error 2");
|
||||
@ -98,24 +98,24 @@ void jus::GateWayClient::onClientData(jus::Buffer& _value) {
|
||||
if (m_userConnectionName == "") {
|
||||
answerProtocolError(transactionId, "Call connectToUser with no parameter 'user'");
|
||||
} else {
|
||||
JUS_WARNING("[" << m_uid << "] Set client connect to user : '" << m_userConnectionName << "'");
|
||||
ZEUS_WARNING("[" << m_uid << "] Set client connect to user : '" << m_userConnectionName << "'");
|
||||
m_userService = m_gatewayInterface->get("system-user");
|
||||
if (m_userService == nullptr) {
|
||||
answerProtocolError(transactionId, "Gateway internal error 'No user interface'");
|
||||
} else {
|
||||
jus::Future<bool> futLocalService = m_userService->m_interfaceClient.callClient(m_uid2, "_new", m_userConnectionName, "**Gateway**", std::vector<std::string>());
|
||||
zeus::Future<bool> futLocalService = m_userService->m_interfaceClient.callClient(m_uid2, "_new", m_userConnectionName, "**Gateway**", std::vector<std::string>());
|
||||
futLocalService.wait(); // TODO: Set timeout ...
|
||||
m_state = jus::GateWayClient::state::userIdentify;
|
||||
m_state = zeus::GateWayClient::state::userIdentify;
|
||||
m_interfaceClient.answerValue(transactionId, true);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
JUS_WARNING("[" << m_uid << "] Client must send conection to user name ...");
|
||||
ZEUS_WARNING("[" << m_uid << "] Client must send conection to user name ...");
|
||||
answerProtocolError(transactionId, "Missing call of connectToUser");
|
||||
return;
|
||||
}
|
||||
case jus::GateWayClient::state::userIdentify:
|
||||
case zeus::GateWayClient::state::userIdentify:
|
||||
{
|
||||
m_clientServices.clear();
|
||||
m_clientgroups.clear();
|
||||
@ -134,10 +134,10 @@ void jus::GateWayClient::onClientData(jus::Buffer& _value) {
|
||||
return;
|
||||
}
|
||||
|
||||
jus::Future<bool> fut = m_userService->m_interfaceClient.callClient(m_uid2, "checkTocken", clientName, clientTocken);
|
||||
zeus::Future<bool> fut = m_userService->m_interfaceClient.callClient(m_uid2, "checkTocken", clientName, clientTocken);
|
||||
fut.wait(); // TODO: Set timeout ...
|
||||
if (fut.hasError() == true) {
|
||||
JUS_ERROR("Get error from the service ...");
|
||||
ZEUS_ERROR("Get error from the service ...");
|
||||
m_interfaceClient.answerValue(transactionId, false);
|
||||
answerProtocolError(transactionId, "connection refused 1");
|
||||
return;
|
||||
@ -150,10 +150,10 @@ void jus::GateWayClient::onClientData(jus::Buffer& _value) {
|
||||
}
|
||||
if (callFunction == "auth") {
|
||||
std::string password = _value.getParameter<std::string>(0);
|
||||
jus::Future<bool> fut = m_userService->m_interfaceClient.callClient(m_uid2, "checkAuth", password);
|
||||
zeus::Future<bool> fut = m_userService->m_interfaceClient.callClient(m_uid2, "checkAuth", password);
|
||||
fut.wait(); // TODO: Set timeout ...
|
||||
if (fut.hasError() == true) {
|
||||
JUS_ERROR("Get error from the service ...");
|
||||
ZEUS_ERROR("Get error from the service ...");
|
||||
m_interfaceClient.answerValue(transactionId, false);
|
||||
answerProtocolError(transactionId, "connection refused 1");
|
||||
return;
|
||||
@ -170,10 +170,10 @@ void jus::GateWayClient::onClientData(jus::Buffer& _value) {
|
||||
// --------------------------------
|
||||
// -- Get groups:
|
||||
// --------------------------------
|
||||
jus::Future<std::vector<std::string>> futGroup = m_userService->m_interfaceClient.callClient(m_uid2, "getGroups", m_clientName);
|
||||
zeus::Future<std::vector<std::string>> futGroup = m_userService->m_interfaceClient.callClient(m_uid2, "getGroups", m_clientName);
|
||||
futGroup.wait(); // TODO: Set timeout ...
|
||||
if (futGroup.hasError() == true) {
|
||||
JUS_ERROR("Get error from the service ...");
|
||||
ZEUS_ERROR("Get error from the service ...");
|
||||
m_interfaceClient.answerValue(transactionId, false);
|
||||
answerProtocolError(transactionId, "grouping error");
|
||||
return;
|
||||
@ -183,26 +183,26 @@ void jus::GateWayClient::onClientData(jus::Buffer& _value) {
|
||||
// -- Get services:
|
||||
// --------------------------------
|
||||
std::vector<std::string> currentServices = m_gatewayInterface->getAllServiceName();
|
||||
jus::Future<std::vector<std::string>> futServices = m_userService->m_interfaceClient.callClient(m_uid2, "filterServices", m_clientName, currentServices);
|
||||
zeus::Future<std::vector<std::string>> futServices = m_userService->m_interfaceClient.callClient(m_uid2, "filterServices", m_clientName, currentServices);
|
||||
futServices.wait(); // TODO: Set timeout ...
|
||||
if (futServices.hasError() == true) {
|
||||
JUS_ERROR("Get error from the service ...");
|
||||
ZEUS_ERROR("Get error from the service ...");
|
||||
m_interfaceClient.answerValue(transactionId, false);
|
||||
answerProtocolError(transactionId, "service filtering error");
|
||||
return;
|
||||
}
|
||||
m_clientServices = futServices.get();
|
||||
JUS_WARNING("Connection of: '" << m_clientName << "' to '" << m_userConnectionName << "'");
|
||||
JUS_WARNING(" groups: " << etk::to_string(m_clientgroups));
|
||||
JUS_WARNING(" services: " << etk::to_string(m_clientServices));
|
||||
ZEUS_WARNING("Connection of: '" << m_clientName << "' to '" << m_userConnectionName << "'");
|
||||
ZEUS_WARNING(" groups: " << etk::to_string(m_clientgroups));
|
||||
ZEUS_WARNING(" services: " << etk::to_string(m_clientServices));
|
||||
|
||||
|
||||
m_interfaceClient.answerValue(transactionId, true);
|
||||
m_state = jus::GateWayClient::state::clientIdentify;
|
||||
m_state = zeus::GateWayClient::state::clientIdentify;
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case jus::GateWayClient::state::clientIdentify:
|
||||
case zeus::GateWayClient::state::clientIdentify:
|
||||
{
|
||||
uint32_t serviceId = _value.getServiceId();
|
||||
if (serviceId == 0) {
|
||||
@ -238,12 +238,12 @@ void jus::GateWayClient::onClientData(jus::Buffer& _value) {
|
||||
m_interfaceClient.answerError(transactionId, "UN-AUTHORIZED-SERVICE");
|
||||
return;
|
||||
}
|
||||
ememory::SharedPtr<jus::GateWayService> srv = m_gatewayInterface->get(serviceName);
|
||||
ememory::SharedPtr<zeus::GateWayService> srv = m_gatewayInterface->get(serviceName);
|
||||
if (srv != nullptr) {
|
||||
jus::Future<bool> futLink = srv->m_interfaceClient.callClient(m_uid, "_new", m_userConnectionName, m_clientName, m_clientgroups);
|
||||
zeus::Future<bool> futLink = srv->m_interfaceClient.callClient(m_uid, "_new", m_userConnectionName, m_clientName, m_clientgroups);
|
||||
futLink.wait(); // TODO: Set timeout ...
|
||||
if (futLink.hasError() == true) {
|
||||
JUS_ERROR("Get error from the service ... LINK");
|
||||
ZEUS_ERROR("Get error from the service ... LINK");
|
||||
m_interfaceClient.answerError(transactionId, "ERROR-CREATE-SERVICE-INSTANCE");
|
||||
return;
|
||||
}
|
||||
@ -265,10 +265,10 @@ void jus::GateWayClient::onClientData(jus::Buffer& _value) {
|
||||
m_interfaceClient.answerError(transactionId, "NOT-CONNECTED-SERVICE");
|
||||
return;
|
||||
}
|
||||
jus::Future<bool> futUnLink = m_listConnectedService[localServiceID]->m_interfaceClient.callClient(m_uid, "_delete");
|
||||
zeus::Future<bool> futUnLink = m_listConnectedService[localServiceID]->m_interfaceClient.callClient(m_uid, "_delete");
|
||||
futUnLink.wait(); // TODO: Set timeout ...
|
||||
if (futUnLink.hasError() == true) {
|
||||
JUS_ERROR("Get error from the service ... UNLINK");
|
||||
ZEUS_ERROR("Get error from the service ... UNLINK");
|
||||
m_interfaceClient.answerError(transactionId, "ERROR-CREATE-SERVICE-INSTANCE");
|
||||
return;
|
||||
}
|
||||
@ -276,7 +276,7 @@ void jus::GateWayClient::onClientData(jus::Buffer& _value) {
|
||||
m_interfaceClient.answerValue(transactionId, true);
|
||||
return;
|
||||
}
|
||||
JUS_ERROR("Function does not exist ... '" << callFunction << "'");
|
||||
ZEUS_ERROR("Function does not exist ... '" << callFunction << "'");
|
||||
m_interfaceClient.answerError(transactionId, "CALL-UNEXISTING");
|
||||
return;
|
||||
}
|
||||
@ -288,7 +288,7 @@ void jus::GateWayClient::onClientData(jus::Buffer& _value) {
|
||||
} else {
|
||||
if (m_listConnectedService[serviceId] == nullptr) {
|
||||
// TODO ...
|
||||
JUS_ERROR("TODO : Manage this case ...");
|
||||
ZEUS_ERROR("TODO : Manage this case ...");
|
||||
return;
|
||||
}
|
||||
uint16_t partId = _value.getPartId();
|
||||
@ -303,13 +303,13 @@ void jus::GateWayClient::onClientData(jus::Buffer& _value) {
|
||||
m_uid,
|
||||
_value,
|
||||
(uint64_t(m_uid) << 32) + uint64_t(transactionId),
|
||||
[=](jus::FutureBase _ret) {
|
||||
jus::Buffer tmpp = _ret.getRaw();
|
||||
JUS_DEBUG(" ==> transmit : " << tmpp.getTransactionId() << " -> " << transactionId);
|
||||
JUS_DEBUG(" msg=" << tmpp.generateHumanString());
|
||||
[=](zeus::FutureBase _ret) {
|
||||
zeus::Buffer tmpp = _ret.getRaw();
|
||||
ZEUS_DEBUG(" ==> transmit : " << tmpp.getTransactionId() << " -> " << transactionId);
|
||||
ZEUS_DEBUG(" msg=" << tmpp.generateHumanString());
|
||||
tmpp.setTransactionId(transactionId);
|
||||
tmpp.setServiceId(serviceId+1);
|
||||
JUS_DEBUG("transmit=" << tmpp.generateHumanString());
|
||||
ZEUS_DEBUG("transmit=" << tmpp.generateHumanString());
|
||||
m_interfaceClient.writeBinary(tmpp);
|
||||
// multiple send element ...
|
||||
return tmpp.getPartFinish();
|
||||
@ -319,6 +319,6 @@ void jus::GateWayClient::onClientData(jus::Buffer& _value) {
|
||||
}
|
||||
}
|
||||
|
||||
void jus::GateWayClient::returnMessage(jus::Buffer& _data) {
|
||||
JUS_ERROR("Get call from the Service to the user ...");
|
||||
void zeus::GateWayClient::returnMessage(zeus::Buffer& _data) {
|
||||
ZEUS_ERROR("Get call from the Service to the user ...");
|
||||
}
|
@ -5,34 +5,34 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <jus/TcpString.h>
|
||||
#include <zeus/TcpString.h>
|
||||
#include <ememory/memory.h>
|
||||
#include <esignal/Signal.h>
|
||||
#include <jus/GateWayService.h>
|
||||
#include <jus/Future.h>
|
||||
#include <jus/AbstractFunction.h>
|
||||
#include <zeus/GateWayService.h>
|
||||
#include <zeus/Future.h>
|
||||
#include <zeus/AbstractFunction.h>
|
||||
|
||||
|
||||
|
||||
namespace jus {
|
||||
namespace zeus {
|
||||
class GateWay;
|
||||
class GateWayClient {
|
||||
private:
|
||||
enum class state {
|
||||
unconnect, // starting sate
|
||||
connect, // just get a TCP connection
|
||||
connect, // zeust get a TCP connection
|
||||
userIdentify, // client set the user it want to access
|
||||
clientIdentify, // client defien the mode of the acces (anonymous,client/user)
|
||||
disconnect // client is dead or loal disconnection
|
||||
};
|
||||
enum state m_state; // state machine ...
|
||||
private:
|
||||
jus::GateWay* m_gatewayInterface;
|
||||
jus::TcpString m_interfaceClient;
|
||||
zeus::GateWay* m_gatewayInterface;
|
||||
zeus::TcpString m_interfaceClient;
|
||||
public:
|
||||
esignal::Signal<bool> signalIsConnected;
|
||||
ememory::SharedPtr<jus::GateWayService> m_userService;
|
||||
std::vector<ememory::SharedPtr<jus::GateWayService>> m_listConnectedService;
|
||||
ememory::SharedPtr<zeus::GateWayService> m_userService;
|
||||
std::vector<ememory::SharedPtr<zeus::GateWayService>> m_listConnectedService;
|
||||
uint64_t m_uid;
|
||||
uint64_t m_uid2;
|
||||
std::string m_userConnectionName;
|
||||
@ -40,12 +40,12 @@ namespace jus {
|
||||
std::vector<std::string> m_clientgroups;
|
||||
std::vector<std::string> m_clientServices;
|
||||
public:
|
||||
GateWayClient(enet::Tcp _connection, jus::GateWay* _gatewayInterface);
|
||||
GateWayClient(enet::Tcp _connection, zeus::GateWay* _gatewayInterface);
|
||||
virtual ~GateWayClient();
|
||||
void start(uint64_t _uid, uint64_t _uid2);
|
||||
void stop();
|
||||
void onClientData(jus::Buffer& _value);
|
||||
void returnMessage(jus::Buffer& _data);
|
||||
void onClientData(zeus::Buffer& _value);
|
||||
void returnMessage(zeus::Buffer& _data);
|
||||
bool checkId(uint64_t _id) const {
|
||||
return m_uid == _id
|
||||
|| m_uid2 == _id;
|
||||
|
@ -4,79 +4,79 @@
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <jus/debug.h>
|
||||
#include <jus/GateWayService.h>
|
||||
#include <jus/GateWay.h>
|
||||
#include <zeus/debug.h>
|
||||
#include <zeus/GateWayService.h>
|
||||
#include <zeus/GateWay.h>
|
||||
|
||||
// todo : cHANGE THIS ...
|
||||
static const std::string protocolError = "PROTOCOL-ERROR";
|
||||
|
||||
|
||||
|
||||
jus::GateWayService::GateWayService(enet::Tcp _connection, jus::GateWay* _gatewayInterface) :
|
||||
zeus::GateWayService::GateWayService(enet::Tcp _connection, zeus::GateWay* _gatewayInterface) :
|
||||
m_gatewayInterface(_gatewayInterface),
|
||||
m_interfaceClient(std::move(_connection)) {
|
||||
JUS_INFO("-----------------");
|
||||
JUS_INFO("-- NEW Service --");
|
||||
JUS_INFO("-----------------");
|
||||
m_interfaceClient(std::move(_connection), true) {
|
||||
ZEUS_INFO("-----------------");
|
||||
ZEUS_INFO("-- NEW Service --");
|
||||
ZEUS_INFO("-----------------");
|
||||
}
|
||||
|
||||
jus::GateWayService::~GateWayService() {
|
||||
zeus::GateWayService::~GateWayService() {
|
||||
|
||||
JUS_INFO("--------------------");
|
||||
JUS_INFO("-- DELETE Service --");
|
||||
JUS_INFO("--------------------");
|
||||
ZEUS_INFO("--------------------");
|
||||
ZEUS_INFO("-- DELETE Service --");
|
||||
ZEUS_INFO("--------------------");
|
||||
}
|
||||
|
||||
bool jus::GateWayService::isAlive() {
|
||||
bool zeus::GateWayService::isAlive() {
|
||||
return m_interfaceClient.isActive();
|
||||
}
|
||||
|
||||
void jus::GateWayService::start() {
|
||||
m_interfaceClient.connect(this, &jus::GateWayService::onServiceData);
|
||||
void zeus::GateWayService::start() {
|
||||
m_interfaceClient.connect(this, &zeus::GateWayService::onServiceData);
|
||||
m_interfaceClient.connect();
|
||||
m_interfaceClient.setInterfaceName("srv-?");
|
||||
}
|
||||
|
||||
void jus::GateWayService::stop() {
|
||||
void zeus::GateWayService::stop() {
|
||||
m_interfaceClient.disconnect();
|
||||
}
|
||||
|
||||
|
||||
void jus::GateWayService::SendData(uint64_t _userSessionId, jus::Buffer& _data) {
|
||||
void zeus::GateWayService::SendData(uint64_t _userSessionId, zeus::Buffer& _data) {
|
||||
_data.setClientId(_userSessionId);
|
||||
_data.prepare();
|
||||
m_interfaceClient.writeBinary(_data);
|
||||
}
|
||||
|
||||
void jus::GateWayService::onServiceData(jus::Buffer& _value) {
|
||||
JUS_DEBUG("On service data: " << _value.generateHumanString());
|
||||
void zeus::GateWayService::onServiceData(zeus::Buffer& _value) {
|
||||
ZEUS_DEBUG("On service data: " << _value.generateHumanString());
|
||||
uint32_t transactionId = _value.getTransactionId();
|
||||
//data.add("from-service", ejson::String(m_name));
|
||||
if (_value.getType() == jus::Buffer::typeMessage::event) {
|
||||
if (_value.getType() == zeus::Buffer::typeMessage::event) {
|
||||
/*
|
||||
if (data.valueExist("event") == true) {
|
||||
// No need to have a user ID ...
|
||||
if (data["event"].toString().get() == "IS-ALIVE") {
|
||||
JUS_VERBOSE("Service Alive ...");
|
||||
ZEUS_VERBOSE("Service Alive ...");
|
||||
if (std::chrono::steady_clock::now() - m_interfaceClient.getLastTimeSend() >= std::chrono::seconds(20)) {
|
||||
ejson::Object tmpp;
|
||||
tmpp.add("event", ejson::String("IS-ALIVE"));
|
||||
m_interfaceClient.writeJson(tmpp);
|
||||
}
|
||||
} else {
|
||||
JUS_INFO("Unknow service event: '" << data["event"].toString().get() << "'");
|
||||
ZEUS_INFO("Unknow service event: '" << data["event"].toString().get() << "'");
|
||||
}
|
||||
return;
|
||||
}
|
||||
*/
|
||||
return;
|
||||
}
|
||||
if (_value.getType() == jus::Buffer::typeMessage::call) {
|
||||
if (_value.getType() == zeus::Buffer::typeMessage::call) {
|
||||
std::string callFunction = _value.getCall();
|
||||
if (callFunction == "connect-service") {
|
||||
if (m_name != "") {
|
||||
JUS_WARNING("Service interface ==> try change the servie name after init: '" << _value.getParameter<std::string>(0));
|
||||
ZEUS_WARNING("Service interface ==> try change the servie name after init: '" << _value.getParameter<std::string>(0));
|
||||
m_interfaceClient.answerValue(transactionId, false);
|
||||
return;
|
||||
}
|
||||
@ -88,14 +88,14 @@ void jus::GateWayService::onServiceData(jus::Buffer& _value) {
|
||||
answerProtocolError(transactionId, "unknow function");
|
||||
}
|
||||
if (_value.getClientId() == 0) {
|
||||
JUS_ERROR("Service interface ==> wrong service answer ==> missing 'client-id'");
|
||||
ZEUS_ERROR("Service interface ==> wrong service answer ==> missing 'client-id'");
|
||||
return;
|
||||
}
|
||||
m_gatewayInterface->answer(_value.getClientId(), _value);
|
||||
}
|
||||
|
||||
|
||||
void jus::GateWayService::answerProtocolError(uint32_t _transactionId, const std::string& _errorHelp) {
|
||||
void zeus::GateWayService::answerProtocolError(uint32_t _transactionId, const std::string& _errorHelp) {
|
||||
m_interfaceClient.answerError(_transactionId, protocolError, _errorHelp);
|
||||
m_interfaceClient.disconnect(true);
|
||||
}
|
@ -5,29 +5,29 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <jus/TcpString.h>
|
||||
#include <zeus/TcpString.h>
|
||||
#include <ememory/memory.h>
|
||||
#include <esignal/Signal.h>
|
||||
|
||||
namespace jus {
|
||||
namespace zeus {
|
||||
class GateWay;
|
||||
class GateWayClient;
|
||||
class GateWayService {
|
||||
friend class jus::GateWayClient;
|
||||
friend class zeus::GateWayClient;
|
||||
private:
|
||||
jus::GateWay* m_gatewayInterface;
|
||||
jus::TcpString m_interfaceClient;
|
||||
zeus::GateWay* m_gatewayInterface;
|
||||
zeus::TcpString m_interfaceClient;
|
||||
std::string m_name;
|
||||
public:
|
||||
esignal::Signal<bool> signalIsConnected;
|
||||
public:
|
||||
GateWayService(enet::Tcp _connection, jus::GateWay* _gatewayInterface);
|
||||
GateWayService(enet::Tcp _connection, zeus::GateWay* _gatewayInterface);
|
||||
virtual ~GateWayService();
|
||||
void start();
|
||||
void stop();
|
||||
void onServiceData(jus::Buffer& _value);
|
||||
void onServiceData(zeus::Buffer& _value);
|
||||
public:
|
||||
void SendData(uint64_t _userSessionId, jus::Buffer& _data);
|
||||
void SendData(uint64_t _userSessionId, zeus::Buffer& _data);
|
||||
const std::string& getName() {
|
||||
return m_name;
|
||||
}
|
||||
|
@ -4,35 +4,35 @@
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <jus/ParamType.h>
|
||||
#include <jus/debug.h>
|
||||
#include <jus/File.h>
|
||||
#include <zeus/ParamType.h>
|
||||
#include <zeus/debug.h>
|
||||
#include <zeus/File.h>
|
||||
|
||||
|
||||
jus::ParamType::ParamType(const char* _name):
|
||||
zeus::ParamType::ParamType(const char* _name):
|
||||
m_typeName(_name) {
|
||||
|
||||
}
|
||||
|
||||
const char* jus::ParamType::getName() const {
|
||||
const char* zeus::ParamType::getName() const {
|
||||
return m_typeName;
|
||||
}
|
||||
|
||||
bool jus::ParamType::operator == (const ParamType& _obj) const {
|
||||
bool zeus::ParamType::operator == (const ParamType& _obj) const {
|
||||
return m_typeName == _obj.m_typeName;
|
||||
}
|
||||
|
||||
bool jus::ParamType::operator == (const std::string& _value) const {
|
||||
bool zeus::ParamType::operator == (const std::string& _value) const {
|
||||
return _value == m_typeName;
|
||||
}
|
||||
bool jus::ParamType::operator != (const std::string& _value) const {
|
||||
bool zeus::ParamType::operator != (const std::string& _value) const {
|
||||
return _value != m_typeName;
|
||||
}
|
||||
|
||||
#define generate_basic_type(_type, _name) \
|
||||
namespace jus { \
|
||||
template<> jus::ParamType createType<_type>() {\
|
||||
return jus::ParamType(_name); \
|
||||
namespace zeus { \
|
||||
template<> zeus::ParamType createType<_type>() {\
|
||||
return zeus::ParamType(_name); \
|
||||
} \
|
||||
}
|
||||
|
||||
@ -65,7 +65,7 @@ generate_basic_type(std::vector<uint8_t>, "vector:uint8");
|
||||
generate_basic_type(std::vector<std::string>, "vector:string");
|
||||
|
||||
|
||||
generate_basic_type(jus::File, "file");
|
||||
generate_basic_type(jus::FileServer, "file");
|
||||
generate_basic_type(zeus::File, "file");
|
||||
generate_basic_type(zeus::FileServer, "file");
|
||||
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace jus {
|
||||
namespace zeus {
|
||||
class ParamType {
|
||||
protected:
|
||||
const char* m_typeName;
|
||||
@ -20,7 +20,7 @@ namespace jus {
|
||||
};
|
||||
|
||||
|
||||
template<class JUS_TYPE>
|
||||
template<class ZEUS_TYPE>
|
||||
ParamType createType();
|
||||
}
|
||||
|
||||
|
@ -3,72 +3,72 @@
|
||||
* @copyright 2016, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
#include <jus/RemoteProcessCall.h>
|
||||
#include <zeus/RemoteProcessCall.h>
|
||||
|
||||
jus::RemoteProcessCall::RemoteProcessCall() :
|
||||
zeus::RemoteProcessCall::RemoteProcessCall() :
|
||||
m_type("UNKNOW"){
|
||||
advertise("getDescription", &jus::RemoteProcessCall::getDescription);
|
||||
advertise("getDescription", &zeus::RemoteProcessCall::getDescription);
|
||||
setLastFuncDesc("Get description");
|
||||
addLastFuncReturn("String version of the service number separate with dot with -dev at the end if developpement version, and '-number' or integration version uipdate : 1.5.2 or 1.8-dev 1.5.2-55");
|
||||
|
||||
advertise("getVersion", &jus::RemoteProcessCall::getVersion);
|
||||
advertise("getVersion", &zeus::RemoteProcessCall::getVersion);
|
||||
setLastFuncDesc("Get version");
|
||||
addLastFuncReturn("String version of the service number separate with dot with -dev at the end if developpement version, and '-number' or integration version uipdate : 1.5.2 or 1.8-dev 1.5.2-55");
|
||||
|
||||
advertise("getType", &jus::RemoteProcessCall::getType);
|
||||
advertise("getType", &zeus::RemoteProcessCall::getType);
|
||||
setLastFuncDesc("Get type");
|
||||
addLastFuncReturn("String of generic type of the service base on TYPE-ENTERPRISE.ENTERPRISE-NAME.SERVICE-TYPE/VERSION_PROTOCOL");
|
||||
|
||||
advertise("getAuthors", &jus::RemoteProcessCall::getAuthors2);
|
||||
advertise("getAuthors", &zeus::RemoteProcessCall::getAuthors2);
|
||||
setLastFuncDesc("Get List of developper/maintainer");
|
||||
addLastFuncReturn("list of personnes: 'NAME surname <email@xxx.yyy>'");
|
||||
|
||||
advertise("getFunctions", &jus::RemoteProcessCall::getFunctions);
|
||||
advertise("getFunctions", &zeus::RemoteProcessCall::getFunctions);
|
||||
setLastFuncDesc("Get List of function availlable (filter with right)");
|
||||
addLastFuncReturn("list of function name");
|
||||
|
||||
advertise("getFunctionSignature", &jus::RemoteProcessCall::getFunctionSignature);
|
||||
advertise("getFunctionSignature", &zeus::RemoteProcessCall::getFunctionSignature);
|
||||
addLastFuncParam("func", "function name");
|
||||
setLastFuncDesc("Get List type of return and after the parameters");
|
||||
addLastFuncReturn("list of element type");
|
||||
|
||||
advertise("getFunctionPrototype", &jus::RemoteProcessCall::getFunctionPrototype);
|
||||
advertise("getFunctionPrototype", &zeus::RemoteProcessCall::getFunctionPrototype);
|
||||
addLastFuncParam("func", "function name");
|
||||
setLastFuncDesc("Get List type of return and after the parameters");
|
||||
addLastFuncReturn("list of element type");
|
||||
|
||||
advertise("getFunctionDescription", &jus::RemoteProcessCall::getFunctionDescription);
|
||||
advertise("getFunctionDescription", &zeus::RemoteProcessCall::getFunctionDescription);
|
||||
addLastFuncParam("func", "function name");
|
||||
setLastFuncDesc("get function description");
|
||||
addLastFuncReturn("generic string");
|
||||
}
|
||||
|
||||
|
||||
void jus::RemoteProcessCall::setDescription(const std::string& _desc) {
|
||||
void zeus::RemoteProcessCall::setDescription(const std::string& _desc) {
|
||||
m_description = _desc;
|
||||
}
|
||||
|
||||
std::string jus::RemoteProcessCall::getDescription() {
|
||||
std::string zeus::RemoteProcessCall::getDescription() {
|
||||
return m_description;
|
||||
}
|
||||
|
||||
void jus::RemoteProcessCall::setVersion(const std::string& _desc) {
|
||||
void zeus::RemoteProcessCall::setVersion(const std::string& _desc) {
|
||||
m_version = _desc;
|
||||
}
|
||||
|
||||
std::string jus::RemoteProcessCall::getVersion() {
|
||||
std::string zeus::RemoteProcessCall::getVersion() {
|
||||
return m_version;
|
||||
}
|
||||
|
||||
void jus::RemoteProcessCall::addAuthor(const std::string& _name, const std::string& _email) {
|
||||
void zeus::RemoteProcessCall::addAuthor(const std::string& _name, const std::string& _email) {
|
||||
m_authors.push_back(std::make_pair(_name, _email));
|
||||
}
|
||||
|
||||
const std::vector<std::pair<std::string,std::string>>& jus::RemoteProcessCall::getAuthors() const {
|
||||
const std::vector<std::pair<std::string,std::string>>& zeus::RemoteProcessCall::getAuthors() const {
|
||||
return m_authors;
|
||||
}
|
||||
|
||||
std::vector<std::string> jus::RemoteProcessCall::getAuthors2() {
|
||||
std::vector<std::string> zeus::RemoteProcessCall::getAuthors2() {
|
||||
std::vector<std::string> out;
|
||||
for (auto &it : m_authors) {
|
||||
out.push_back(it.first + "<" + it.second + ">");
|
||||
@ -76,19 +76,19 @@ std::vector<std::string> jus::RemoteProcessCall::getAuthors2() {
|
||||
return out;
|
||||
}
|
||||
|
||||
void jus::RemoteProcessCall::setLastFuncDesc(const std::string& _desc) {
|
||||
void zeus::RemoteProcessCall::setLastFuncDesc(const std::string& _desc) {
|
||||
if (m_listFunction.size() == 0) {
|
||||
JUS_ERROR("Can not set description to a function with no function advertise before ...");
|
||||
ZEUS_ERROR("Can not set description to a function with no function advertise before ...");
|
||||
return;
|
||||
}
|
||||
if (m_listFunction[m_listFunction.size()-1] == nullptr) {
|
||||
JUS_ERROR("Last element is nullptr ... ==> what are you doing??");
|
||||
ZEUS_ERROR("Last element is nullptr ... ==> what are you doing??");
|
||||
return;
|
||||
}
|
||||
m_listFunction[m_listFunction.size()-1]->setDescription(_desc);
|
||||
}
|
||||
|
||||
void jus::RemoteProcessCall::setFuncDesc(const std::string& _funcName, const std::string& _desc) {
|
||||
void zeus::RemoteProcessCall::setFuncDesc(const std::string& _funcName, const std::string& _desc) {
|
||||
for (auto &it : m_listFunction) {
|
||||
if (it == nullptr) {
|
||||
continue;
|
||||
@ -99,22 +99,22 @@ void jus::RemoteProcessCall::setFuncDesc(const std::string& _funcName, const std
|
||||
it->setDescription(_desc);
|
||||
return;
|
||||
}
|
||||
JUS_ERROR("function '" << _funcName << "' des not exist");
|
||||
ZEUS_ERROR("function '" << _funcName << "' des not exist");
|
||||
}
|
||||
|
||||
void jus::RemoteProcessCall::addLastFuncParam(const std::string& _name, const std::string& _desc) {
|
||||
void zeus::RemoteProcessCall::addLastFuncParam(const std::string& _name, const std::string& _desc) {
|
||||
if (m_listFunction.size() == 0) {
|
||||
JUS_ERROR("Can not set description to a function with no function advertise before ...");
|
||||
ZEUS_ERROR("Can not set description to a function with no function advertise before ...");
|
||||
return;
|
||||
}
|
||||
if (m_listFunction[m_listFunction.size()-1] == nullptr) {
|
||||
JUS_ERROR("Last element is nullptr ... ==> what are you doing??");
|
||||
ZEUS_ERROR("Last element is nullptr ... ==> what are you doing??");
|
||||
return;
|
||||
}
|
||||
m_listFunction[m_listFunction.size()-1]->addParam(_name, _desc);
|
||||
}
|
||||
|
||||
void jus::RemoteProcessCall::setFuncParam(const std::string& _funcName, int32_t _idParam, const std::string& _name, const std::string& _desc) {
|
||||
void zeus::RemoteProcessCall::setFuncParam(const std::string& _funcName, int32_t _idParam, const std::string& _name, const std::string& _desc) {
|
||||
for (auto &it : m_listFunction) {
|
||||
if (it == nullptr) {
|
||||
continue;
|
||||
@ -125,22 +125,22 @@ void jus::RemoteProcessCall::setFuncParam(const std::string& _funcName, int32_t
|
||||
it->setParam(_idParam, _name, _desc);
|
||||
return;
|
||||
}
|
||||
JUS_ERROR("function '" << _funcName << "' des not exist");
|
||||
ZEUS_ERROR("function '" << _funcName << "' des not exist");
|
||||
}
|
||||
|
||||
void jus::RemoteProcessCall::addLastFuncReturn(const std::string& _desc) {
|
||||
void zeus::RemoteProcessCall::addLastFuncReturn(const std::string& _desc) {
|
||||
if (m_listFunction.size() == 0) {
|
||||
JUS_ERROR("Can not set return to a function with no function advertise before ...");
|
||||
ZEUS_ERROR("Can not set return to a function with no function advertise before ...");
|
||||
return;
|
||||
}
|
||||
if (m_listFunction[m_listFunction.size()-1] == nullptr) {
|
||||
JUS_ERROR("Last element is nullptr ... ==> what are you doing??");
|
||||
ZEUS_ERROR("Last element is nullptr ... ==> what are you doing??");
|
||||
return;
|
||||
}
|
||||
m_listFunction[m_listFunction.size()-1]->setReturn(_desc);
|
||||
}
|
||||
|
||||
void jus::RemoteProcessCall::setFuncReturn(const std::string& _funcName, const std::string& _desc) {
|
||||
void zeus::RemoteProcessCall::setFuncReturn(const std::string& _funcName, const std::string& _desc) {
|
||||
for (auto &it : m_listFunction) {
|
||||
if (it == nullptr) {
|
||||
continue;
|
||||
@ -151,19 +151,19 @@ void jus::RemoteProcessCall::setFuncReturn(const std::string& _funcName, const s
|
||||
it->setReturn(_desc);
|
||||
return;
|
||||
}
|
||||
JUS_ERROR("function '" << _funcName << "' des not exist");
|
||||
ZEUS_ERROR("function '" << _funcName << "' des not exist");
|
||||
}
|
||||
|
||||
|
||||
std::string jus::RemoteProcessCall::getType() {
|
||||
std::string zeus::RemoteProcessCall::getType() {
|
||||
return m_type;
|
||||
}
|
||||
void jus::RemoteProcessCall::setType(const std::string& _type, uint16_t _version) {
|
||||
void zeus::RemoteProcessCall::setType(const std::string& _type, uint16_t _version) {
|
||||
m_type = _type + "/" + etk::to_string(_version);
|
||||
}
|
||||
|
||||
|
||||
std::vector<std::string> jus::RemoteProcessCall::getFunctions() {
|
||||
std::vector<std::string> zeus::RemoteProcessCall::getFunctions() {
|
||||
std::vector<std::string> out;
|
||||
for (auto &it: m_listFunction) {
|
||||
if (it == nullptr) {
|
||||
@ -179,7 +179,7 @@ std::vector<std::string> jus::RemoteProcessCall::getFunctions() {
|
||||
return out;
|
||||
}
|
||||
|
||||
std::vector<std::string> jus::RemoteProcessCall::getFunctionSignature(std::string _funcName) {
|
||||
std::vector<std::string> zeus::RemoteProcessCall::getFunctionSignature(std::string _funcName) {
|
||||
/*
|
||||
if (isFunctionAuthorized(_funcName) == false) {
|
||||
return std::vector<std::string>();
|
||||
@ -200,7 +200,7 @@ std::vector<std::string> jus::RemoteProcessCall::getFunctionSignature(std::strin
|
||||
return std::vector<std::string>();
|
||||
}
|
||||
|
||||
std::string jus::RemoteProcessCall::getFunctionPrototype(std::string _funcName) {
|
||||
std::string zeus::RemoteProcessCall::getFunctionPrototype(std::string _funcName) {
|
||||
/*
|
||||
if (isFunctionAuthorized(_funcName) == false) {
|
||||
return "";
|
||||
@ -218,7 +218,7 @@ std::string jus::RemoteProcessCall::getFunctionPrototype(std::string _funcName)
|
||||
return "";
|
||||
}
|
||||
|
||||
std::string jus::RemoteProcessCall::getFunctionDescription(std::string _funcName) {
|
||||
std::string zeus::RemoteProcessCall::getFunctionDescription(std::string _funcName) {
|
||||
/*
|
||||
if (isFunctionAuthorized(_funcName) == false) {
|
||||
return std::string("UNKNOW Function: ") + _funcName;
|
||||
@ -237,6 +237,6 @@ std::string jus::RemoteProcessCall::getFunctionDescription(std::string _funcName
|
||||
|
||||
}
|
||||
|
||||
bool jus::RemoteProcessCall::isFunctionAuthorized(uint64_t _clientSessionID, const std::string& _funcName) {
|
||||
bool zeus::RemoteProcessCall::isFunctionAuthorized(uint64_t _clientSessionID, const std::string& _funcName) {
|
||||
return true;
|
||||
}
|
||||
|
@ -5,18 +5,18 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <jus/TcpString.h>
|
||||
#include <zeus/TcpString.h>
|
||||
#include <eproperty/Value.h>
|
||||
#include <jus/AbstractFunctionTypeDirect.h>
|
||||
#include <jus/AbstractFunctionTypeClass.h>
|
||||
#include <jus/debug.h>
|
||||
#include <zeus/AbstractFunctionTypeDirect.h>
|
||||
#include <zeus/AbstractFunctionTypeClass.h>
|
||||
#include <zeus/debug.h>
|
||||
|
||||
namespace jus {
|
||||
namespace zeus {
|
||||
class RemoteProcessCall {
|
||||
public:
|
||||
RemoteProcessCall();
|
||||
protected:
|
||||
std::vector<jus::AbstractFunction*> m_listFunction;
|
||||
std::vector<zeus::AbstractFunction*> m_listFunction;
|
||||
protected:
|
||||
std::string m_description;
|
||||
public:
|
||||
@ -54,35 +54,35 @@ namespace jus {
|
||||
virtual bool isFunctionAuthorized(uint64_t _clientSessionID, const std::string& _funcName);
|
||||
public:
|
||||
// Add global fuction (no link with this class)
|
||||
template<class JUS_RETURN_VALUE,
|
||||
class... JUS_FUNC_ARGS_TYPE>
|
||||
template<class ZEUS_RETURN_VALUE,
|
||||
class... ZEUS_FUNC_ARGS_TYPE>
|
||||
void advertise(const std::string& _name,
|
||||
JUS_RETURN_VALUE (*_func)(JUS_FUNC_ARGS_TYPE... _args),
|
||||
ZEUS_RETURN_VALUE (*_func)(ZEUS_FUNC_ARGS_TYPE... _args),
|
||||
const std::string& _desc = "") {
|
||||
for (auto &it : m_listFunction) {
|
||||
if (it == nullptr) {
|
||||
continue;
|
||||
}
|
||||
if (it->getName() == _name) {
|
||||
JUS_ERROR("Advertise function already bind .. ==> can not be done...: '" << _name << "'");
|
||||
ZEUS_ERROR("Advertise function already bind .. ==> can not be done...: '" << _name << "'");
|
||||
return;
|
||||
}
|
||||
}
|
||||
AbstractFunction* tmp = createAbstractFunctionDirect(_name, _desc, _func);
|
||||
if (tmp == nullptr) {
|
||||
JUS_ERROR("can not create abstract function ... '" << _name << "'");
|
||||
ZEUS_ERROR("can not create abstract function ... '" << _name << "'");
|
||||
return;
|
||||
}
|
||||
tmp->setType(jus::AbstractFunction::type::global);
|
||||
JUS_INFO("Add function '" << _name << "' in global mode");
|
||||
tmp->setType(zeus::AbstractFunction::type::global);
|
||||
ZEUS_INFO("Add function '" << _name << "' in global mode");
|
||||
m_listFunction.push_back(tmp);
|
||||
}
|
||||
// Add Local fuction (depend on this class)
|
||||
template<class JUS_RETURN_VALUE,
|
||||
class JUS_CLASS_TYPE,
|
||||
class... JUS_FUNC_ARGS_TYPE>
|
||||
template<class ZEUS_RETURN_VALUE,
|
||||
class ZEUS_CLASS_TYPE,
|
||||
class... ZEUS_FUNC_ARGS_TYPE>
|
||||
void advertise(std::string _name,
|
||||
JUS_RETURN_VALUE (JUS_CLASS_TYPE::*_func)(JUS_FUNC_ARGS_TYPE... _args),
|
||||
ZEUS_RETURN_VALUE (ZEUS_CLASS_TYPE::*_func)(ZEUS_FUNC_ARGS_TYPE... _args),
|
||||
const std::string& _desc = "") {
|
||||
_name = "sys." + _name;
|
||||
for (auto &it : m_listFunction) {
|
||||
@ -90,17 +90,17 @@ namespace jus {
|
||||
continue;
|
||||
}
|
||||
if (it->getName() == _name) {
|
||||
JUS_ERROR("Advertise function already bind .. ==> can not be done...: '" << _name << "'");
|
||||
ZEUS_ERROR("Advertise function already bind .. ==> can not be done...: '" << _name << "'");
|
||||
return;
|
||||
}
|
||||
}
|
||||
AbstractFunction* tmp = createAbstractFunctionClass(_name, _desc, _func);
|
||||
if (tmp == nullptr) {
|
||||
JUS_ERROR("can not create abstract function ... '" << _name << "'");
|
||||
ZEUS_ERROR("can not create abstract function ... '" << _name << "'");
|
||||
return;
|
||||
}
|
||||
tmp->setType(jus::AbstractFunction::type::local);
|
||||
JUS_INFO("Add function '" << _name << "' in local mode");
|
||||
tmp->setType(zeus::AbstractFunction::type::local);
|
||||
ZEUS_INFO("Add function '" << _name << "' in local mode");
|
||||
m_listFunction.push_back(tmp);
|
||||
}
|
||||
};
|
||||
|
@ -4,45 +4,45 @@
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <jus/Service.h>
|
||||
#include <jus/debug.h>
|
||||
#include <zeus/Service.h>
|
||||
#include <zeus/debug.h>
|
||||
#include <etk/stdTools.h>
|
||||
#include <enet/TcpClient.h>
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
jus::Service::Service() :
|
||||
propertyIp(this, "ip", "127.0.0.1", "Ip to connect server", &jus::Service::onPropertyChangeIp),
|
||||
propertyPort(this, "port", 1982, "Port to connect server", &jus::Service::onPropertyChangePort) {
|
||||
zeus::Service::Service() :
|
||||
propertyIp(this, "ip", "127.0.0.1", "Ip to connect server", &zeus::Service::onPropertyChangeIp),
|
||||
propertyPort(this, "port", 1982, "Port to connect server", &zeus::Service::onPropertyChangePort) {
|
||||
|
||||
|
||||
advertise("getExtention", &jus::Service::getExtention);
|
||||
advertise("getExtention", &zeus::Service::getExtention);
|
||||
setLastFuncDesc("Get List of availlable extention of this service");
|
||||
addLastFuncReturn("A list of extention register in the service");
|
||||
|
||||
}
|
||||
|
||||
jus::Service::~Service() {
|
||||
zeus::Service::~Service() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
std::vector<std::string> jus::Service::getExtention() {
|
||||
std::vector<std::string> zeus::Service::getExtention() {
|
||||
return std::vector<std::string>();
|
||||
}
|
||||
|
||||
|
||||
void jus::Service::onClientData(jus::Buffer& _value) {
|
||||
void zeus::Service::onClientData(zeus::Buffer& _value) {
|
||||
uint32_t tmpID = _value.getTransactionId();
|
||||
uint32_t clientId = _value.getClientId();;
|
||||
auto it = m_callMultiData.begin();
|
||||
while (it != m_callMultiData.end()) {
|
||||
if ( it->getTransactionId() == tmpID
|
||||
&& it->getClientId() == clientId) {
|
||||
JUS_WARNING("Append data ... " << tmpID);
|
||||
ZEUS_WARNING("Append data ... " << tmpID);
|
||||
it->appendData(_value);
|
||||
if (it->isFinished() == true) {
|
||||
JUS_WARNING("CALL Function ...");
|
||||
ZEUS_WARNING("CALL Function ...");
|
||||
callBinary(tmpID, it->getRaw());
|
||||
it = m_callMultiData.erase(it);
|
||||
}
|
||||
@ -50,98 +50,86 @@ void jus::Service::onClientData(jus::Buffer& _value) {
|
||||
}
|
||||
++it;
|
||||
}
|
||||
jus::FutureCall futCall(clientId, tmpID, _value);
|
||||
zeus::FutureCall futCall(clientId, tmpID, _value);
|
||||
if (futCall.isFinished() == true) {
|
||||
JUS_INFO("Call Binary ..");
|
||||
ZEUS_INFO("Call Binary ..");
|
||||
callBinary(tmpID, futCall.getRaw());
|
||||
} else {
|
||||
m_callMultiData.push_back(futCall);
|
||||
}
|
||||
}
|
||||
|
||||
void jus::Service::onPropertyChangeIp() {
|
||||
void zeus::Service::onPropertyChangeIp() {
|
||||
disconnect();
|
||||
}
|
||||
|
||||
void jus::Service::onPropertyChangePort(){
|
||||
void zeus::Service::onPropertyChangePort(){
|
||||
disconnect();
|
||||
}
|
||||
|
||||
|
||||
void jus::Service::connect(const std::string& _serviceName, uint32_t _numberRetry){
|
||||
void zeus::Service::connect(const std::string& _serviceName, uint32_t _numberRetry){
|
||||
disconnect();
|
||||
JUS_DEBUG("connect [START]");
|
||||
ZEUS_DEBUG("connect [START]");
|
||||
enet::Tcp connection = std::move(enet::connectTcpClient(*propertyIp, *propertyPort, _numberRetry));
|
||||
if (connection.getConnectionStatus() != enet::Tcp::status::link) {
|
||||
JUS_DEBUG("connect [STOP] ==> can not connect");
|
||||
ZEUS_DEBUG("connect [STOP] ==> can not connect");
|
||||
return;
|
||||
}
|
||||
m_interfaceClient = std::make_shared<jus::TcpString>();
|
||||
m_interfaceClient = std::make_shared<zeus::TcpString>();
|
||||
if (m_interfaceClient == nullptr) {
|
||||
JUS_ERROR("Can not allocate interface ...");
|
||||
ZEUS_ERROR("Can not allocate interface ...");
|
||||
return;
|
||||
}
|
||||
m_interfaceClient->connect(this, &jus::Service::onClientData);
|
||||
m_interfaceClient->setInterface(std::move(connection));
|
||||
m_interfaceClient->connect(this, &zeus::Service::onClientData);
|
||||
m_interfaceClient->setInterface(std::move(connection), false);
|
||||
m_interfaceClient->connect();
|
||||
jus::Future<bool> ret = m_interfaceClient->call("connect-service", _serviceName);
|
||||
zeus::Future<bool> ret = m_interfaceClient->call("connect-service", _serviceName);
|
||||
ret.wait();
|
||||
if (ret.get() == false) {
|
||||
JUS_ERROR("Can not configure the interface for the service with the current name ...");
|
||||
ZEUS_ERROR("Can not configure the interface for the service with the current name ...");
|
||||
m_interfaceClient->disconnect();
|
||||
return;
|
||||
}
|
||||
|
||||
JUS_DEBUG("connect [STOP]");
|
||||
ZEUS_DEBUG("connect [STOP]");
|
||||
}
|
||||
|
||||
void jus::Service::disconnect(){
|
||||
JUS_DEBUG("disconnect [START]");
|
||||
void zeus::Service::disconnect(){
|
||||
ZEUS_DEBUG("disconnect [START]");
|
||||
if (m_interfaceClient != nullptr) {
|
||||
m_interfaceClient->disconnect();
|
||||
m_interfaceClient.reset();
|
||||
} else {
|
||||
JUS_VERBOSE("Nothing to disconnect ...");
|
||||
ZEUS_VERBOSE("Nothing to disconnect ...");
|
||||
}
|
||||
JUS_DEBUG("disconnect [STOP]");
|
||||
ZEUS_DEBUG("disconnect [STOP]");
|
||||
}
|
||||
|
||||
bool jus::Service::GateWayAlive() {
|
||||
bool zeus::Service::GateWayAlive() {
|
||||
if (m_interfaceClient == nullptr) {
|
||||
return false;
|
||||
}
|
||||
return m_interfaceClient->isActive();
|
||||
}
|
||||
|
||||
void jus::Service::pingIsAlive() {
|
||||
void zeus::Service::pingIsAlive() {
|
||||
if (std::chrono::steady_clock::now() - m_interfaceClient->getLastTimeSend() >= std::chrono::seconds(30)) {
|
||||
/*
|
||||
ejson::Object tmpp;
|
||||
tmpp.add("event", ejson::String("IS-ALIVE"));
|
||||
m_interfaceClient->writeJson(tmpp);
|
||||
*/
|
||||
m_interfaceClient->ping();
|
||||
}
|
||||
}
|
||||
|
||||
void jus::Service::callBinary(uint32_t _transactionId, jus::Buffer& _obj) {
|
||||
if (_obj.getType() == jus::Buffer::typeMessage::event) {
|
||||
/*
|
||||
std::string event = _obj["event"].toString().get();
|
||||
if (event == "IS-ALIVE") {
|
||||
// Gateway just aswer a keep alive information ...
|
||||
// Nothing to do ...
|
||||
} else {
|
||||
JUS_ERROR("Unknow event: '" << event << "'");
|
||||
}
|
||||
*/
|
||||
JUS_ERROR("Unknow event: '...'");
|
||||
void zeus::Service::callBinary(uint32_t _transactionId, zeus::Buffer& _obj) {
|
||||
if (_obj.getType() == zeus::Buffer::typeMessage::event) {
|
||||
|
||||
ZEUS_ERROR("Unknow event: '...'");
|
||||
return;
|
||||
}
|
||||
if (_obj.getType() == jus::Buffer::typeMessage::answer) {
|
||||
JUS_ERROR("Local Answer: '...'");
|
||||
if (_obj.getType() == zeus::Buffer::typeMessage::answer) {
|
||||
ZEUS_ERROR("Local Answer: '...'");
|
||||
return;
|
||||
}
|
||||
//if (_obj.getType() == jus::Buffer::typeMessage::event) {
|
||||
//if (_obj.getType() == zeus::Buffer::typeMessage::event) {
|
||||
uint32_t clientId = _obj.getClientId();
|
||||
std::string callFunction = _obj.getCall();
|
||||
if (callFunction[0] == '_') {
|
||||
|
104
zeus/Service.h
104
zeus/Service.h
@ -5,15 +5,15 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <jus/TcpString.h>
|
||||
#include <zeus/TcpString.h>
|
||||
#include <eproperty/Value.h>
|
||||
#include <jus/AbstractFunctionTypeDirect.h>
|
||||
#include <jus/AbstractFunctionTypeClass.h>
|
||||
#include <jus/debug.h>
|
||||
#include <jus/RemoteProcessCall.h>
|
||||
#include <jus/Future.h>
|
||||
#include <zeus/AbstractFunctionTypeDirect.h>
|
||||
#include <zeus/AbstractFunctionTypeClass.h>
|
||||
#include <zeus/debug.h>
|
||||
#include <zeus/RemoteProcessCall.h>
|
||||
#include <zeus/Future.h>
|
||||
|
||||
namespace jus {
|
||||
namespace zeus {
|
||||
class ClientProperty {
|
||||
public:
|
||||
ClientProperty(const std::string& _clientName="", const std::vector<std::string>& _groups = std::vector<std::string>()) :
|
||||
@ -50,25 +50,25 @@ namespace jus {
|
||||
}
|
||||
};
|
||||
}
|
||||
namespace jus {
|
||||
class Service : public eproperty::Interface, public jus::RemoteProcessCall {
|
||||
namespace zeus {
|
||||
class Service : public eproperty::Interface, public zeus::RemoteProcessCall {
|
||||
protected:
|
||||
std::mutex m_mutex;
|
||||
public:
|
||||
eproperty::Value<std::string> propertyIp;
|
||||
eproperty::Value<uint16_t> propertyPort;
|
||||
protected:
|
||||
ememory::SharedPtr<jus::TcpString> m_interfaceClient;
|
||||
ememory::SharedPtr<zeus::TcpString> m_interfaceClient;
|
||||
uint32_t m_id;
|
||||
std::vector<std::string> m_newData;
|
||||
std::vector<jus::FutureCall> m_callMultiData;
|
||||
std::vector<zeus::FutureCall> m_callMultiData;
|
||||
public:
|
||||
Service();
|
||||
virtual ~Service();
|
||||
void connect(const std::string& _serviceName, uint32_t _numberRetry = 1);
|
||||
void disconnect();
|
||||
private:
|
||||
void onClientData(jus::Buffer& _value);
|
||||
void onClientData(zeus::Buffer& _value);
|
||||
public:
|
||||
void pingIsAlive();
|
||||
bool GateWayAlive();
|
||||
@ -84,16 +84,16 @@ namespace jus {
|
||||
virtual void clientConnect(uint64_t _clientId, const std::string& _userName, const std::string& _clientName, const std::vector<std::string>& _groups) = 0;
|
||||
virtual void clientDisconnect(uint64_t _clientId) = 0;
|
||||
// Genenric function call:
|
||||
void callBinary(uint32_t _transactionId, jus::Buffer& _obj);
|
||||
virtual void callBinary2(uint32_t _transactionId, uint64_t _clientId, const std::string& _call, jus::Buffer& _obj) = 0;
|
||||
void callBinary(uint32_t _transactionId, zeus::Buffer& _obj);
|
||||
virtual void callBinary2(uint32_t _transactionId, uint64_t _clientId, const std::string& _call, zeus::Buffer& _obj) = 0;
|
||||
std::vector<std::string> getExtention();
|
||||
public:
|
||||
// Add Local fuction (depend on this class)
|
||||
template<class JUS_RETURN_VALUE,
|
||||
class JUS_CLASS_TYPE,
|
||||
class... JUS_FUNC_ARGS_TYPE>
|
||||
template<class ZEUS_RETURN_VALUE,
|
||||
class ZEUS_CLASS_TYPE,
|
||||
class... ZEUS_FUNC_ARGS_TYPE>
|
||||
void advertise(std::string _name,
|
||||
JUS_RETURN_VALUE (JUS_CLASS_TYPE::*_func)(JUS_FUNC_ARGS_TYPE... _args),
|
||||
ZEUS_RETURN_VALUE (ZEUS_CLASS_TYPE::*_func)(ZEUS_FUNC_ARGS_TYPE... _args),
|
||||
const std::string& _desc = "") {
|
||||
_name = "srv." + _name;
|
||||
for (auto &it : m_listFunction) {
|
||||
@ -101,37 +101,37 @@ namespace jus {
|
||||
continue;
|
||||
}
|
||||
if (it->getName() == _name) {
|
||||
JUS_ERROR("Advertise function already bind .. ==> can not be done...: '" << _name << "'");
|
||||
ZEUS_ERROR("Advertise function already bind .. ==> can not be done...: '" << _name << "'");
|
||||
return;
|
||||
}
|
||||
}
|
||||
AbstractFunction* tmp = createAbstractFunctionClass(_name, _desc, _func);
|
||||
if (tmp == nullptr) {
|
||||
JUS_ERROR("can not create abstract function ... '" << _name << "'");
|
||||
ZEUS_ERROR("can not create abstract function ... '" << _name << "'");
|
||||
return;
|
||||
}
|
||||
tmp->setType(jus::AbstractFunction::type::service);
|
||||
JUS_INFO("Add function '" << _name << "' in local mode");
|
||||
tmp->setType(zeus::AbstractFunction::type::service);
|
||||
ZEUS_INFO("Add function '" << _name << "' in local mode");
|
||||
m_listFunction.push_back(tmp);
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
template<class JUS_TYPE_SERVICE, class JUS_USER_ACCESS>
|
||||
class ServiceType : public jus::Service {
|
||||
template<class ZEUS_TYPE_SERVICE, class ZEUS_USER_ACCESS>
|
||||
class ServiceType : public zeus::Service {
|
||||
private:
|
||||
JUS_USER_ACCESS& m_getUserInterface;
|
||||
ZEUS_USER_ACCESS& m_getUserInterface;
|
||||
// no need of shared_ptr or unique_ptr (if service die all is lost and is client die, the gateway notify us...)
|
||||
std::map<uint64_t, std::pair<ememory::SharedPtr<ClientProperty>, ememory::SharedPtr<JUS_TYPE_SERVICE>>> m_interface;
|
||||
std::map<uint64_t, std::pair<ememory::SharedPtr<ClientProperty>, ememory::SharedPtr<ZEUS_TYPE_SERVICE>>> m_interface;
|
||||
public:
|
||||
template<class JUS_RETURN_VALUE,
|
||||
class JUS_CLASS_TYPE,
|
||||
class... JUS_FUNC_ARGS_TYPE>
|
||||
template<class ZEUS_RETURN_VALUE,
|
||||
class ZEUS_CLASS_TYPE,
|
||||
class... ZEUS_FUNC_ARGS_TYPE>
|
||||
void advertise(const std::string& _name,
|
||||
JUS_RETURN_VALUE (JUS_CLASS_TYPE::*_func)(JUS_FUNC_ARGS_TYPE... _args),
|
||||
ZEUS_RETURN_VALUE (ZEUS_CLASS_TYPE::*_func)(ZEUS_FUNC_ARGS_TYPE... _args),
|
||||
const std::string& _desc = "") {
|
||||
if (etk::start_with(_name, "srv.") == true) {
|
||||
JUS_ERROR("Advertise function start with 'srv.' is not permited ==> only allow for internal service: '" << _name << "'");
|
||||
ZEUS_ERROR("Advertise function start with 'srv.' is not permited ==> only allow for internal service: '" << _name << "'");
|
||||
return;
|
||||
}
|
||||
for (auto &it : m_listFunction) {
|
||||
@ -139,20 +139,20 @@ namespace jus {
|
||||
continue;
|
||||
}
|
||||
if (it->getName() == _name) {
|
||||
JUS_ERROR("Advertise function already bind .. ==> can not be done...: '" << _name << "'");
|
||||
ZEUS_ERROR("Advertise function already bind .. ==> can not be done...: '" << _name << "'");
|
||||
return;
|
||||
}
|
||||
}
|
||||
AbstractFunction* tmp = createAbstractFunctionClass(_name, _desc, _func);
|
||||
if (tmp == nullptr) {
|
||||
JUS_ERROR("can not create abstract function ... '" << _name << "'");
|
||||
ZEUS_ERROR("can not create abstract function ... '" << _name << "'");
|
||||
return;
|
||||
}
|
||||
tmp->setType(jus::AbstractFunction::type::object);
|
||||
JUS_INFO("Add function '" << _name << "' in object mode");
|
||||
tmp->setType(zeus::AbstractFunction::type::object);
|
||||
ZEUS_INFO("Add function '" << _name << "' in object mode");
|
||||
m_listFunction.push_back(tmp);
|
||||
}
|
||||
ServiceType(JUS_USER_ACCESS& _interface):
|
||||
ServiceType(ZEUS_USER_ACCESS& _interface):
|
||||
m_getUserInterface(_interface) {
|
||||
|
||||
}
|
||||
@ -165,11 +165,11 @@ namespace jus {
|
||||
}
|
||||
void clientConnect(uint64_t _clientId, const std::string& _userName, const std::string& _clientName, const std::vector<std::string>& _groups) {
|
||||
std::unique_lock<std::mutex> lock(m_mutex);
|
||||
JUS_DEBUG("connect: " << _clientId << " to '" << _userName << "'");
|
||||
JUS_DEBUG(" client name='" << _clientName << "'");
|
||||
JUS_DEBUG(" groups=" << etk::to_string(_groups));
|
||||
ZEUS_DEBUG("connect: " << _clientId << " to '" << _userName << "'");
|
||||
ZEUS_DEBUG(" client name='" << _clientName << "'");
|
||||
ZEUS_DEBUG(" groups=" << etk::to_string(_groups));
|
||||
ememory::SharedPtr<ClientProperty> tmpProperty = std::make_shared<ClientProperty>(_clientName, _groups);
|
||||
ememory::SharedPtr<JUS_TYPE_SERVICE> tmpSrv = std::make_shared<JUS_TYPE_SERVICE>(m_getUserInterface.getUser(_userName), tmpProperty);
|
||||
ememory::SharedPtr<ZEUS_TYPE_SERVICE> tmpSrv = std::make_shared<ZEUS_TYPE_SERVICE>(m_getUserInterface.getUser(_userName), tmpProperty);
|
||||
m_interface.insert(std::make_pair(_clientId, std::make_pair(tmpProperty, tmpSrv)));
|
||||
// enable list of function availlable:
|
||||
for (auto &it : m_listFunction) {
|
||||
@ -181,10 +181,10 @@ namespace jus {
|
||||
}
|
||||
void clientDisconnect(uint64_t _clientId) {
|
||||
std::unique_lock<std::mutex> lock(m_mutex);
|
||||
JUS_DEBUG("disconnect: " << _clientId);
|
||||
ZEUS_DEBUG("disconnect: " << _clientId);
|
||||
auto it = m_interface.find(_clientId);
|
||||
if (it == m_interface.end()) {
|
||||
JUS_WARNING("disconnect ==> Not find Client ID " << _clientId);
|
||||
ZEUS_WARNING("disconnect ==> Not find Client ID " << _clientId);
|
||||
// noting to do ==> user never conected.
|
||||
return;
|
||||
}
|
||||
@ -194,7 +194,7 @@ namespace jus {
|
||||
std::unique_lock<std::mutex> lock(m_mutex);
|
||||
auto it = m_interface.find(_clientId);
|
||||
if (it == m_interface.end()) {
|
||||
JUS_ERROR("Change the client property but client was not created ...");
|
||||
ZEUS_ERROR("Change the client property but client was not created ...");
|
||||
return;
|
||||
}
|
||||
it->second.first->setName(_clientName);
|
||||
@ -203,12 +203,12 @@ namespace jus {
|
||||
std::unique_lock<std::mutex> lock(m_mutex);
|
||||
auto it = m_interface.find(_clientId);
|
||||
if (it == m_interface.end()) {
|
||||
JUS_ERROR("Change the client property but client was not created ...");
|
||||
ZEUS_ERROR("Change the client property but client was not created ...");
|
||||
return;
|
||||
}
|
||||
it->second.first->setGroups(_clientGroups);
|
||||
}
|
||||
void callBinary2(uint32_t _transactionId, uint64_t _clientId, const std::string& _call, jus::Buffer& _obj) {
|
||||
void callBinary2(uint32_t _transactionId, uint64_t _clientId, const std::string& _call, zeus::Buffer& _obj) {
|
||||
auto it = m_interface.find(_clientId);
|
||||
if (it == m_interface.end()) {
|
||||
m_interfaceClient->answerError(_transactionId, "CLIENT-UNKNOW", "", _clientId);
|
||||
@ -222,25 +222,25 @@ namespace jus {
|
||||
continue;
|
||||
}
|
||||
switch (it2->getType()) {
|
||||
case jus::AbstractFunction::type::object: {
|
||||
JUS_TYPE_SERVICE* elem = it->second.second.get();
|
||||
case zeus::AbstractFunction::type::object: {
|
||||
ZEUS_TYPE_SERVICE* elem = it->second.second.get();
|
||||
it2->execute(m_interfaceClient, _transactionId, _clientId, _obj, (void*)elem);
|
||||
return;
|
||||
}
|
||||
case jus::AbstractFunction::type::local: {
|
||||
case zeus::AbstractFunction::type::local: {
|
||||
it2->execute(m_interfaceClient, _transactionId, _clientId, _obj, (void*)((RemoteProcessCall*)this));
|
||||
return;
|
||||
}
|
||||
case jus::AbstractFunction::type::service: {
|
||||
case zeus::AbstractFunction::type::service: {
|
||||
it2->execute(m_interfaceClient, _transactionId, _clientId, _obj, (void*)this);
|
||||
return;
|
||||
}
|
||||
case jus::AbstractFunction::type::global: {
|
||||
case zeus::AbstractFunction::type::global: {
|
||||
it2->execute(m_interfaceClient, _transactionId, _clientId, _obj, nullptr);
|
||||
return;
|
||||
}
|
||||
case jus::AbstractFunction::type::unknow:
|
||||
JUS_ERROR("Can not call unknow type ...");
|
||||
case zeus::AbstractFunction::type::unknow:
|
||||
ZEUS_ERROR("Can not call unknow type ...");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -4,10 +4,10 @@
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <jus/ServiceRemote.h>
|
||||
#include <jus/Client.h>
|
||||
#include <zeus/ServiceRemote.h>
|
||||
#include <zeus/Client.h>
|
||||
|
||||
jus::ServiceRemote::ServiceRemote(ememory::SharedPtr<jus::TcpString> _clientLink, const std::string& _name):
|
||||
zeus::ServiceRemote::ServiceRemote(ememory::SharedPtr<zeus::TcpString> _clientLink, const std::string& _name):
|
||||
m_interfaceClient(_clientLink),
|
||||
m_name(_name),
|
||||
m_serviceId(0),
|
||||
@ -16,38 +16,38 @@ jus::ServiceRemote::ServiceRemote(ememory::SharedPtr<jus::TcpString> _clientLink
|
||||
return;
|
||||
}
|
||||
// little hack : Call the service manager with the service ID=0 ...
|
||||
jus::Future<uint32_t> ret = call("link", _name);
|
||||
zeus::Future<uint32_t> ret = call("link", _name);
|
||||
ret.wait();
|
||||
if (ret.hasError() == true) {
|
||||
JUS_WARNING("Can not link with the service named: '" << _name << "' ==> link error");
|
||||
ZEUS_WARNING("Can not link with the service named: '" << _name << "' ==> link error");
|
||||
return;
|
||||
}
|
||||
m_isLinked = true;
|
||||
m_serviceId = ret.get();
|
||||
}
|
||||
|
||||
jus::ServiceRemote::~ServiceRemote() {
|
||||
zeus::ServiceRemote::~ServiceRemote() {
|
||||
if (m_isLinked == true) {
|
||||
uint32_t tmpLocalService = m_serviceId;
|
||||
// little hack : Call the service manager with the service ID=0 ...
|
||||
m_serviceId = 0;
|
||||
jus::Future<bool> ret = call("unlink", tmpLocalService);
|
||||
zeus::Future<bool> ret = call("unlink", tmpLocalService);
|
||||
ret.wait();
|
||||
if (ret.hasError() == true) {
|
||||
JUS_WARNING("Can not unlink with the service id: '" << tmpLocalService << "' ==> link error");
|
||||
ZEUS_WARNING("Can not unlink with the service id: '" << tmpLocalService << "' ==> link error");
|
||||
m_serviceId = tmpLocalService;
|
||||
return;
|
||||
}
|
||||
if (ret.get() == true) {
|
||||
m_isLinked = false;
|
||||
} else {
|
||||
JUS_ERROR("Can not unlink with this service ....");
|
||||
ZEUS_ERROR("Can not unlink with this service ....");
|
||||
m_serviceId = tmpLocalService;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool jus::ServiceRemote::exist() {
|
||||
bool zeus::ServiceRemote::exist() {
|
||||
return m_isLinked;
|
||||
}
|
||||
|
||||
|
@ -5,42 +5,42 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <jus/TcpString.h>
|
||||
#include <zeus/TcpString.h>
|
||||
#include <eproperty/Value.h>
|
||||
#include <jus/debug.h>
|
||||
#include <jus/AbstractFunction.h>
|
||||
#include <jus/ServiceRemote.h>
|
||||
#include <jus/Future.h>
|
||||
#include <jus/TcpString.h>
|
||||
#include <zeus/debug.h>
|
||||
#include <zeus/AbstractFunction.h>
|
||||
#include <zeus/ServiceRemote.h>
|
||||
#include <zeus/Future.h>
|
||||
#include <zeus/TcpString.h>
|
||||
|
||||
namespace jus {
|
||||
namespace zeus {
|
||||
class Client;
|
||||
class ServiceRemote {
|
||||
private:
|
||||
ememory::SharedPtr<jus::TcpString> m_interfaceClient;
|
||||
ememory::SharedPtr<zeus::TcpString> m_interfaceClient;
|
||||
std::string m_name;
|
||||
uint32_t m_serviceId;
|
||||
bool m_isLinked;
|
||||
public:
|
||||
ServiceRemote(ememory::SharedPtr<jus::TcpString> _clientLink, const std::string& _name);
|
||||
ServiceRemote(ememory::SharedPtr<zeus::TcpString> _clientLink, const std::string& _name);
|
||||
~ServiceRemote();
|
||||
bool exist();
|
||||
public:
|
||||
template<class... _ARGS>
|
||||
jus::FutureBase call(const std::string& _functionName, _ARGS&&... _args) {
|
||||
zeus::FutureBase call(const std::string& _functionName, _ARGS&&... _args) {
|
||||
if (m_interfaceClient == nullptr) {
|
||||
jus::Buffer ret;
|
||||
zeus::Buffer ret;
|
||||
ret.addError("NULLPTR", "call " + _functionName + " with no interface open");
|
||||
return jus::FutureBase(0, true, ret);
|
||||
return zeus::FutureBase(0, true, ret);
|
||||
}
|
||||
return m_interfaceClient->callService(m_serviceId, _functionName, _args...);
|
||||
}
|
||||
template<class... _ARGS>
|
||||
jus::FutureBase callAction(const std::string& _functionName, _ARGS&&... _args, jus::FutureData::ObserverFinish _callback) {
|
||||
zeus::FutureBase callAction(const std::string& _functionName, _ARGS&&... _args, zeus::FutureData::ObserverFinish _callback) {
|
||||
if (m_interfaceClient == nullptr) {
|
||||
jus::Buffer ret;
|
||||
zeus::Buffer ret;
|
||||
ret.addError("NULLPTR", "call " + _functionName + " with no interface open");
|
||||
return jus::FutureBase(0, true, ret, _callback);
|
||||
return zeus::FutureBase(0, true, ret, _callback);
|
||||
}
|
||||
return m_interfaceClient->callServiceAction(m_serviceId, _functionName, _args..., _callback);
|
||||
}
|
||||
|
@ -3,241 +3,146 @@
|
||||
* @copyright 2016, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
#include <jus/TcpString.h>
|
||||
#include <jus/debug.h>
|
||||
#include <zeus/TcpString.h>
|
||||
#include <zeus/debug.h>
|
||||
#include <ethread/tools.h>
|
||||
#include <unistd.h>
|
||||
|
||||
jus::TcpString::TcpString(enet::Tcp _connection) :
|
||||
m_connection(std::move(_connection)),
|
||||
m_thread(nullptr),
|
||||
m_observerElement(nullptr),
|
||||
m_threadAsync(nullptr) {
|
||||
m_threadRunning = false;
|
||||
m_threadAsyncRunning = false;
|
||||
m_transmissionId = 1;
|
||||
}
|
||||
|
||||
jus::TcpString::TcpString() :
|
||||
zeus::TcpString::TcpString() :
|
||||
m_connection(),
|
||||
m_thread(nullptr),
|
||||
m_observerElement(nullptr),
|
||||
m_threadAsync(nullptr) {
|
||||
m_threadRunning = false;
|
||||
m_threadAsyncRunning = false;
|
||||
m_transmissionId = 1;
|
||||
}
|
||||
|
||||
void jus::TcpString::setInterface(enet::Tcp _connection) {
|
||||
m_connection = std::move(_connection);
|
||||
zeus::TcpString::TcpString(enet::Tcp _connection, bool _isServer) :
|
||||
m_connection(),
|
||||
m_observerElement(nullptr),
|
||||
m_threadAsync(nullptr) {
|
||||
m_threadAsyncRunning = false;
|
||||
m_transmissionId = 1;
|
||||
setInterface(std::move(_connection), _isServer);
|
||||
}
|
||||
|
||||
jus::TcpString::~TcpString() {
|
||||
void zeus::TcpString::setInterface(enet::Tcp _connection, bool _isServer) {
|
||||
m_connection.setInterface(std::move(_connection), _isServer);
|
||||
m_connection.connect(this, &zeus::TcpString::onReceiveData);
|
||||
if (_isServer == true) {
|
||||
m_connection.connectUri(this, &zeus::TcpString::onReceiveUri);
|
||||
m_connection.start();
|
||||
} else {
|
||||
m_connection.start("/stupidName");
|
||||
}
|
||||
}
|
||||
|
||||
zeus::TcpString::~TcpString() {
|
||||
disconnect();
|
||||
}
|
||||
|
||||
void jus::TcpString::setInterfaceName(const std::string& _name) {
|
||||
ethread::setName(*m_thread, "Tcp-" + _name);
|
||||
void zeus::TcpString::setInterfaceName(const std::string& _name) {
|
||||
//ethread::setName(*m_thread, "Tcp-" + _name);
|
||||
}
|
||||
|
||||
void jus::TcpString::threadCallback() {
|
||||
ethread::setName("TcpString-input");
|
||||
// get datas:
|
||||
while ( m_threadRunning == true
|
||||
&& m_connection.getConnectionStatus() == enet::Tcp::status::link) {
|
||||
// READ section data:
|
||||
read();
|
||||
}
|
||||
m_threadRunning = false;
|
||||
JUS_DEBUG("End of thread");
|
||||
|
||||
bool zeus::TcpString::isActive() const {
|
||||
return m_connection.isAlive();
|
||||
}
|
||||
|
||||
bool jus::TcpString::isActive() const {
|
||||
return m_threadRunning;
|
||||
}
|
||||
|
||||
void jus::TcpString::connect(bool _async){
|
||||
JUS_DEBUG("connect [START]");
|
||||
m_threadRunning = true;
|
||||
m_thread = new std::thread([&](void *){ this->threadCallback();}, nullptr);
|
||||
if (m_thread == nullptr) {
|
||||
m_threadRunning = false;
|
||||
JUS_ERROR("creating callback thread!");
|
||||
return;
|
||||
}
|
||||
void zeus::TcpString::connect(bool _async){
|
||||
ZEUS_DEBUG("connect [START]");
|
||||
m_threadAsyncRunning = true;
|
||||
m_threadAsync = new std::thread([&](void *){ this->threadAsyncCallback();}, nullptr);
|
||||
if (m_threadAsync == nullptr) {
|
||||
m_threadAsyncRunning = false;
|
||||
JUS_ERROR("creating async sender thread!");
|
||||
ZEUS_ERROR("creating async sender thread!");
|
||||
return;
|
||||
}
|
||||
|
||||
while ( _async == false
|
||||
&& m_threadRunning == true
|
||||
&& m_connection.getConnectionStatus() != enet::Tcp::status::link) {
|
||||
&& m_threadAsyncRunning == true
|
||||
&& m_connection.isAlive() != true) {
|
||||
usleep(50000);
|
||||
}
|
||||
//ethread::setPriority(*m_receiveThread, -6);
|
||||
if (_async == true) {
|
||||
JUS_DEBUG("connect [STOP] async mode");
|
||||
ZEUS_DEBUG("connect [STOP] async mode");
|
||||
} else {
|
||||
JUS_DEBUG("connect [STOP]");
|
||||
ZEUS_DEBUG("connect [STOP]");
|
||||
}
|
||||
}
|
||||
|
||||
void jus::TcpString::disconnect(bool _inThreadStop){
|
||||
JUS_DEBUG("disconnect [START]");
|
||||
m_threadRunning = false;
|
||||
void zeus::TcpString::disconnect(bool _inThreadStop){
|
||||
ZEUS_DEBUG("disconnect [START]");
|
||||
m_threadAsyncRunning = false;
|
||||
if (m_connection.getConnectionStatus() == enet::Tcp::status::link) {
|
||||
uint32_t size = 0xFFFFFFFF;
|
||||
m_connection.write(&size, 4);
|
||||
}
|
||||
if (m_connection.getConnectionStatus() != enet::Tcp::status::unlink) {
|
||||
m_connection.unlink();
|
||||
if (m_connection.isAlive() == true) {
|
||||
m_connection.controlClose();
|
||||
}
|
||||
m_connection.stop(_inThreadStop);
|
||||
if (m_threadAsync != nullptr) {
|
||||
m_threadAsync->join();
|
||||
delete m_threadAsync;
|
||||
m_threadAsync = nullptr;
|
||||
}
|
||||
if (_inThreadStop == false) {
|
||||
if (m_thread != nullptr) {
|
||||
m_thread->join();
|
||||
delete m_thread;
|
||||
m_thread = nullptr;
|
||||
}
|
||||
}
|
||||
JUS_DEBUG("disconnect [STOP]");
|
||||
ZEUS_DEBUG("disconnect [STOP]");
|
||||
}
|
||||
|
||||
int32_t jus::TcpString::writeBinary(jus::Buffer& _data) {
|
||||
_data.prepare();
|
||||
JUS_DEBUG("Send BINARY '" << _data.generateHumanString() << "'");
|
||||
if (m_threadRunning == false) {
|
||||
int32_t zeus::TcpString::writeBinary(zeus::Buffer& _data) {
|
||||
uint64_t size = _data.prepare();
|
||||
ZEUS_DEBUG("Send BINARY " << size << " bytes '" << _data.generateHumanString() << "'");
|
||||
if (m_connection.isAlive() == false) {
|
||||
return -2;
|
||||
}
|
||||
m_lastSend = std::chrono::steady_clock::now();
|
||||
m_connection.write("B", 1);
|
||||
const uint8_t* data = nullptr;
|
||||
if (m_connection.writeHeader(size, false) == false) {
|
||||
return -1;
|
||||
}
|
||||
uint8_t* data = nullptr;
|
||||
uint32_t dataSize = 0;
|
||||
data = _data.getHeader();
|
||||
data = (uint8_t*)_data.getHeader();
|
||||
dataSize = _data.getHeaderSize();
|
||||
m_connection.write(data, dataSize);
|
||||
data = _data.getParam();
|
||||
size = m_connection.writeData(data, dataSize);
|
||||
data = (uint8_t*)_data.getParam();
|
||||
dataSize = _data.getParamSize();
|
||||
m_connection.write(data, dataSize);
|
||||
data = _data.getData();
|
||||
size += m_connection.writeData(data, dataSize);
|
||||
data = (uint8_t*)_data.getData();
|
||||
dataSize = _data.getDataSize();
|
||||
m_connection.write(data, dataSize);
|
||||
return 1;
|
||||
size += m_connection.writeData(data, dataSize);
|
||||
return size;
|
||||
}
|
||||
|
||||
void jus::TcpString::read() {
|
||||
JUS_VERBOSE("Read [START]");
|
||||
if (m_threadRunning == false) {
|
||||
JUS_DEBUG("Read [END] Disconected");
|
||||
bool zeus::TcpString::onReceiveUri(const std::string& _uri) {
|
||||
ZEUS_INFO("Receive Header uri: " << _uri);
|
||||
if (_uri == "/stupidName") {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void zeus::TcpString::onReceiveData(std::vector<uint8_t>& _frame, bool _isBinary) {
|
||||
ZEUS_VERBOSE("Receive Frame ... " << _frame.size());
|
||||
zeus::Buffer dataRaw;
|
||||
if (_isBinary == true) {
|
||||
ZEUS_ERROR("Receive non binary frame ...");
|
||||
disconnect(true);
|
||||
return;
|
||||
}
|
||||
// TODO : Do it better with a correct way to check data size ...
|
||||
JUS_VERBOSE("Read [START]");
|
||||
uint8_t type = 0;
|
||||
int32_t len = m_connection.read(&type, 1);
|
||||
if (len == 0) {
|
||||
JUS_ERROR("Protocol error occured ==> No datas ...");
|
||||
} else {
|
||||
if (type == 'G') { // Get (This is a websocket first connection
|
||||
std::string out = "G";
|
||||
JUS_VERBOSE("Read HTTP first connection of a websocket [START]");
|
||||
// get all data while we find "User-Agent **********\n" ==> After this is a TCP connection (need to answear)
|
||||
while (true) {
|
||||
int32_t len = m_connection.read(&type, 1);
|
||||
if (len == 0) {
|
||||
continue;
|
||||
}
|
||||
out += char(type);
|
||||
JUS_INFO(" ** " << out);
|
||||
if ( out.size() > 4
|
||||
&& out[out.size()-1] == '\n'
|
||||
&& out[out.size()-2] == '\r'
|
||||
&& out[out.size()-3] == '\n'
|
||||
&& out[out.size()-4] == '\r') {
|
||||
break;
|
||||
}
|
||||
if ( out.size() > 2
|
||||
&& out[out.size()-1] == '\n'
|
||||
&& out[out.size()-2] == '\n') {
|
||||
break;
|
||||
}
|
||||
/*
|
||||
if (char(type) == '\n') {
|
||||
if (out.find("User-Agent") != std::string::npos) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
JUS_INFO("Find WebSocket ...");
|
||||
JUS_INFO("data='" << out << "'");
|
||||
if ( if out.size() < 3
|
||||
|| ( out[0] != 'G'
|
||||
&& out[1] != 'E'
|
||||
&& out[2] != 'T'
|
||||
)
|
||||
) {
|
||||
std::string ret = "HTTP/1.0 400 Bad Request\r\n";
|
||||
ret += "\r\n";
|
||||
m_connection.write(&ret[0], ret.size());
|
||||
disconnect(true);
|
||||
} else {
|
||||
std::string ret = "HTTP/1.0 200 OK\n";
|
||||
ret += "Content-Type : application/octet-stream\n";
|
||||
ret += "\n";
|
||||
m_connection.write(&ret[0], ret.size());
|
||||
}
|
||||
JUS_VERBOSE("Read HTTP first connection of a websocket [STOP]");
|
||||
} else if (type == 'B') { // binary
|
||||
// Binary mode ... start with the lenght of the stream
|
||||
JUS_VERBOSE("Read Binary [START]");
|
||||
uint32_t size = 0;
|
||||
len = m_connection.read(&size, 4);
|
||||
if (len != 4) {
|
||||
JUS_ERROR("Protocol error occured ...");
|
||||
} else {
|
||||
if (size == -1) {
|
||||
JUS_WARNING("Remote close connection");
|
||||
m_threadRunning = false;
|
||||
//m_connection.unlink();
|
||||
} else {
|
||||
int64_t offset = 0;
|
||||
m_buffer.resize(size);
|
||||
while (offset != size) {
|
||||
len = m_connection.read(&m_buffer[offset], size-offset);
|
||||
offset += len;
|
||||
if (len == 0) {
|
||||
JUS_WARNING("Read No data");
|
||||
}
|
||||
}
|
||||
jus::Buffer dataRaw;
|
||||
dataRaw.composeWith(m_buffer);
|
||||
newBuffer(dataRaw);
|
||||
}
|
||||
}
|
||||
JUS_VERBOSE("ReadRaw [STOP]");
|
||||
}
|
||||
}
|
||||
dataRaw.composeWith(_frame);
|
||||
newBuffer(dataRaw);
|
||||
}
|
||||
|
||||
void jus::TcpString::newBuffer(jus::Buffer& _buffer) {
|
||||
JUS_VERBOSE("Receive Binary :" << _buffer.generateHumanString());
|
||||
jus::FutureBase future;
|
||||
void zeus::TcpString::ping() {
|
||||
m_connection.controlPing();
|
||||
}
|
||||
|
||||
void zeus::TcpString::newBuffer(zeus::Buffer& _buffer) {
|
||||
ZEUS_VERBOSE("Receive Binary :" << _buffer.generateHumanString());
|
||||
zeus::FutureBase future;
|
||||
uint64_t tid = _buffer.getTransactionId();
|
||||
if (tid == 0) {
|
||||
JUS_ERROR("Get a Protocol error ... No ID ...");
|
||||
ZEUS_ERROR("Get a Protocol error ... No ID ...");
|
||||
/*
|
||||
if (obj["error"].toString().get() == "PROTOCOL-ERROR") {
|
||||
JUS_ERROR("Get a Protocol error ...");
|
||||
ZEUS_ERROR("Get a Protocol error ...");
|
||||
std::unique_lock<std::mutex> lock(m_mutex);
|
||||
for (auto &it : m_pendingCall) {
|
||||
if (it.isValid() == false) {
|
||||
@ -247,7 +152,7 @@ void jus::TcpString::newBuffer(jus::Buffer& _buffer) {
|
||||
}
|
||||
m_pendingCall.clear();
|
||||
} else {
|
||||
JUS_ERROR("call with no ID ==> error ...");
|
||||
ZEUS_ERROR("call with no ID ==> error ...");
|
||||
}
|
||||
*/
|
||||
return;
|
||||
@ -294,11 +199,11 @@ void jus::TcpString::newBuffer(jus::Buffer& _buffer) {
|
||||
}
|
||||
}
|
||||
|
||||
void jus::TcpString::threadAsyncCallback() {
|
||||
void zeus::TcpString::threadAsyncCallback() {
|
||||
ethread::setName("Async-sender");
|
||||
// get datas:
|
||||
while ( m_threadAsyncRunning == true
|
||||
&& m_connection.getConnectionStatus() == enet::Tcp::status::link) {
|
||||
&& m_connection.isAlive() == true) {
|
||||
if (m_threadAsyncList.size() == 0) {
|
||||
usleep(10000);
|
||||
continue;
|
||||
@ -315,28 +220,25 @@ void jus::TcpString::threadAsyncCallback() {
|
||||
}
|
||||
}
|
||||
}
|
||||
m_threadRunning = false;
|
||||
JUS_DEBUG("End of thread");
|
||||
m_threadAsyncRunning = false;
|
||||
ZEUS_DEBUG("End of thread");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
class SendAsyncBinary {
|
||||
private:
|
||||
std::vector<jus::ActionAsyncClient> m_async;
|
||||
std::vector<zeus::ActionAsyncClient> m_async;
|
||||
uint64_t m_transactionId;
|
||||
uint32_t m_serviceId;
|
||||
uint32_t m_partId;
|
||||
public:
|
||||
SendAsyncBinary(uint64_t _transactionId, const uint32_t& _serviceId, const std::vector<jus::ActionAsyncClient>& _async) :
|
||||
SendAsyncBinary(uint64_t _transactionId, const uint32_t& _serviceId, const std::vector<zeus::ActionAsyncClient>& _async) :
|
||||
m_async(_async),
|
||||
m_transactionId(_transactionId),
|
||||
m_serviceId(_serviceId),
|
||||
m_partId(1) {
|
||||
|
||||
}
|
||||
bool operator() (jus::TcpString* _interface){
|
||||
bool operator() (zeus::TcpString* _interface){
|
||||
auto it = m_async.begin();
|
||||
while (it != m_async.end()) {
|
||||
bool ret = (*it)(_interface, m_serviceId, m_transactionId, m_partId);
|
||||
@ -349,7 +251,7 @@ class SendAsyncBinary {
|
||||
m_partId++;
|
||||
}
|
||||
if (m_async.size() == 0) {
|
||||
jus::Buffer obj;
|
||||
zeus::Buffer obj;
|
||||
obj.setServiceId(m_serviceId);
|
||||
obj.setTransactionId(m_transactionId);
|
||||
obj.setPartId(m_partId);
|
||||
@ -361,19 +263,19 @@ class SendAsyncBinary {
|
||||
}
|
||||
};
|
||||
|
||||
jus::FutureBase jus::TcpString::callBinary(uint64_t _transactionId,
|
||||
jus::Buffer& _obj,
|
||||
zeus::FutureBase zeus::TcpString::callBinary(uint64_t _transactionId,
|
||||
zeus::Buffer& _obj,
|
||||
const std::vector<ActionAsyncClient>& _async,
|
||||
jus::FutureData::ObserverFinish _callback,
|
||||
zeus::FutureData::ObserverFinish _callback,
|
||||
const uint32_t& _serviceId) {
|
||||
JUS_VERBOSE("Send Binary [START] ");
|
||||
ZEUS_VERBOSE("Send Binary [START] ");
|
||||
if (isActive() == false) {
|
||||
jus::Buffer obj;
|
||||
obj.setType(jus::Buffer::typeMessage::answer);
|
||||
zeus::Buffer obj;
|
||||
obj.setType(zeus::Buffer::typeMessage::answer);
|
||||
obj.addError("NOT-CONNECTED", "Client interface not connected (no TCP)");
|
||||
return jus::FutureBase(_transactionId, true, obj, _callback);
|
||||
return zeus::FutureBase(_transactionId, true, obj, _callback);
|
||||
}
|
||||
jus::FutureBase tmpFuture(_transactionId, _callback);
|
||||
zeus::FutureBase tmpFuture(_transactionId, _callback);
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(m_pendingCallMutex);
|
||||
m_pendingCall.push_back(std::make_pair(uint64_t(0), tmpFuture));
|
||||
@ -388,45 +290,45 @@ jus::FutureBase jus::TcpString::callBinary(uint64_t _transactionId,
|
||||
if (_async.size() != 0) {
|
||||
addAsync(SendAsyncBinary(_transactionId, _serviceId, _async));
|
||||
}
|
||||
JUS_VERBOSE("Send Binary [STOP]");
|
||||
ZEUS_VERBOSE("Send Binary [STOP]");
|
||||
return tmpFuture;
|
||||
}
|
||||
|
||||
jus::FutureBase jus::TcpString::callForward(uint32_t _clientId,
|
||||
jus::Buffer& _buffer,
|
||||
zeus::FutureBase zeus::TcpString::callForward(uint32_t _clientId,
|
||||
zeus::Buffer& _buffer,
|
||||
uint64_t _singleReferenceId,
|
||||
jus::FutureData::ObserverFinish _callback) {
|
||||
JUS_VERBOSE("Call Forward [START]");
|
||||
//jus::FutureBase ret = callBinary(id, _Buffer, async, _callback);
|
||||
zeus::FutureData::ObserverFinish _callback) {
|
||||
ZEUS_VERBOSE("Call Forward [START]");
|
||||
//zeus::FutureBase ret = callBinary(id, _Buffer, async, _callback);
|
||||
//ret.setSynchronous();
|
||||
|
||||
if (isActive() == false) {
|
||||
jus::Buffer obj;
|
||||
obj.setType(jus::Buffer::typeMessage::answer);
|
||||
zeus::Buffer obj;
|
||||
obj.setType(zeus::Buffer::typeMessage::answer);
|
||||
obj.addError("NOT-CONNECTED", "Client interface not connected (no TCP)");
|
||||
return jus::FutureBase(0, true, obj, _callback);
|
||||
return zeus::FutureBase(0, true, obj, _callback);
|
||||
}
|
||||
uint64_t id = getId();
|
||||
_buffer.setTransactionId(id);
|
||||
_buffer.setClientId(_clientId);
|
||||
jus::FutureBase tmpFuture(id, _callback);
|
||||
zeus::FutureBase tmpFuture(id, _callback);
|
||||
tmpFuture.setSynchronous();
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(m_pendingCallMutex);
|
||||
m_pendingCall.push_back(std::make_pair(_singleReferenceId, tmpFuture));
|
||||
}
|
||||
writeBinary(_buffer);
|
||||
JUS_VERBOSE("Send Forward [STOP]");
|
||||
ZEUS_VERBOSE("Send Forward [STOP]");
|
||||
return tmpFuture;
|
||||
}
|
||||
|
||||
void jus::TcpString::callForwardMultiple(uint32_t _clientId,
|
||||
jus::Buffer& _buffer,
|
||||
void zeus::TcpString::callForwardMultiple(uint32_t _clientId,
|
||||
zeus::Buffer& _buffer,
|
||||
uint64_t _singleReferenceId){
|
||||
// subMessage ... ==> try to forward message:
|
||||
std::unique_lock<std::mutex> lock(m_pendingCallMutex);
|
||||
for (auto &itCall : m_pendingCall) {
|
||||
JUS_INFO(" compare : " << itCall.first << " =?= " << _singleReferenceId);
|
||||
ZEUS_INFO(" compare : " << itCall.first << " =?= " << _singleReferenceId);
|
||||
if (itCall.first == _singleReferenceId) {
|
||||
// Find element ==> transit it ...
|
||||
_buffer.setTransactionId(itCall.second.getTransactionId());
|
||||
@ -435,12 +337,12 @@ void jus::TcpString::callForwardMultiple(uint32_t _clientId,
|
||||
return;
|
||||
}
|
||||
}
|
||||
JUS_ERROR("Can not transfer part of a message ...");
|
||||
ZEUS_ERROR("Can not transfer part of a message ...");
|
||||
}
|
||||
|
||||
void jus::TcpString::answerError(uint64_t _clientTransactionId, const std::string& _errorValue, const std::string& _errorHelp, uint32_t _clientId) {
|
||||
jus::Buffer answer;
|
||||
answer.setType(jus::Buffer::typeMessage::answer);
|
||||
void zeus::TcpString::answerError(uint64_t _clientTransactionId, const std::string& _errorValue, const std::string& _errorHelp, uint32_t _clientId) {
|
||||
zeus::Buffer answer;
|
||||
answer.setType(zeus::Buffer::typeMessage::answer);
|
||||
answer.setTransactionId(_clientTransactionId);
|
||||
answer.setClientId(_clientId);
|
||||
answer.addError(_errorValue, _errorHelp);
|
||||
@ -448,9 +350,9 @@ void jus::TcpString::answerError(uint64_t _clientTransactionId, const std::strin
|
||||
}
|
||||
|
||||
|
||||
void jus::TcpString::answerVoid(uint64_t _clientTransactionId, uint32_t _clientId) {
|
||||
jus::Buffer answer;
|
||||
answer.setType(jus::Buffer::typeMessage::answer);
|
||||
void zeus::TcpString::answerVoid(uint64_t _clientTransactionId, uint32_t _clientId) {
|
||||
zeus::Buffer answer;
|
||||
answer.setType(zeus::Buffer::typeMessage::answer);
|
||||
answer.setTransactionId(_clientTransactionId);
|
||||
answer.setClientId(_clientId);
|
||||
answer.addParameter();
|
||||
|
@ -6,31 +6,25 @@
|
||||
#pragma once
|
||||
#include <eproperty/Value.h>
|
||||
#include <esignal/Signal.h>
|
||||
#include <jus/Buffer.h>
|
||||
#include <enet/Tcp.h>
|
||||
#include <zeus/Buffer.h>
|
||||
#include <enet/WebSocket.h>
|
||||
#include <thread>
|
||||
#include <memory>
|
||||
#include <jus/AbstractFunction.h>
|
||||
#include <jus/FutureBase.h>
|
||||
#include <zeus/AbstractFunction.h>
|
||||
#include <zeus/FutureBase.h>
|
||||
|
||||
namespace jus {
|
||||
namespace zeus {
|
||||
class TcpString : public eproperty::Interface {
|
||||
private:
|
||||
enet::Tcp m_connection;
|
||||
std::thread* m_thread;
|
||||
bool m_threadRunning;
|
||||
enet::WebSocket m_connection;
|
||||
uint16_t m_transmissionId;
|
||||
uint16_t getId() {
|
||||
return m_transmissionId++;
|
||||
}
|
||||
std::mutex m_pendingCallMutex;
|
||||
std::vector<std::pair<uint64_t, jus::FutureBase>> m_pendingCall;
|
||||
std::vector<uint8_t> m_buffer;
|
||||
std::vector<uint8_t> m_temporaryBuffer;
|
||||
std::chrono::steady_clock::time_point m_lastReceive;
|
||||
std::chrono::steady_clock::time_point m_lastSend;
|
||||
std::vector<std::pair<uint64_t, zeus::FutureBase>> m_pendingCall;
|
||||
public:
|
||||
using Observer = std::function<void(jus::Buffer&)>; //!< Define an Observer: function pointer
|
||||
using Observer = std::function<void(zeus::Buffer&)>; //!< Define an Observer: function pointer
|
||||
Observer m_observerElement;
|
||||
/**
|
||||
* @brief Connect an function member on the signal with the shared_ptr object.
|
||||
@ -39,34 +33,32 @@ namespace jus {
|
||||
* @param[in] _args Argument optinnal the user want to add.
|
||||
*/
|
||||
template<class CLASS_TYPE>
|
||||
void connect(CLASS_TYPE* _class, void (CLASS_TYPE::*_func)(jus::Buffer&)) {
|
||||
m_observerElement = [=](jus::Buffer& _value){
|
||||
void connect(CLASS_TYPE* _class, void (CLASS_TYPE::*_func)(zeus::Buffer&)) {
|
||||
m_observerElement = [=](zeus::Buffer& _value){
|
||||
(*_class.*_func)(_value);
|
||||
};
|
||||
}
|
||||
public:
|
||||
TcpString();
|
||||
TcpString(enet::Tcp _connection);
|
||||
TcpString(enet::Tcp _connection, bool _isServer);
|
||||
virtual ~TcpString();
|
||||
void setInterface(enet::Tcp _connection);
|
||||
void setInterface(enet::Tcp _connection, bool _isServer);
|
||||
void connect(bool _async = false);
|
||||
void disconnect(bool _inThreadStop = false);
|
||||
bool isActive() const;
|
||||
void setInterfaceName(const std::string& _name);
|
||||
int32_t writeBinary(jus::Buffer& _data);
|
||||
std::string asyncRead();
|
||||
int32_t writeBinary(zeus::Buffer& _data);
|
||||
void ping();
|
||||
private:
|
||||
void read();
|
||||
|
||||
void newBuffer(jus::Buffer& _buffer);
|
||||
private:
|
||||
void threadCallback();
|
||||
bool onReceiveUri(const std::string& _uri);
|
||||
void onReceiveData(std::vector<uint8_t>& _frame, bool _isBinary);
|
||||
void newBuffer(zeus::Buffer& _buffer);
|
||||
public:
|
||||
const std::chrono::steady_clock::time_point& getLastTimeReceive() {
|
||||
return m_lastReceive;
|
||||
return m_connection.getLastTimeReceive();
|
||||
}
|
||||
const std::chrono::steady_clock::time_point& getLastTimeSend() {
|
||||
return m_lastSend;
|
||||
return m_connection.getLastTimeSend();
|
||||
}
|
||||
private:
|
||||
using ActionAsync = std::function<bool(TcpString* _interface)>;
|
||||
@ -82,69 +74,69 @@ namespace jus {
|
||||
m_threadAsyncList.push_back(_elem);
|
||||
}
|
||||
private:
|
||||
jus::FutureBase callBinary(uint64_t _transactionId,
|
||||
jus::Buffer& _obj,
|
||||
zeus::FutureBase callBinary(uint64_t _transactionId,
|
||||
zeus::Buffer& _obj,
|
||||
const std::vector<ActionAsyncClient>& _async,
|
||||
jus::FutureData::ObserverFinish _callback=nullptr,
|
||||
zeus::FutureData::ObserverFinish _callback=nullptr,
|
||||
const uint32_t& _service=0);
|
||||
public: // section call direct
|
||||
template<class... _ARGS>
|
||||
jus::FutureBase call(const std::string& _functionName, _ARGS&&... _args) {
|
||||
zeus::FutureBase call(const std::string& _functionName, _ARGS&&... _args) {
|
||||
uint16_t id = getId();
|
||||
std::vector<jus::ActionAsyncClient> asyncAction;
|
||||
jus::Buffer callElem = jus::createBinaryCall(asyncAction, id, _functionName, std::forward<_ARGS>(_args)...);
|
||||
std::vector<zeus::ActionAsyncClient> asyncAction;
|
||||
zeus::Buffer callElem = zeus::createBinaryCall(asyncAction, id, _functionName, std::forward<_ARGS>(_args)...);
|
||||
return callBinary(id, callElem, asyncAction);
|
||||
}
|
||||
template<class... _ARGS>
|
||||
jus::FutureBase callAction(const std::string& _functionName, _ARGS&&... _args, jus::FutureData::ObserverFinish _callback) {
|
||||
zeus::FutureBase callAction(const std::string& _functionName, _ARGS&&... _args, zeus::FutureData::ObserverFinish _callback) {
|
||||
uint16_t id = getId();
|
||||
std::vector<jus::ActionAsyncClient> asyncAction;
|
||||
jus::Buffer callElem = jus::createBinaryCall(asyncAction, id, _functionName, std::forward<_ARGS>(_args)...);
|
||||
std::vector<zeus::ActionAsyncClient> asyncAction;
|
||||
zeus::Buffer callElem = zeus::createBinaryCall(asyncAction, id, _functionName, std::forward<_ARGS>(_args)...);
|
||||
return callBinary(id, callElem, asyncAction, _callback);
|
||||
}
|
||||
public: // section call with service ID / Client ID
|
||||
|
||||
template<class... _ARGS>
|
||||
jus::FutureBase callService(uint32_t _serviceId, const std::string& _functionName, _ARGS&&... _args) {
|
||||
zeus::FutureBase callService(uint32_t _serviceId, const std::string& _functionName, _ARGS&&... _args) {
|
||||
uint16_t id = getId();
|
||||
std::vector<jus::ActionAsyncClient> asyncActionToDo;
|
||||
jus::Buffer callElem = jus::createBinaryCallService(asyncActionToDo, id, _serviceId, _functionName, std::forward<_ARGS>(_args)...);
|
||||
std::vector<zeus::ActionAsyncClient> asyncActionToDo;
|
||||
zeus::Buffer callElem = zeus::createBinaryCallService(asyncActionToDo, id, _serviceId, _functionName, std::forward<_ARGS>(_args)...);
|
||||
return callBinary(id, callElem, asyncActionToDo);
|
||||
}
|
||||
template<class... _ARGS>
|
||||
jus::FutureBase callServiceAction(uint32_t _serviceId, const std::string& _functionName, _ARGS&&... _args, jus::FutureData::ObserverFinish _callback) {
|
||||
zeus::FutureBase callServiceAction(uint32_t _serviceId, const std::string& _functionName, _ARGS&&... _args, zeus::FutureData::ObserverFinish _callback) {
|
||||
uint16_t id = getId();
|
||||
std::vector<jus::ActionAsyncClient> asyncActionToDo;
|
||||
jus::Buffer callElem = jus::createBinaryCallService(asyncActionToDo, id, _serviceId, _functionName, std::forward<_ARGS>(_args)...);
|
||||
std::vector<zeus::ActionAsyncClient> asyncActionToDo;
|
||||
zeus::Buffer callElem = zeus::createBinaryCallService(asyncActionToDo, id, _serviceId, _functionName, std::forward<_ARGS>(_args)...);
|
||||
return callBinary(id, callElem, asyncActionToDo, _callback);
|
||||
}
|
||||
template<class... _ARGS>
|
||||
jus::FutureBase callClient(uint32_t _clientId,
|
||||
zeus::FutureBase callClient(uint32_t _clientId,
|
||||
const std::string& _functionName,
|
||||
_ARGS&&... _args) {
|
||||
return callService(_clientId, _functionName, _args...);
|
||||
}
|
||||
template<class... _ARGS>
|
||||
jus::FutureBase callClientAction(uint32_t _clientId,
|
||||
zeus::FutureBase callClientAction(uint32_t _clientId,
|
||||
const std::string& _functionName,
|
||||
_ARGS&&... _args,
|
||||
jus::FutureData::ObserverFinish _callback) {
|
||||
zeus::FutureData::ObserverFinish _callback) {
|
||||
return callServiceAction(_clientId, _functionName, _args..., _callback);
|
||||
}
|
||||
jus::FutureBase callForward(uint32_t _clientId,
|
||||
jus::Buffer& _Buffer,
|
||||
zeus::FutureBase callForward(uint32_t _clientId,
|
||||
zeus::Buffer& _Buffer,
|
||||
uint64_t _singleReferenceId,
|
||||
jus::FutureData::ObserverFinish _callback);
|
||||
zeus::FutureData::ObserverFinish _callback);
|
||||
void callForwardMultiple(uint32_t _clientId,
|
||||
jus::Buffer& _Buffer,
|
||||
zeus::Buffer& _Buffer,
|
||||
uint64_t _singleReferenceId);
|
||||
public: // answers ...
|
||||
|
||||
void answerProtocolError(uint32_t _transactionId, const std::string& _errorHelp);
|
||||
template<class JUS_ARG>
|
||||
void answerValue(uint64_t _clientTransactionId, JUS_ARG _value, uint32_t _clientId=0) {
|
||||
jus::Buffer answer;
|
||||
answer.setType(jus::Buffer::typeMessage::answer);
|
||||
template<class ZEUS_ARG>
|
||||
void answerValue(uint64_t _clientTransactionId, ZEUS_ARG _value, uint32_t _clientId=0) {
|
||||
zeus::Buffer answer;
|
||||
answer.setType(zeus::Buffer::typeMessage::answer);
|
||||
answer.setTransactionId(_clientTransactionId);
|
||||
answer.setClientId(_clientId);
|
||||
answer.addAnswer(_value);
|
||||
|
@ -4,9 +4,9 @@
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <jus/debug.h>
|
||||
#include <zeus/debug.h>
|
||||
|
||||
int32_t jus::getLogId() {
|
||||
static int32_t g_val = elog::registerInstance("jus");
|
||||
int32_t zeus::getLogId() {
|
||||
static int32_t g_val = elog::registerInstance("zeus");
|
||||
return g_val;
|
||||
}
|
||||
|
32
zeus/debug.h
32
zeus/debug.h
@ -7,32 +7,32 @@
|
||||
|
||||
#include <elog/log.h>
|
||||
|
||||
namespace jus {
|
||||
namespace zeus {
|
||||
int32_t getLogId();
|
||||
};
|
||||
|
||||
#define JUS_BASE(info,data) ELOG_BASE(jus::getLogId(),info,data)
|
||||
#define ZEUS_BASE(info,data) ELOG_BASE(zeus::getLogId(),info,data)
|
||||
|
||||
#define JUS_PRINT(data) JUS_BASE(-1, data)
|
||||
#define JUS_CRITICAL(data) JUS_BASE(1, data)
|
||||
#define JUS_ERROR(data) JUS_BASE(2, data)
|
||||
#define JUS_WARNING(data) JUS_BASE(3, data)
|
||||
#define ZEUS_PRINT(data) ZEUS_BASE(-1, data)
|
||||
#define ZEUS_CRITICAL(data) ZEUS_BASE(1, data)
|
||||
#define ZEUS_ERROR(data) ZEUS_BASE(2, data)
|
||||
#define ZEUS_WARNING(data) ZEUS_BASE(3, data)
|
||||
#ifdef DEBUG
|
||||
#define JUS_INFO(data) JUS_BASE(4, data)
|
||||
#define JUS_DEBUG(data) JUS_BASE(5, data)
|
||||
#define JUS_VERBOSE(data) JUS_BASE(6, data)
|
||||
#define JUS_TODO(data) JUS_BASE(4, "TODO : " << data)
|
||||
#define ZEUS_INFO(data) ZEUS_BASE(4, data)
|
||||
#define ZEUS_DEBUG(data) ZEUS_BASE(5, data)
|
||||
#define ZEUS_VERBOSE(data) ZEUS_BASE(6, data)
|
||||
#define ZEUS_TODO(data) ZEUS_BASE(4, "TODO : " << data)
|
||||
#else
|
||||
#define JUS_INFO(data) do { } while(false)
|
||||
#define JUS_DEBUG(data) do { } while(false)
|
||||
#define JUS_VERBOSE(data) do { } while(false)
|
||||
#define JUS_TODO(data) do { } while(false)
|
||||
#define ZEUS_INFO(data) do { } while(false)
|
||||
#define ZEUS_DEBUG(data) do { } while(false)
|
||||
#define ZEUS_VERBOSE(data) do { } while(false)
|
||||
#define ZEUS_TODO(data) do { } while(false)
|
||||
#endif
|
||||
|
||||
#define JUS_ASSERT(cond,data) \
|
||||
#define ZEUS_ASSERT(cond,data) \
|
||||
do { \
|
||||
if (!(cond)) { \
|
||||
JUS_CRITICAL(data); \
|
||||
ZEUS_CRITICAL(data); \
|
||||
assert(!#cond); \
|
||||
} \
|
||||
} while (0)
|
||||
|
@ -4,8 +4,8 @@
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <jus/mineType.h>
|
||||
#include <jus/debug.h>
|
||||
#include <zeus/mineType.h>
|
||||
#include <zeus/debug.h>
|
||||
|
||||
|
||||
static std::vector<std::pair<std::string, std::string>> mineList = {
|
||||
@ -113,22 +113,22 @@ static std::vector<std::pair<std::string, std::string>> mineList = {
|
||||
{ "ifo", "text/ifo"}, /* DVD information */
|
||||
};
|
||||
|
||||
std::string jus::getMineType(const std::string& _extention) {
|
||||
std::string zeus::getMineType(const std::string& _extention) {
|
||||
for (auto &it : mineList) {
|
||||
if (it.first == _extention) {
|
||||
return it.second;
|
||||
}
|
||||
}
|
||||
JUS_ERROR(" try to cenvert mine type: " << _extention);
|
||||
ZEUS_ERROR(" try to cenvert mine type: " << _extention);
|
||||
return "";
|
||||
}
|
||||
|
||||
std::string jus::getExtention(const std::string& _mineType) {
|
||||
std::string zeus::getExtention(const std::string& _mineType) {
|
||||
for (auto &it : mineList) {
|
||||
if (it.second == _mineType) {
|
||||
return it.first;
|
||||
}
|
||||
}
|
||||
JUS_ERROR(" try to cenvert extention: " << _mineType);
|
||||
ZEUS_ERROR(" try to cenvert extention: " << _mineType);
|
||||
return "";
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
#pragma once
|
||||
#include <etk/types.h>
|
||||
|
||||
namespace jus {
|
||||
namespace zeus {
|
||||
std::string getMineType(const std::string& _extention);
|
||||
std::string getExtention(const std::string& _mineType);
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user