[DEBUG/DEV] Correct compile with gcc and try think connection management
This commit is contained in:
parent
181930f01d
commit
1891295eff
@ -5,119 +5,120 @@
|
||||
*/
|
||||
#include <jus/AbstractFunction.h>
|
||||
#include <jus/debug.h>
|
||||
|
||||
template<> bool jus::convertJsonTo<bool>(const ejson::Value& _value) {
|
||||
namespace jus {
|
||||
template<> bool convertJsonTo<bool>(const ejson::Value& _value) {
|
||||
return _value.toBoolean().get();
|
||||
}
|
||||
template<> float jus::convertJsonTo<float>(const ejson::Value& _value) {
|
||||
template<> float convertJsonTo<float>(const ejson::Value& _value) {
|
||||
return _value.toNumber().get();
|
||||
}
|
||||
template<> double jus::convertJsonTo<double>(const ejson::Value& _value) {
|
||||
template<> double convertJsonTo<double>(const ejson::Value& _value) {
|
||||
return _value.toNumber().get();
|
||||
}
|
||||
template<> int64_t jus::convertJsonTo<int64_t>(const ejson::Value& _value) {
|
||||
template<> int64_t convertJsonTo<int64_t>(const ejson::Value& _value) {
|
||||
return int64_t(_value.toNumber().get());
|
||||
}
|
||||
template<> int32_t jus::convertJsonTo<int32_t>(const ejson::Value& _value) {
|
||||
template<> int32_t convertJsonTo<int32_t>(const ejson::Value& _value) {
|
||||
//_value.display();
|
||||
return int32_t(_value.toNumber().get());
|
||||
}
|
||||
template<> int16_t jus::convertJsonTo<int16_t>(const ejson::Value& _value) {
|
||||
template<> int16_t convertJsonTo<int16_t>(const ejson::Value& _value) {
|
||||
return int16_t(_value.toNumber().get());
|
||||
}
|
||||
template<> int8_t jus::convertJsonTo<int8_t>(const ejson::Value& _value) {
|
||||
template<> int8_t convertJsonTo<int8_t>(const ejson::Value& _value) {
|
||||
return int8_t(_value.toNumber().get());
|
||||
}
|
||||
template<> uint64_t jus::convertJsonTo<uint64_t>(const ejson::Value& _value) {
|
||||
template<> uint64_t convertJsonTo<uint64_t>(const ejson::Value& _value) {
|
||||
return uint64_t(_value.toNumber().get());
|
||||
}
|
||||
template<> uint32_t jus::convertJsonTo<uint32_t>(const ejson::Value& _value) {
|
||||
template<> uint32_t convertJsonTo<uint32_t>(const ejson::Value& _value) {
|
||||
return uint32_t(_value.toNumber().get());
|
||||
}
|
||||
template<> uint16_t jus::convertJsonTo<uint16_t>(const ejson::Value& _value) {
|
||||
template<> uint16_t convertJsonTo<uint16_t>(const ejson::Value& _value) {
|
||||
return uint16_t(_value.toNumber().get());
|
||||
}
|
||||
template<> uint8_t jus::convertJsonTo<uint8_t>(const ejson::Value& _value) {
|
||||
template<> uint8_t convertJsonTo<uint8_t>(const ejson::Value& _value) {
|
||||
return uint8_t(_value.toNumber().get());
|
||||
}
|
||||
template<> std::string jus::convertJsonTo<std::string>(const ejson::Value& _value) {
|
||||
template<> std::string convertJsonTo<std::string>(const ejson::Value& _value) {
|
||||
//_value.display();
|
||||
return _value.toString().get();
|
||||
}
|
||||
|
||||
template<> ejson::Value jus::convertToJson<bool>(const bool& _value) {
|
||||
template<> ejson::Value convertToJson<bool>(const bool& _value) {
|
||||
return ejson::Boolean(_value);
|
||||
}
|
||||
template<> ejson::Value jus::convertToJson<float>(const float& _value) {
|
||||
template<> ejson::Value convertToJson<float>(const float& _value) {
|
||||
return ejson::Number(_value);
|
||||
}
|
||||
template<> ejson::Value jus::convertToJson<double>(const double& _value) {
|
||||
template<> ejson::Value convertToJson<double>(const double& _value) {
|
||||
return ejson::Number(_value);
|
||||
}
|
||||
template<> ejson::Value jus::convertToJson<int64_t>(const int64_t& _value) {
|
||||
template<> ejson::Value convertToJson<int64_t>(const int64_t& _value) {
|
||||
return ejson::Number(_value);
|
||||
}
|
||||
template<> ejson::Value jus::convertToJson<int32_t>(const int32_t& _value) {
|
||||
template<> ejson::Value convertToJson<int32_t>(const int32_t& _value) {
|
||||
return ejson::Number(_value);
|
||||
}
|
||||
template<> ejson::Value jus::convertToJson<int16_t>(const int16_t& _value) {
|
||||
template<> ejson::Value convertToJson<int16_t>(const int16_t& _value) {
|
||||
return ejson::Number(_value);
|
||||
}
|
||||
template<> ejson::Value jus::convertToJson<int8_t>(const int8_t& _value) {
|
||||
template<> ejson::Value convertToJson<int8_t>(const int8_t& _value) {
|
||||
return ejson::Number(_value);
|
||||
}
|
||||
template<> ejson::Value jus::convertToJson<uint64_t>(const uint64_t& _value) {
|
||||
template<> ejson::Value convertToJson<uint64_t>(const uint64_t& _value) {
|
||||
return ejson::Number(_value);
|
||||
}
|
||||
template<> ejson::Value jus::convertToJson<uint32_t>(const uint32_t& _value) {
|
||||
template<> ejson::Value convertToJson<uint32_t>(const uint32_t& _value) {
|
||||
return ejson::Number(_value);
|
||||
}
|
||||
template<> ejson::Value jus::convertToJson<uint16_t>(const uint16_t& _value) {
|
||||
template<> ejson::Value convertToJson<uint16_t>(const uint16_t& _value) {
|
||||
return ejson::Number(_value);
|
||||
}
|
||||
template<> ejson::Value jus::convertToJson<uint8_t>(const uint8_t& _value) {
|
||||
template<> ejson::Value convertToJson<uint8_t>(const uint8_t& _value) {
|
||||
return ejson::Number(_value);
|
||||
}
|
||||
template<> ejson::Value jus::convertToJson<std::string>(const std::string& _value) {
|
||||
template<> ejson::Value convertToJson<std::string>(const std::string& _value) {
|
||||
return ejson::String(_value);
|
||||
}
|
||||
|
||||
template<> bool jus::convertStringTo<bool>(const std::string& _value) {
|
||||
template<> bool convertStringTo<bool>(const std::string& _value) {
|
||||
return etk::string_to_bool(_value);
|
||||
}
|
||||
template<> float jus::convertStringTo<float>(const std::string& _value) {
|
||||
template<> float convertStringTo<float>(const std::string& _value) {
|
||||
return etk::string_to_float(_value);
|
||||
}
|
||||
template<> double jus::convertStringTo<double>(const std::string& _value) {
|
||||
template<> double convertStringTo<double>(const std::string& _value) {
|
||||
return etk::string_to_double(_value);
|
||||
}
|
||||
template<> int64_t jus::convertStringTo<int64_t>(const std::string& _value) {
|
||||
template<> int64_t convertStringTo<int64_t>(const std::string& _value) {
|
||||
return etk::string_to_int64_t(_value);
|
||||
}
|
||||
template<> int32_t jus::convertStringTo<int32_t>(const std::string& _value) {
|
||||
template<> int32_t convertStringTo<int32_t>(const std::string& _value) {
|
||||
return etk::string_to_int32_t(_value);
|
||||
}
|
||||
template<> int16_t jus::convertStringTo<int16_t>(const std::string& _value) {
|
||||
template<> int16_t convertStringTo<int16_t>(const std::string& _value) {
|
||||
return etk::string_to_int16_t(_value);
|
||||
}
|
||||
template<> int8_t jus::convertStringTo<int8_t>(const std::string& _value) {
|
||||
template<> int8_t convertStringTo<int8_t>(const std::string& _value) {
|
||||
return etk::string_to_int8_t(_value);
|
||||
}
|
||||
template<> uint64_t jus::convertStringTo<uint64_t>(const std::string& _value) {
|
||||
template<> uint64_t convertStringTo<uint64_t>(const std::string& _value) {
|
||||
return etk::string_to_uint64_t(_value);
|
||||
}
|
||||
template<> uint32_t jus::convertStringTo<uint32_t>(const std::string& _value) {
|
||||
template<> uint32_t convertStringTo<uint32_t>(const std::string& _value) {
|
||||
return etk::string_to_uint32_t(_value);
|
||||
}
|
||||
template<> uint16_t jus::convertStringTo<uint16_t>(const std::string& _value) {
|
||||
template<> uint16_t convertStringTo<uint16_t>(const std::string& _value) {
|
||||
return etk::string_to_uint16_t(_value);
|
||||
}
|
||||
template<> uint8_t jus::convertStringTo<uint8_t>(const std::string& _value) {
|
||||
template<> uint8_t convertStringTo<uint8_t>(const std::string& _value) {
|
||||
return etk::string_to_uint8_t(_value);
|
||||
}
|
||||
template<> std::string jus::convertStringTo<std::string>(const std::string& _value) {
|
||||
template<> std::string convertStringTo<std::string>(const std::string& _value) {
|
||||
return _value;
|
||||
}
|
||||
}
|
||||
|
||||
const std::string& jus::AbstractFunction::getName() const {
|
||||
return m_name;
|
||||
|
@ -14,15 +14,15 @@ 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),
|
||||
m_id(0) {
|
||||
m_dataCallback = m_interfaceClient.signalData.connect(this, &jus::Client::onClientData);
|
||||
m_interfaceClient.connect(this, &jus::Client::onClientData);
|
||||
}
|
||||
|
||||
jus::Client::~Client() {
|
||||
|
||||
}
|
||||
|
||||
void jus::Client::onClientData(const std::string& _value) {
|
||||
m_newData.push_back(_value);
|
||||
void jus::Client::onClientData(std::string _value) {
|
||||
m_newData.push_back(std::move(_value));
|
||||
}
|
||||
|
||||
jus::ServiceRemote jus::Client::getService(const std::string& _name) {
|
||||
|
@ -20,7 +20,6 @@ namespace jus {
|
||||
private:
|
||||
jus::TcpString m_interfaceClient;
|
||||
uint32_t m_id;
|
||||
esignal::Connection m_dataCallback;
|
||||
std::vector<std::string> m_newData;
|
||||
public:
|
||||
Client();
|
||||
@ -32,7 +31,7 @@ namespace jus {
|
||||
void link(const std::string& _serviceName);
|
||||
void unlink(const std::string& _serviceName);
|
||||
private:
|
||||
void onClientData(const std::string& _value);
|
||||
void onClientData(std::string _value);
|
||||
std::string asyncRead();
|
||||
ejson::Object callJson(const ejson::Object& _obj);
|
||||
ejson::Object createBaseCall(const std::string& _functionName, const std::string& _service="");
|
||||
|
@ -28,7 +28,7 @@ jus::GateWayClient::~GateWayClient() {
|
||||
|
||||
void jus::GateWayClient::start(size_t _uid) {
|
||||
m_uid = _uid;
|
||||
m_dataCallback = m_interfaceClient.signalData.connect(this, &jus::GateWayClient::onClientData);
|
||||
m_interfaceClient.connect(this, &jus::GateWayClient::onClientData);
|
||||
m_interfaceClient.connect(true);
|
||||
m_interfaceClient.setInterfaceName("cli-" + etk::to_string(m_uid));
|
||||
}
|
||||
@ -48,7 +48,7 @@ bool jus::GateWayClient::isAlive() {
|
||||
return m_interfaceClient.isActive();
|
||||
}
|
||||
|
||||
void jus::GateWayClient::onClientData(const std::string& _value) {
|
||||
void jus::GateWayClient::onClientData(std::string _value) {
|
||||
JUS_DEBUG("On data: " << _value);
|
||||
ejson::Object data(_value);
|
||||
if (m_userConnectionName == "") {
|
||||
|
@ -18,7 +18,6 @@ namespace jus {
|
||||
jus::TcpString m_interfaceClient;
|
||||
public:
|
||||
esignal::Signal<bool> signalIsConnected;
|
||||
esignal::Connection m_dataCallback;
|
||||
std::vector<ememory::SharedPtr<jus::GateWayService>> m_listConnectedService;
|
||||
size_t m_uid;
|
||||
std::string m_userConnectionName;
|
||||
@ -27,7 +26,7 @@ namespace jus {
|
||||
virtual ~GateWayClient();
|
||||
void start(size_t _uid);
|
||||
void stop();
|
||||
void onClientData(const std::string& _value);
|
||||
void onClientData(std::string _value);
|
||||
void returnMessage(ejson::Object _data);
|
||||
size_t getId() const {
|
||||
return m_uid;
|
||||
|
@ -29,7 +29,7 @@ bool jus::GateWayService::isAlive() {
|
||||
}
|
||||
|
||||
void jus::GateWayService::start() {
|
||||
m_dataCallback = m_interfaceClient.signalData.connect(this, &jus::GateWayService::onServiceData);
|
||||
m_interfaceClient.connect(this, &jus::GateWayService::onServiceData);
|
||||
m_interfaceClient.connect();
|
||||
m_interfaceClient.setInterfaceName("srv-?");
|
||||
}
|
||||
@ -45,7 +45,7 @@ void jus::GateWayService::SendData(size_t _userSessionId, ejson::Object _data, c
|
||||
m_interfaceClient.write(_data.generateMachineString());
|
||||
}
|
||||
|
||||
void jus::GateWayService::onServiceData(const std::string& _value) {
|
||||
void jus::GateWayService::onServiceData(std::string _value) {
|
||||
JUS_DEBUG("On service data: " << _value);
|
||||
ejson::Object data(_value);
|
||||
if (data.valueExist("event") == true) {
|
||||
|
@ -19,13 +19,12 @@ namespace jus {
|
||||
std::string m_name;
|
||||
public:
|
||||
esignal::Signal<bool> signalIsConnected;
|
||||
esignal::Connection m_dataCallback;
|
||||
public:
|
||||
GateWayService(enet::Tcp _connection, jus::GateWay* _gatewayInterface);
|
||||
virtual ~GateWayService();
|
||||
void start();
|
||||
void stop();
|
||||
void onServiceData(const std::string& _value);
|
||||
void onServiceData(std::string _value);
|
||||
public:
|
||||
void SendData(size_t _userSessionId, ejson::Object _data, const std::string& _action="call");
|
||||
const std::string& getName() {
|
||||
|
@ -23,8 +23,10 @@ bool jus::ParamType::operator == (const ParamType& _obj) const {
|
||||
|
||||
|
||||
#define generate_basic_type(_type, _name) \
|
||||
template<> jus::ParamType jus::createType<_type>() {\
|
||||
namespace jus { \
|
||||
template<> jus::ParamType createType<_type>() {\
|
||||
return jus::ParamType(_name); \
|
||||
} \
|
||||
}
|
||||
|
||||
generate_basic_type(void, "void");
|
||||
|
@ -17,14 +17,14 @@
|
||||
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) {
|
||||
m_dataCallback = m_interfaceClient.signalData.connect(this, &jus::Service::onClientData);
|
||||
m_interfaceClient.connect(this, &jus::Service::onClientData);
|
||||
}
|
||||
|
||||
jus::Service::~Service() {
|
||||
|
||||
}
|
||||
|
||||
void jus::Service::onClientData(const std::string& _value) {
|
||||
void jus::Service::onClientData(std::string _value) {
|
||||
ejson::Object request(_value);
|
||||
JUS_INFO("Request: " << _value);
|
||||
ejson::Value answer = callJson(request);
|
||||
|
@ -21,7 +21,6 @@ namespace jus {
|
||||
private:
|
||||
jus::TcpString m_interfaceClient;
|
||||
uint32_t m_id;
|
||||
esignal::Connection m_dataCallback;
|
||||
std::vector<std::string> m_newData;
|
||||
public:
|
||||
Service();
|
||||
@ -29,7 +28,7 @@ namespace jus {
|
||||
void connect(const std::string& _serviceName);
|
||||
void disconnect();
|
||||
private:
|
||||
void onClientData(const std::string& _value);
|
||||
void onClientData(std::string _value);
|
||||
std::string asyncRead();
|
||||
public:
|
||||
void pingIsAlive();
|
||||
|
@ -11,16 +11,14 @@
|
||||
jus::TcpString::TcpString(enet::Tcp _connection) :
|
||||
m_connection(std::move(_connection)),
|
||||
m_thread(nullptr),
|
||||
signalIsConnected(),
|
||||
signalData() {
|
||||
m_obsercerElement(nullptr) {
|
||||
m_threadRunning = false;
|
||||
}
|
||||
|
||||
jus::TcpString::TcpString() :
|
||||
m_connection(),
|
||||
m_thread(nullptr),
|
||||
signalIsConnected(),
|
||||
signalData() {
|
||||
m_obsercerElement(nullptr) {
|
||||
m_threadRunning = false;
|
||||
}
|
||||
|
||||
@ -45,7 +43,9 @@ void jus::TcpString::threadCallback() {
|
||||
std::string data = std::move(read());
|
||||
JUS_VERBOSE("Receive data: '" << data << "'");
|
||||
if (data.size() != 0) {
|
||||
signalData.emit(data);
|
||||
if (m_obsercerElement != nullptr) {
|
||||
m_obsercerElement(std::move(data));
|
||||
}
|
||||
}
|
||||
}
|
||||
m_threadRunning = false;
|
||||
|
@ -17,8 +17,20 @@ namespace jus {
|
||||
std::thread* m_thread;
|
||||
bool m_threadRunning;
|
||||
public:
|
||||
esignal::Signal<bool> signalIsConnected;
|
||||
esignal::Signal<std::string> signalData;
|
||||
using Observer = std::function<void(std::string)>; //!< Define an Observer: function pointer
|
||||
Observer m_obsercerElement;
|
||||
/**
|
||||
* @brief Connect an function member on the signal with the shared_ptr object.
|
||||
* @param[in] _class shared_ptr Object on whe we need to call ==> the object is get in keeped in weak_ptr.
|
||||
* @param[in] _func Function to call.
|
||||
* @param[in] _args Argument optinnal the user want to add.
|
||||
*/
|
||||
template<class CLASS_TYPE>
|
||||
void connect(CLASS_TYPE* _class, void (CLASS_TYPE::*_func)(std::string)) {
|
||||
m_obsercerElement = [=](std::string _value){
|
||||
(*_class.*_func)(std::move(_value));
|
||||
};
|
||||
}
|
||||
public:
|
||||
TcpString();
|
||||
TcpString(enet::Tcp _connection);
|
||||
|
@ -1,3 +1,4 @@
|
||||
tools/gateway
|
||||
tools/system-gateway
|
||||
tools/system-service
|
||||
test/client
|
||||
test/service1
|
12
tools/system-service/appl/debug.cpp
Normal file
12
tools/system-service/appl/debug.cpp
Normal file
@ -0,0 +1,12 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2016, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <appl/debug.h>
|
||||
|
||||
int32_t appl::getLogId() {
|
||||
static int32_t g_val = elog::registerInstance("jus-system-service");
|
||||
return g_val;
|
||||
}
|
40
tools/system-service/appl/debug.h
Normal file
40
tools/system-service/appl/debug.h
Normal file
@ -0,0 +1,40 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2016, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <elog/log.h>
|
||||
|
||||
namespace appl {
|
||||
int32_t getLogId();
|
||||
};
|
||||
|
||||
#define APPL_BASE(info,data) ELOG_BASE(appl::getLogId(),info,data)
|
||||
|
||||
#define APPL_PRINT(data) APPL_BASE(-1, data)
|
||||
#define APPL_CRITICAL(data) APPL_BASE(1, data)
|
||||
#define APPL_ERROR(data) APPL_BASE(2, data)
|
||||
#define APPL_WARNING(data) APPL_BASE(3, data)
|
||||
#ifdef DEBUG
|
||||
#define APPL_INFO(data) APPL_BASE(4, data)
|
||||
#define APPL_DEBUG(data) APPL_BASE(5, data)
|
||||
#define APPL_VERBOSE(data) APPL_BASE(6, data)
|
||||
#define APPL_TODO(data) APPL_BASE(4, "TODO : " << data)
|
||||
#else
|
||||
#define APPL_INFO(data) do { } while(false)
|
||||
#define APPL_DEBUG(data) do { } while(false)
|
||||
#define APPL_VERBOSE(data) do { } while(false)
|
||||
#define APPL_TODO(data) do { } while(false)
|
||||
#endif
|
||||
|
||||
#define APPL_ASSERT(cond,data) \
|
||||
do { \
|
||||
if (!(cond)) { \
|
||||
APPL_CRITICAL(data); \
|
||||
assert(!#cond); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
|
137
tools/system-service/appl/main.cpp
Normal file
137
tools/system-service/appl/main.cpp
Normal file
@ -0,0 +1,137 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2014, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <appl/debug.h>
|
||||
#include <jus/Service.h>
|
||||
#include <etk/etk.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <etk/stdTools.h>
|
||||
namespace appl {
|
||||
class User {
|
||||
public:
|
||||
User() {
|
||||
APPL_WARNING("new USER");
|
||||
}
|
||||
~User() {
|
||||
APPL_WARNING("delete USER");
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
class UserManager {
|
||||
private:
|
||||
std::map<std::string, ememory::SharedPtr<appl::User>> m_listLoaded;
|
||||
public:
|
||||
UserManager() {
|
||||
|
||||
}
|
||||
ememory::SharedPtr<appl::User> getUser(const std::string& _userName) {
|
||||
// TODO : Lock ...
|
||||
auto it = m_listLoaded.find(_userName);
|
||||
if (it != m_listLoaded.end()) {
|
||||
// User already loaded:
|
||||
return it->second;
|
||||
}
|
||||
// load New User:
|
||||
ememory::SharedPtr<appl::User> tmp(new appl::User);
|
||||
m_listLoaded.insert(std::make_pair(_userName, tmp));
|
||||
return tmp;
|
||||
}
|
||||
};
|
||||
class ClientProperty {
|
||||
public:
|
||||
ClientProperty() {}
|
||||
private:
|
||||
std::string m_name;
|
||||
public:
|
||||
void setName(const std::string& _name) {
|
||||
m_name = _name
|
||||
}
|
||||
const std::string& getName() {
|
||||
return m_name;
|
||||
}
|
||||
private:
|
||||
std::vector<std::string> m_groups;
|
||||
public:
|
||||
void setGroups(std::vector<std::string> _groups) {
|
||||
m_groups = _groups
|
||||
}
|
||||
const std::vector<std::string>& getGroups() {
|
||||
return m_groups;
|
||||
}
|
||||
}
|
||||
class SystemService {
|
||||
private:
|
||||
|
||||
public:
|
||||
SystemService() {
|
||||
APPL_WARNING("New SystemService ...");
|
||||
}
|
||||
~SystemService() {
|
||||
APPL_WARNING("delete SystemService ...");
|
||||
}
|
||||
private:
|
||||
ememory::SharedPtr<appl::User> m_user;
|
||||
public:
|
||||
int32_t getServiceCount() {
|
||||
return 0;
|
||||
}
|
||||
std::vector<std::string> getServiceList() {
|
||||
return std::vector<std::string>();
|
||||
}
|
||||
public:
|
||||
SystemService(ememory::SharedPtr<appl::User> _user) :
|
||||
m_user(_user) {
|
||||
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
int main(int _argc, const char *_argv[]) {
|
||||
etk::init(_argc, _argv);
|
||||
appl::UserManager userMng;
|
||||
jus::ServiceType<appl::SystemService, appl::UserManager> serviceInterface(userMng);
|
||||
serviceInterface.setDescription("SystemService interface");
|
||||
serviceInterface.setVersion("0.1.1");
|
||||
serviceInterface.addAuthor("Heero Yui", "yui.heero@gmail.com");
|
||||
serviceInterface.advertise("mul", &appl::SystemService::mul);
|
||||
serviceInterface.setLastFuncDesc("simple multiplication to test double IO");
|
||||
serviceInterface.addLastFuncParam("val1", "First Parameter To multiply");
|
||||
serviceInterface.addLastFuncParam("val2", "Second Parameter To multiply");
|
||||
for (int32_t iii=0; iii<_argc ; ++iii) {
|
||||
std::string data = _argv[iii];
|
||||
if (etk::start_with(data, "--ip=") == true) {
|
||||
serviceInterface.propertyIp.set(std::string(&data[5]));
|
||||
} else if (etk::start_with(data, "--port=") == true) {
|
||||
serviceInterface.propertyPort.set(etk::string_to_uint16_t(std::string(&data[7])));
|
||||
} else if ( data == "-h"
|
||||
|| data == "--help") {
|
||||
APPL_PRINT(etk::getApplicationName() << " - help : ");
|
||||
APPL_PRINT(" " << _argv[0] << " [options]");
|
||||
APPL_PRINT(" --ip=XXX Server connection IP (default: 1.7.0.0.1)");
|
||||
APPL_PRINT(" --port=XXX Server connection PORT (default: 1983)");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
APPL_INFO("==================================");
|
||||
APPL_INFO("== JUS test service1 start ==");
|
||||
APPL_INFO("==================================");
|
||||
serviceInterface.connect("serviceTest1");
|
||||
int32_t iii=0;
|
||||
while (true) {
|
||||
usleep(1000000);
|
||||
serviceInterface.pingIsAlive();
|
||||
APPL_INFO("service in waiting ... " << iii << "/inf");
|
||||
iii++;
|
||||
}
|
||||
serviceInterface.disconnect();
|
||||
APPL_INFO("==================================");
|
||||
APPL_INFO("== JUS test service1 stop ==");
|
||||
APPL_INFO("==================================");
|
||||
return 0;
|
||||
}
|
38
tools/system-service/lutin_jus-system-service.py
Normal file
38
tools/system-service/lutin_jus-system-service.py
Normal file
@ -0,0 +1,38 @@
|
||||
#!/usr/bin/python
|
||||
import lutin.module as module
|
||||
import lutin.tools as tools
|
||||
|
||||
|
||||
def get_type():
|
||||
return "BINARY"
|
||||
|
||||
def get_sub_type():
|
||||
return "TOOLS"
|
||||
|
||||
def get_desc():
|
||||
return "JUS test service"
|
||||
|
||||
def get_licence():
|
||||
return "APACHE-2"
|
||||
|
||||
def get_compagny_type():
|
||||
return "com"
|
||||
|
||||
def get_compagny_name():
|
||||
return "atria-soft"
|
||||
|
||||
def get_maintainer():
|
||||
return ["Mr DUPIN Edouard <yui.heero@gmail.com>"]
|
||||
|
||||
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_src_file([
|
||||
'appl/debug.cpp',
|
||||
'appl/main.cpp'
|
||||
])
|
||||
return my_module
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user