[DEV] rename gateway front and back in gateway and router
This commit is contained in:
parent
7cef0f6b08
commit
8780e9fe45
27
README.md
27
README.md
@ -8,6 +8,33 @@ Instructions
|
||||
|
||||
messaging engine drived by data and message based on websocket api
|
||||
|
||||
Start basic service engine
|
||||
==========================
|
||||
|
||||
Start The router interface:
|
||||
```
|
||||
lutin -cclang -mdebug zeus-package-base?build?run%zeus-router
|
||||
```
|
||||
|
||||
You have now multiple choice:
|
||||
|
||||
* Single process start:
|
||||
|
||||
```
|
||||
#Start a single gateWay with basic with no user service associated:
|
||||
lutin -cclang -mdebug zeus-package-base?build?run%zeus-gateway:--user=userName~server.org
|
||||
# start service is separated process: (the user service is needed all the time ...)
|
||||
lutin -cclang -mdebug zeus-package-base?build?run%zeus-launch:--srv=user
|
||||
lutin -cclang -mdebug zeus-package-base?build?run%zeus-launch:--srv=picture
|
||||
lutin -cclang -mdebug zeus-package-base?build?run%zeus-launch:--srv=video
|
||||
```
|
||||
|
||||
* Start your gateway with the service in a single process (faster: No inter-process messaging)
|
||||
|
||||
```
|
||||
lutin -cclang -mdebug zeus-package-base?build?run%zeus-gateway:--user=userName~server.org:--srv=user:--srv=picture:--srv=video
|
||||
```
|
||||
|
||||
|
||||
License (APACHE v2.0)
|
||||
=====================
|
||||
|
@ -1,5 +1,5 @@
|
||||
tools/gateway-front-end
|
||||
tools/gateway-back-end
|
||||
tools/gateway
|
||||
tools/router
|
||||
tools/service-user
|
||||
tools/service-picture
|
||||
tools/service-video
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
|
||||
*----------------------------------------------------------------------------*
|
||||
| Docker / single binary Single User specufic program/environement |
|
||||
| Docker / single binary Single User specific program/environement |
|
||||
| |
|
||||
| *-----------------------* |
|
||||
| +--------->| service-right-manager | |
|
||||
@ -25,7 +25,7 @@ Internet | | | |
|
||||
|<----*===>|80 ROUTER |
|
||||
| | | |
|
||||
|<----| | |<---+ *----------------------------------------------------------------------------*
|
||||
| | | | | | Docker / single binary Single User specufic program/environement |
|
||||
| | | | | | Docker / single binary Single User specific program/environement |
|
||||
|<----* | | | | |
|
||||
| *-------------* | | *-----------------------* |
|
||||
| || | | +--------->| service-right-manager | |
|
||||
|
@ -69,8 +69,8 @@ void appl::GateWay::newService(enet::Tcp _connection) {
|
||||
appl::GateWay::GateWay() :
|
||||
m_clientUID(1),
|
||||
propertyUserName(this, "user", "no-name", "User name of the interface"), // must be set befor start ...
|
||||
propertyGateWayClientIp(this, "gw-ip", "127.0.0.1", "Ip to listen client", &appl::GateWay::onPropertyChangeClientIp),
|
||||
propertyGateWayClientPort(this, "gw-port", 1984, "Port to listen client", &appl::GateWay::onPropertyChangeClientPort),
|
||||
propertyRouterIp(this, "router-ip", "127.0.0.1", "Ip to listen client", &appl::GateWay::onPropertyChangeClientIp),
|
||||
propertyRouterPort(this, "router-port", 1984, "Port to listen client", &appl::GateWay::onPropertyChangeClientPort),
|
||||
propertyServiceIp(this, "service-ip", "127.0.0.1", "Ip to listen client", &appl::GateWay::onPropertyChangeServiceIp),
|
||||
propertyServicePort(this, "service-port", 1982, "Port to listen client", &appl::GateWay::onPropertyChangeServicePort),
|
||||
propertyServiceMax(this, "service-max", 80, "Maximum of client at the same time", &appl::GateWay::onPropertyChangeServiceMax) {
|
||||
@ -82,13 +82,13 @@ appl::GateWay::~GateWay() {
|
||||
}
|
||||
|
||||
void appl::GateWay::start() {
|
||||
m_gateWayClient = ememory::makeShared<appl::ClientGateWayInterface>(*propertyGateWayClientIp, *propertyGateWayClientPort, *propertyUserName, this);
|
||||
m_routerClient = ememory::makeShared<appl::RouterInterface>(*propertyRouterIp, *propertyRouterPort, *propertyUserName, this);
|
||||
|
||||
m_interfaceNewService->start(*propertyServiceIp, *propertyServicePort);
|
||||
}
|
||||
|
||||
void appl::GateWay::stop() {
|
||||
m_gateWayClient.reset();
|
||||
m_routerClient.reset();
|
||||
|
||||
}
|
||||
|
||||
@ -118,8 +118,8 @@ std::vector<std::string> appl::GateWay::getAllServiceName() {
|
||||
|
||||
|
||||
void appl::GateWay::answer(uint64_t _userSessionId, const ememory::SharedPtr<zeus::Buffer>& _data) {
|
||||
if (m_gateWayClient != nullptr) {
|
||||
m_gateWayClient->answer(_userSessionId, _data);
|
||||
if (m_routerClient != nullptr) {
|
||||
m_routerClient->answer(_userSessionId, _data);
|
||||
}
|
||||
}
|
||||
|
||||
@ -138,8 +138,8 @@ void appl::GateWay::cleanIO() {
|
||||
}
|
||||
++it;
|
||||
}
|
||||
if (m_gateWayClient != nullptr) {
|
||||
m_gateWayClient->clean();
|
||||
if (m_routerClient != nullptr) {
|
||||
m_routerClient->clean();
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
*/
|
||||
#pragma once
|
||||
#include <appl/ServiceInterface.hpp>
|
||||
#include <appl/ClientGateWayInterface.hpp>
|
||||
#include <appl/RouterInterface.hpp>
|
||||
#include <eproperty/Value.hpp>
|
||||
|
||||
namespace appl {
|
||||
@ -15,13 +15,13 @@ namespace appl {
|
||||
uint64_t m_clientUID;
|
||||
private:
|
||||
std::vector<ememory::SharedPtr<appl::ServiceInterface>> m_serviceList; //!< List of all service availlable with their specific connection interface
|
||||
ememory::SharedPtr<appl::ClientGateWayInterface> m_gateWayClient; //!< Interface with the Gateway Front End
|
||||
ememory::SharedPtr<appl::RouterInterface> m_routerClient; //!< Interface with the Gateway Front End
|
||||
|
||||
ememory::SharedPtr<appl::TcpServerInput> m_interfaceNewService;
|
||||
public:
|
||||
eproperty::Value<std::string> propertyUserName;
|
||||
eproperty::Value<std::string> propertyGateWayClientIp;
|
||||
eproperty::Value<uint16_t> propertyGateWayClientPort;
|
||||
eproperty::Value<std::string> propertyRouterIp;
|
||||
eproperty::Value<uint16_t> propertyRouterPort;
|
||||
eproperty::Value<std::string> propertyServiceIp;
|
||||
eproperty::Value<uint16_t> propertyServicePort;
|
||||
eproperty::Value<uint16_t> propertyServiceMax;
|
@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
#include <appl/debug.hpp>
|
||||
#include <appl/ClientGateWayInterface.hpp>
|
||||
#include <appl/RouterInterface.hpp>
|
||||
#include <zeus/Future.hpp>
|
||||
#include <appl/GateWay.hpp>
|
||||
#include <enet/TcpClient.hpp>
|
||||
@ -31,18 +31,18 @@ appl::userSpecificInterface::~userSpecificInterface() {
|
||||
}
|
||||
|
||||
void appl::userSpecificInterface::answerProtocolError(uint32_t _transactionId, const std::string& _errorHelp) {
|
||||
m_interfaceGateWayClient->answerError(_transactionId, protocolError, _errorHelp);
|
||||
m_interfaceGateWayClient->sendCtrl("DISCONNECT", m_uid);
|
||||
m_interfaceRouterClient->answerError(_transactionId, protocolError, _errorHelp);
|
||||
m_interfaceRouterClient->sendCtrl("DISCONNECT", m_uid);
|
||||
m_state = appl::clientState::disconnect;
|
||||
}
|
||||
|
||||
bool appl::userSpecificInterface::start(uint32_t _transactionId, appl::GateWay* _gatewayInterface, zeus::WebServer* _interfaceGateWayClient, uint64_t _id) {
|
||||
m_interfaceGateWayClient = _interfaceGateWayClient;
|
||||
m_interfaceRouterClient = _interfaceGateWayClient;
|
||||
m_gatewayInterface = _gatewayInterface;
|
||||
m_uid = _id;
|
||||
m_localIdUser = _id+1;
|
||||
m_state = appl::clientState::connect;
|
||||
//m_interfaceGateWayClient->setInterfaceName("cli-" + etk::to_string(m_uid));
|
||||
//m_interfaceRouterClient->setInterfaceName("cli-" + etk::to_string(m_uid));
|
||||
|
||||
APPL_WARNING("[" << m_uid << "] New client");
|
||||
|
||||
@ -90,7 +90,7 @@ void appl::userSpecificInterface::onClientData(ememory::SharedPtr<zeus::Buffer>
|
||||
}
|
||||
serviceId--;
|
||||
if (serviceId >= m_listConnectedService.size()) {
|
||||
m_interfaceGateWayClient->answerError(transactionId, "NOT-CONNECTED-SERVICE");
|
||||
m_interfaceRouterClient->answerError(transactionId, "NOT-CONNECTED-SERVICE");
|
||||
return;
|
||||
}
|
||||
if (m_listConnectedService[serviceId] == nullptr) {
|
||||
@ -142,11 +142,11 @@ void appl::userSpecificInterface::onClientData(ememory::SharedPtr<zeus::Buffer>
|
||||
fut.wait(); // TODO: Set timeout ...
|
||||
if (fut.hasError() == true) {
|
||||
APPL_ERROR("Get error from the service ...");
|
||||
m_interfaceGateWayClient->answerValue(transactionId, false);
|
||||
m_interfaceRouterClient->answerValue(transactionId, false);
|
||||
answerProtocolError(transactionId, "connection refused 1");
|
||||
return;
|
||||
} else if (fut.get() == false) {
|
||||
m_interfaceGateWayClient->answerValue(transactionId, false);
|
||||
m_interfaceRouterClient->answerValue(transactionId, false);
|
||||
answerProtocolError(transactionId, "connection refused 2");
|
||||
return;
|
||||
}
|
||||
@ -158,11 +158,11 @@ void appl::userSpecificInterface::onClientData(ememory::SharedPtr<zeus::Buffer>
|
||||
fut.wait(); // TODO: Set timeout ...
|
||||
if (fut.hasError() == true) {
|
||||
APPL_ERROR("Get error from the service ...");
|
||||
m_interfaceGateWayClient->answerValue(transactionId, false);
|
||||
m_interfaceRouterClient->answerValue(transactionId, false);
|
||||
answerProtocolError(transactionId, "connection refused 1");
|
||||
return;
|
||||
} else if (fut.get() == false) {
|
||||
m_interfaceGateWayClient->answerValue(transactionId, false);
|
||||
m_interfaceRouterClient->answerValue(transactionId, false);
|
||||
answerProtocolError(transactionId, "connection refused 2");
|
||||
return;
|
||||
}
|
||||
@ -178,7 +178,7 @@ void appl::userSpecificInterface::onClientData(ememory::SharedPtr<zeus::Buffer>
|
||||
futGroup.wait(); // TODO: Set timeout ...
|
||||
if (futGroup.hasError() == true) {
|
||||
APPL_ERROR("Get error from the service ...");
|
||||
m_interfaceGateWayClient->answerValue(transactionId, false);
|
||||
m_interfaceRouterClient->answerValue(transactionId, false);
|
||||
answerProtocolError(transactionId, "grouping error");
|
||||
return;
|
||||
}
|
||||
@ -191,7 +191,7 @@ void appl::userSpecificInterface::onClientData(ememory::SharedPtr<zeus::Buffer>
|
||||
futServices.wait(); // TODO: Set timeout ...
|
||||
if (futServices.hasError() == true) {
|
||||
APPL_ERROR("Get error from the service ...");
|
||||
m_interfaceGateWayClient->answerValue(transactionId, false);
|
||||
m_interfaceRouterClient->answerValue(transactionId, false);
|
||||
answerProtocolError(transactionId, "service filtering error");
|
||||
return;
|
||||
}
|
||||
@ -201,7 +201,7 @@ void appl::userSpecificInterface::onClientData(ememory::SharedPtr<zeus::Buffer>
|
||||
APPL_WARNING(" services: " << etk::to_string(m_clientServices));
|
||||
|
||||
|
||||
m_interfaceGateWayClient->answerValue(transactionId, true);
|
||||
m_interfaceRouterClient->answerValue(transactionId, true);
|
||||
m_state = appl::clientState::clientIdentify;
|
||||
return;
|
||||
}
|
||||
@ -212,11 +212,11 @@ void appl::userSpecificInterface::onClientData(ememory::SharedPtr<zeus::Buffer>
|
||||
if (serviceId == 0) {
|
||||
// This is 2 default service for the cient interface that manage the authorisation of view:
|
||||
if (callFunction == "getServiceCount") {
|
||||
m_interfaceGateWayClient->answerValue(transactionId, m_clientServices.size(), m_uid);
|
||||
m_interfaceRouterClient->answerValue(transactionId, m_clientServices.size(), m_uid);
|
||||
return;
|
||||
}
|
||||
if (callFunction == "getServiceList") {
|
||||
m_interfaceGateWayClient->answerValue(transactionId, m_clientServices, m_uid);
|
||||
m_interfaceRouterClient->answerValue(transactionId, m_clientServices, m_uid);
|
||||
//"ServiceManager/v0.1.0"
|
||||
return;
|
||||
}
|
||||
@ -239,7 +239,7 @@ void appl::userSpecificInterface::onClientData(ememory::SharedPtr<zeus::Buffer>
|
||||
if (it == m_listConnectedService.end()) {
|
||||
// check if service is connectable ...
|
||||
if (std::find(m_clientServices.begin(), m_clientServices.end(), serviceName) == m_clientServices.end()) {
|
||||
m_interfaceGateWayClient->answerError(transactionId, "UN-AUTHORIZED-SERVICE");
|
||||
m_interfaceRouterClient->answerError(transactionId, "UN-AUTHORIZED-SERVICE");
|
||||
return;
|
||||
}
|
||||
ememory::SharedPtr<appl::ServiceInterface> srv = m_gatewayInterface->get(serviceName);
|
||||
@ -248,17 +248,17 @@ void appl::userSpecificInterface::onClientData(ememory::SharedPtr<zeus::Buffer>
|
||||
futLink.wait(); // TODO: Set timeout ...
|
||||
if (futLink.hasError() == true) {
|
||||
APPL_ERROR("Get error from the service ... LINK");
|
||||
m_interfaceGateWayClient->answerError(transactionId, "ERROR-CREATE-SERVICE-INSTANCE");
|
||||
m_interfaceRouterClient->answerError(transactionId, "ERROR-CREATE-SERVICE-INSTANCE");
|
||||
return;
|
||||
}
|
||||
m_listConnectedService.push_back(srv);
|
||||
m_interfaceGateWayClient->answerValue(transactionId, m_listConnectedService.size(), m_uid);
|
||||
m_interfaceRouterClient->answerValue(transactionId, m_listConnectedService.size(), m_uid);
|
||||
return;
|
||||
}
|
||||
m_interfaceGateWayClient->answerError(transactionId, "CAN-NOT-CONNECT-SERVICE");
|
||||
m_interfaceRouterClient->answerError(transactionId, "CAN-NOT-CONNECT-SERVICE");
|
||||
return;
|
||||
}
|
||||
m_interfaceGateWayClient->answerError(transactionId, "SERVICE-ALREADY-CONNECTED");;
|
||||
m_interfaceRouterClient->answerError(transactionId, "SERVICE-ALREADY-CONNECTED");;
|
||||
return;
|
||||
}
|
||||
if (callFunction == "unlink") {
|
||||
@ -266,28 +266,28 @@ void appl::userSpecificInterface::onClientData(ememory::SharedPtr<zeus::Buffer>
|
||||
int64_t localServiceID = callObj->getParameter<int64_t>(0)-1;
|
||||
// Check if service already link:
|
||||
if (localServiceID >= m_listConnectedService.size()) {
|
||||
m_interfaceGateWayClient->answerError(transactionId, "NOT-CONNECTED-SERVICE");
|
||||
m_interfaceRouterClient->answerError(transactionId, "NOT-CONNECTED-SERVICE");
|
||||
return;
|
||||
}
|
||||
zeus::Future<bool> futUnLink = m_listConnectedService[localServiceID]->m_interfaceClient.callClient(m_uid, "_delete");
|
||||
futUnLink.wait(); // TODO: Set timeout ...
|
||||
if (futUnLink.hasError() == true) {
|
||||
APPL_ERROR("Get error from the service ... UNLINK");
|
||||
m_interfaceGateWayClient->answerError(transactionId, "ERROR-CREATE-SERVICE-INSTANCE");
|
||||
m_interfaceRouterClient->answerError(transactionId, "ERROR-CREATE-SERVICE-INSTANCE");
|
||||
return;
|
||||
}
|
||||
m_listConnectedService[localServiceID] = nullptr;
|
||||
m_interfaceGateWayClient->answerValue(transactionId, true);
|
||||
m_interfaceRouterClient->answerValue(transactionId, true);
|
||||
return;
|
||||
}
|
||||
APPL_ERROR("Function does not exist ... '" << callFunction << "'");
|
||||
m_interfaceGateWayClient->answerError(transactionId, "CALL-UNEXISTING");
|
||||
m_interfaceRouterClient->answerError(transactionId, "CALL-UNEXISTING");
|
||||
return;
|
||||
}
|
||||
// decrease service ID ...
|
||||
serviceId -= 1;
|
||||
if (serviceId >= m_listConnectedService.size()) {
|
||||
m_interfaceGateWayClient->answerError(transactionId, "NOT-CONNECTED-SERVICE");
|
||||
m_interfaceRouterClient->answerError(transactionId, "NOT-CONNECTED-SERVICE");
|
||||
return;
|
||||
} else {
|
||||
if (m_listConnectedService[serviceId] == nullptr) {
|
||||
@ -309,7 +309,7 @@ void appl::userSpecificInterface::onClientData(ememory::SharedPtr<zeus::Buffer>
|
||||
tmpp->setTransactionId(transactionId);
|
||||
tmpp->setServiceId(serviceId+1);
|
||||
APPL_DEBUG("transmit=" << tmpp);
|
||||
m_interfaceGateWayClient->writeBinary(tmpp);
|
||||
m_interfaceRouterClient->writeBinary(tmpp);
|
||||
// multiple send element ...
|
||||
return tmpp->getPartFinish();
|
||||
});
|
||||
@ -321,10 +321,10 @@ void appl::userSpecificInterface::onClientData(ememory::SharedPtr<zeus::Buffer>
|
||||
|
||||
|
||||
|
||||
appl::ClientGateWayInterface::ClientGateWayInterface(const std::string& _ip, uint16_t _port, const std::string& _userName, appl::GateWay* _gatewayInterface) :
|
||||
appl::RouterInterface::RouterInterface(const std::string& _ip, uint16_t _port, const std::string& _userName, appl::GateWay* _gatewayInterface) :
|
||||
m_state(appl::clientState::unconnect),
|
||||
m_gatewayInterface(_gatewayInterface),
|
||||
m_interfaceGateWayClient() {
|
||||
m_interfaceRouterClient() {
|
||||
APPL_INFO("----------------------------------------");
|
||||
APPL_INFO("-- NEW Connection to GateWay Font-end --");
|
||||
APPL_INFO("----------------------------------------");
|
||||
@ -333,16 +333,16 @@ appl::ClientGateWayInterface::ClientGateWayInterface(const std::string& _ip, uin
|
||||
APPL_ERROR("Can not connect the GateWay-front-end");
|
||||
return;
|
||||
}
|
||||
m_interfaceGateWayClient.setInterface(std::move(connection), false, _userName);
|
||||
m_interfaceRouterClient.setInterface(std::move(connection), false, _userName);
|
||||
//m_userConnectionName = _userName;
|
||||
m_state = appl::clientState::connect;
|
||||
m_interfaceGateWayClient.connect(this, &appl::ClientGateWayInterface::onClientData);
|
||||
m_interfaceGateWayClient.connect(true);
|
||||
m_interfaceGateWayClient.setInterfaceName("cli-GateWay-front-end");
|
||||
m_interfaceRouterClient.connect(this, &appl::RouterInterface::onClientData);
|
||||
m_interfaceRouterClient.connect(true);
|
||||
m_interfaceRouterClient.setInterfaceName("cli-GateWay-front-end");
|
||||
// TODO : Check if user name is accepted ...
|
||||
}
|
||||
|
||||
appl::ClientGateWayInterface::~ClientGateWayInterface() {
|
||||
appl::RouterInterface::~RouterInterface() {
|
||||
APPL_TODO("Call All unlink ...");
|
||||
stop();
|
||||
APPL_INFO("-------------------------------------------");
|
||||
@ -350,7 +350,7 @@ appl::ClientGateWayInterface::~ClientGateWayInterface() {
|
||||
APPL_INFO("-------------------------------------------");
|
||||
}
|
||||
|
||||
void appl::ClientGateWayInterface::stop() {
|
||||
void appl::RouterInterface::stop() {
|
||||
/* TODO ...
|
||||
for (auto &it : m_listConnectedService) {
|
||||
if (it == nullptr) {
|
||||
@ -364,16 +364,16 @@ void appl::ClientGateWayInterface::stop() {
|
||||
}
|
||||
m_listConnectedService.clear();
|
||||
*/
|
||||
m_interfaceGateWayClient.disconnect();
|
||||
m_interfaceRouterClient.disconnect();
|
||||
}
|
||||
|
||||
bool appl::ClientGateWayInterface::isAlive() {
|
||||
return m_interfaceGateWayClient.isActive();
|
||||
bool appl::RouterInterface::isAlive() {
|
||||
return m_interfaceRouterClient.isActive();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void appl::ClientGateWayInterface::onClientData(ememory::SharedPtr<zeus::Buffer> _value) {
|
||||
void appl::RouterInterface::onClientData(ememory::SharedPtr<zeus::Buffer> _value) {
|
||||
if (_value == nullptr) {
|
||||
return;
|
||||
}
|
||||
@ -390,7 +390,7 @@ void appl::ClientGateWayInterface::onClientData(ememory::SharedPtr<zeus::Buffer>
|
||||
if (localId == -1) {
|
||||
m_listUser.push_back(userSpecificInterface());
|
||||
localId = m_listUser.size()-1;
|
||||
bool ret = m_listUser[localId].start(_value->getTransactionId(), m_gatewayInterface, &m_interfaceGateWayClient, clientId);
|
||||
bool ret = m_listUser[localId].start(_value->getTransactionId(), m_gatewayInterface, &m_interfaceRouterClient, clientId);
|
||||
if (ret == false) {
|
||||
return;
|
||||
}
|
||||
@ -398,7 +398,7 @@ void appl::ClientGateWayInterface::onClientData(ememory::SharedPtr<zeus::Buffer>
|
||||
m_listUser[localId].onClientData(std::move(_value));
|
||||
}
|
||||
|
||||
void appl::ClientGateWayInterface::answer(uint64_t _userSessionId, const ememory::SharedPtr<zeus::Buffer>& _data) {
|
||||
void appl::RouterInterface::answer(uint64_t _userSessionId, const ememory::SharedPtr<zeus::Buffer>& _data) {
|
||||
for (auto &it : m_listUser) {
|
||||
if (it.checkId(_userSessionId) == false) {
|
||||
continue;
|
||||
@ -408,7 +408,7 @@ void appl::ClientGateWayInterface::answer(uint64_t _userSessionId, const ememory
|
||||
}
|
||||
}
|
||||
|
||||
void appl::ClientGateWayInterface::clean() {
|
||||
void appl::RouterInterface::clean() {
|
||||
auto it = m_listUser.begin();
|
||||
while (it != m_listUser.end()) {
|
||||
if (it->m_state == appl::clientState::disconnect) {
|
@ -19,7 +19,7 @@ namespace appl {
|
||||
};
|
||||
class userSpecificInterface {
|
||||
public:
|
||||
zeus::WebServer* m_interfaceGateWayClient;
|
||||
zeus::WebServer* m_interfaceRouterClient;
|
||||
appl::GateWay* m_gatewayInterface;
|
||||
uint64_t m_uid;
|
||||
uint64_t m_localIdUser;
|
||||
@ -41,16 +41,16 @@ namespace appl {
|
||||
}
|
||||
void answerProtocolError(uint32_t _transactionId, const std::string& _errorHelp);
|
||||
};
|
||||
class ClientGateWayInterface {
|
||||
class RouterInterface {
|
||||
private:
|
||||
enum clientState m_state; // state machine ..
|
||||
std::vector<userSpecificInterface> m_listUser;
|
||||
private:
|
||||
appl::GateWay* m_gatewayInterface;
|
||||
zeus::WebServer m_interfaceGateWayClient;
|
||||
zeus::WebServer m_interfaceRouterClient;
|
||||
public:
|
||||
ClientGateWayInterface(const std::string& _ip, uint16_t _port, const std::string& _userName, appl::GateWay* _gatewayInterface);
|
||||
virtual ~ClientGateWayInterface();
|
||||
RouterInterface(const std::string& _ip, uint16_t _port, const std::string& _userName, appl::GateWay* _gatewayInterface);
|
||||
virtual ~RouterInterface();
|
||||
void stop();
|
||||
void onClientData(ememory::SharedPtr<zeus::Buffer> _value);
|
||||
bool isAlive();
|
@ -6,7 +6,6 @@
|
||||
|
||||
#include <appl/debug.hpp>
|
||||
#include <appl/ServiceInterface.hpp>
|
||||
#include <appl/ClientGateWayInterface.hpp>
|
||||
#include <appl/GateWay.hpp>
|
||||
#include <etk/stdTools.hpp>
|
||||
|
@ -10,10 +10,10 @@
|
||||
|
||||
namespace appl {
|
||||
class GateWay;
|
||||
class ClientGateWayInterface;
|
||||
class RouterInterface;
|
||||
class userSpecificInterface;
|
||||
class ServiceInterface {
|
||||
friend class appl::ClientGateWayInterface;
|
||||
friend class appl::RouterInterface;
|
||||
friend class appl::userSpecificInterface;
|
||||
private:
|
||||
appl::GateWay* m_gatewayInterface;
|
@ -20,10 +20,10 @@ int main(int _argc, const char *_argv[]) {
|
||||
std::string data = _argv[iii];
|
||||
if (etk::start_with(data, "--user=") == true) {
|
||||
basicGateway.propertyUserName.set(std::string(&data[7]));
|
||||
} else if (etk::start_with(data, "--gw-ip=") == true) {
|
||||
basicGateway.propertyGateWayClientIp.set(std::string(&data[8]));
|
||||
} else if (etk::start_with(data, "--gw-port=") == true) {
|
||||
basicGateway.propertyGateWayClientPort.set(etk::string_to_uint16_t(std::string(&data[10])));
|
||||
} else if (etk::start_with(data, "--router-ip=") == true) {
|
||||
basicGateway.propertyRouterIp.set(std::string(&data[12]));
|
||||
} else if (etk::start_with(data, "--router-port=") == true) {
|
||||
basicGateway.propertyRouterPort.set(etk::string_to_uint16_t(std::string(&data[14])));
|
||||
} else if (etk::start_with(data, "--service-ip=") == true) {
|
||||
basicGateway.propertyServiceIp.set(std::string(&data[13]));
|
||||
} else if (etk::start_with(data, "--service-port=") == true) {
|
||||
@ -35,8 +35,8 @@ int main(int _argc, const char *_argv[]) {
|
||||
APPL_PRINT(etk::getApplicationName() << " - help : ");
|
||||
APPL_PRINT(" " << _argv[0] << " [options]");
|
||||
APPL_PRINT(" --user=XXX Name of the user that we are connected.");
|
||||
APPL_PRINT(" --gw-ip=XXX GateWay Front-end connection IP (default: 1.7.0.0.1)");
|
||||
APPL_PRINT(" --gw-port=XXX GateWay Front-end connection PORT (default: 1984)");
|
||||
APPL_PRINT(" --router-ip=XXX Router connection IP (default: 1.7.0.0.1)");
|
||||
APPL_PRINT(" --router-port=XXX Router connection PORT (default: 1984)");
|
||||
APPL_PRINT(" --service-ip=XXX Service connection IP (default: 1.7.0.0.1)");
|
||||
APPL_PRINT(" --service-port=XXX Service connection PORT (default: 1982)");
|
||||
APPL_PRINT(" --service-max=XXX Service Maximum IO (default: 15)");
|
@ -29,7 +29,7 @@ def configure(target, my_module):
|
||||
my_module.add_depend(['zeus'])
|
||||
my_module.add_src_file([
|
||||
'appl/debug.cpp',
|
||||
'appl/ClientGateWayInterface.cpp',
|
||||
'appl/RouterInterface.cpp',
|
||||
'appl/ServiceInterface.cpp',
|
||||
'appl/GateWay.cpp',
|
||||
'appl/main.cpp'
|
@ -23,8 +23,8 @@ def get_maintainer():
|
||||
|
||||
def configure(target, my_module):
|
||||
my_module.add_depend([
|
||||
'zeus-gateway-front-end',
|
||||
'zeus-gateway-back-end',
|
||||
'zeus-router',
|
||||
'zeus-gateway',
|
||||
'zeus-service-user',
|
||||
'zeus-service-picture',
|
||||
'zeus-service-video',
|
||||
|
@ -7,7 +7,7 @@
|
||||
#include <appl/debug.hpp>
|
||||
#include <appl/ClientInterface.hpp>
|
||||
#include <zeus/Future.hpp>
|
||||
#include <appl/GateWay.hpp>
|
||||
#include <appl/Router.hpp>
|
||||
#include <zeus/BufferCtrl.hpp>
|
||||
|
||||
|
||||
@ -16,9 +16,9 @@
|
||||
|
||||
static const std::string protocolError = "PROTOCOL-ERROR";
|
||||
|
||||
appl::ClientInterface::ClientInterface(enet::Tcp _connection, appl::GateWay* _gatewayInterface) :
|
||||
appl::ClientInterface::ClientInterface(enet::Tcp _connection, appl::Router* _routerInterface) :
|
||||
m_state(appl::ClientInterface::state::unconnect),
|
||||
m_gatewayInterface(_gatewayInterface),
|
||||
m_routerInterface(_routerInterface),
|
||||
m_interfaceClient(std::move(_connection), true) {
|
||||
APPL_INFO("----------------");
|
||||
APPL_INFO("-- NEW Client --");
|
||||
@ -35,7 +35,7 @@ appl::ClientInterface::~ClientInterface() {
|
||||
|
||||
bool appl::ClientInterface::requestURI(const std::string& _uri) {
|
||||
APPL_WARNING("request connect on CLIENT: '" << _uri << "'");
|
||||
if(m_gatewayInterface == nullptr) {
|
||||
if(m_routerInterface == nullptr) {
|
||||
APPL_ERROR("Can not access to the main GateWay interface (nullptr)");
|
||||
return false;
|
||||
}
|
||||
@ -48,7 +48,7 @@ bool appl::ClientInterface::requestURI(const std::string& _uri) {
|
||||
tmpURI = std::string(tmpURI.begin() + 1, tmpURI.end());
|
||||
}
|
||||
// TODO : Remove subParameters xxx?YYY
|
||||
m_userGateWay = m_gatewayInterface->get(tmpURI);
|
||||
m_userGateWay = m_routerInterface->get(tmpURI);
|
||||
if (m_userGateWay == nullptr) {
|
||||
APPL_ERROR("Can not connect on Client ==> it does not exist ...");
|
||||
return false;
|
@ -6,11 +6,11 @@
|
||||
#pragma once
|
||||
|
||||
#include <zeus/WebServer.hpp>
|
||||
#include <appl/GateWay.hpp>
|
||||
#include <appl/Router.hpp>
|
||||
#include <appl/GateWayInterface.hpp>
|
||||
|
||||
namespace appl {
|
||||
class GateWay;
|
||||
class Router;
|
||||
class ClientInterface {
|
||||
private:
|
||||
enum class state {
|
||||
@ -20,7 +20,7 @@ namespace appl {
|
||||
};
|
||||
enum state m_state; // state machine ...
|
||||
private:
|
||||
appl::GateWay* m_gatewayInterface;
|
||||
appl::Router* m_routerInterface;
|
||||
zeus::WebServer m_interfaceClient;
|
||||
bool requestURI(const std::string& _uri);
|
||||
public:
|
||||
@ -31,7 +31,7 @@ namespace appl {
|
||||
std::vector<std::string> m_clientgroups;
|
||||
std::vector<std::string> m_clientServices;
|
||||
public:
|
||||
ClientInterface(enet::Tcp _connection, appl::GateWay* _gatewayInterface);
|
||||
ClientInterface(enet::Tcp _connection, appl::Router* _routerInterface);
|
||||
virtual ~ClientInterface();
|
||||
void start(uint64_t _uid);
|
||||
void stop();
|
@ -7,15 +7,15 @@
|
||||
#include <appl/debug.hpp>
|
||||
#include <appl/GateWayInterface.hpp>
|
||||
#include <appl/ClientInterface.hpp>
|
||||
#include <appl/GateWay.hpp>
|
||||
#include <appl/Router.hpp>
|
||||
|
||||
// todo : cHANGE THIS ...
|
||||
static const std::string protocolError = "PROTOCOL-ERROR";
|
||||
|
||||
|
||||
|
||||
appl::GateWayInterface::GateWayInterface(enet::Tcp _connection, appl::GateWay* _gatewayInterface) :
|
||||
m_gatewayInterface(_gatewayInterface),
|
||||
appl::GateWayInterface::GateWayInterface(enet::Tcp _connection, appl::Router* _routerInterface) :
|
||||
m_routerInterface(_routerInterface),
|
||||
m_interfaceClient(std::move(_connection), true) {
|
||||
ZEUS_INFO("--------------------------");
|
||||
ZEUS_INFO("-- NEW GateWay Back-end --");
|
||||
@ -36,7 +36,7 @@ bool appl::GateWayInterface::isAlive() {
|
||||
|
||||
bool appl::GateWayInterface::requestURI(const std::string& _uri) {
|
||||
ZEUS_INFO("request connect on User - GateWay: '" << _uri << "'");
|
||||
if(m_gatewayInterface == nullptr) {
|
||||
if(m_routerInterface == nullptr) {
|
||||
ZEUS_ERROR("Can not access to the main GateWay interface (nullptr)");
|
||||
return false;
|
||||
}
|
||||
@ -50,7 +50,7 @@ bool appl::GateWayInterface::requestURI(const std::string& _uri) {
|
||||
}
|
||||
// TODO : Remove subParameters xxx?YYY
|
||||
// check if the USER is already connected:
|
||||
ememory::SharedPtr<appl::GateWayInterface> tmp = m_gatewayInterface->get(tmpURI);
|
||||
ememory::SharedPtr<appl::GateWayInterface> tmp = m_routerInterface->get(tmpURI);
|
||||
if (tmp != nullptr) {
|
||||
ZEUS_ERROR("User is already connected ==> this is a big error ...");
|
||||
return false;
|
||||
@ -122,7 +122,7 @@ void appl::GateWayInterface::onServiceData(ememory::SharedPtr<zeus::Buffer> _val
|
||||
ZEUS_ERROR("Service interface ==> wrong service answer ==> missing 'client-id'");
|
||||
return;
|
||||
}
|
||||
m_gatewayInterface->answer(_value->getClientId(), _value);
|
||||
m_routerInterface->answer(_value->getClientId(), _value);
|
||||
}
|
||||
|
||||
|
@ -9,17 +9,17 @@
|
||||
#include <ememory/memory.hpp>
|
||||
|
||||
namespace appl {
|
||||
class GateWay;
|
||||
class Router;
|
||||
class ClientInterface;
|
||||
class GateWayInterface {
|
||||
friend class appl::ClientInterface;
|
||||
private:
|
||||
appl::GateWay* m_gatewayInterface;
|
||||
appl::Router* m_routerInterface;
|
||||
zeus::WebServer m_interfaceClient;
|
||||
std::string m_name;
|
||||
bool requestURI(const std::string& _uri);
|
||||
public:
|
||||
GateWayInterface(enet::Tcp _connection, appl::GateWay* _gatewayInterface);
|
||||
GateWayInterface(enet::Tcp _connection, appl::Router* _routerInterface);
|
||||
virtual ~GateWayInterface();
|
||||
void start();
|
||||
void stop();
|
@ -4,7 +4,7 @@
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <appl/GateWay.hpp>
|
||||
#include <appl/Router.hpp>
|
||||
#include <appl/debug.hpp>
|
||||
#include <enet/TcpServer.hpp>
|
||||
|
||||
@ -15,13 +15,13 @@ namespace appl {
|
||||
enet::TcpServer m_interface;
|
||||
std::thread* m_thread;
|
||||
bool m_threadRunning;
|
||||
appl::GateWay* m_gateway;
|
||||
appl::Router* m_router;
|
||||
bool m_service;
|
||||
public:
|
||||
TcpServerInput(appl::GateWay* _gateway, bool _service) :
|
||||
TcpServerInput(appl::Router* _router, bool _service) :
|
||||
m_thread(nullptr),
|
||||
m_threadRunning(false),
|
||||
m_gateway(_gateway),
|
||||
m_router(_router),
|
||||
m_service(_service) {
|
||||
|
||||
}
|
||||
@ -56,23 +56,23 @@ namespace appl {
|
||||
enet::Tcp data = std::move(m_interface.waitNext());
|
||||
ZEUS_VERBOSE("New connection");
|
||||
if (m_service == true) {
|
||||
m_gateway->newClientGateWayBackEnd(std::move(data));
|
||||
m_router->newClientGateWay(std::move(data));
|
||||
} else {
|
||||
m_gateway->newClient(std::move(data));
|
||||
m_router->newClient(std::move(data));
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
void appl::GateWay::newClientGateWayBackEnd(enet::Tcp _connection) {
|
||||
void appl::Router::newClientGateWay(enet::Tcp _connection) {
|
||||
ZEUS_WARNING("New TCP connection (service)");
|
||||
ememory::SharedPtr<appl::GateWayInterface> tmp = ememory::makeShared<appl::GateWayInterface>(std::move(_connection), this);
|
||||
tmp->start();
|
||||
m_gatewayBackEndList.push_back(tmp);
|
||||
m_GateWayList.push_back(tmp);
|
||||
}
|
||||
|
||||
void appl::GateWay::newClient(enet::Tcp _connection) {
|
||||
void appl::Router::newClient(enet::Tcp _connection) {
|
||||
ZEUS_WARNING("New TCP connection (client)");
|
||||
ememory::SharedPtr<appl::ClientInterface> tmp = ememory::makeShared<appl::ClientInterface>(std::move(_connection), this);
|
||||
tmp->start(m_clientUID);
|
||||
@ -80,35 +80,35 @@ void appl::GateWay::newClient(enet::Tcp _connection) {
|
||||
m_clientList.push_back(tmp);
|
||||
}
|
||||
|
||||
appl::GateWay::GateWay() :
|
||||
appl::Router::Router() :
|
||||
m_clientUID(2),
|
||||
propertyClientIp(this, "client-ip", "127.0.0.1", "Ip to listen client", &appl::GateWay::onPropertyChangeClientIp),
|
||||
propertyClientPort(this, "client-port", 1983, "Port to listen client", &appl::GateWay::onPropertyChangeClientPort),
|
||||
propertyClientMax(this, "client-max", 80, "Maximum of client at the same time", &appl::GateWay::onPropertyChangeClientMax),
|
||||
propertyGatewayBackEndIp(this, "gw-ip", "127.0.0.1", "Ip to listen client", &appl::GateWay::onPropertyChangeGateWayIp),
|
||||
propertyGatewayBackEndPort(this, "gw-port", 1984, "Port to listen client", &appl::GateWay::onPropertyChangeGateWayPort),
|
||||
propertyGatewayBackEndMax(this, "gw-max", 80, "Maximum of client at the same time", &appl::GateWay::onPropertyChangeGateWayMax) {
|
||||
propertyClientIp(this, "client-ip", "127.0.0.1", "Ip to listen client", &appl::Router::onPropertyChangeClientIp),
|
||||
propertyClientPort(this, "client-port", 1983, "Port to listen client", &appl::Router::onPropertyChangeClientPort),
|
||||
propertyClientMax(this, "client-max", 80, "Maximum of client at the same time", &appl::Router::onPropertyChangeClientMax),
|
||||
propertyGateWayIp(this, "gw-ip", "127.0.0.1", "Ip to listen client", &appl::Router::onPropertyChangeGateWayIp),
|
||||
propertyGateWayPort(this, "gw-port", 1984, "Port to listen client", &appl::Router::onPropertyChangeGateWayPort),
|
||||
propertyGateWayMax(this, "gw-max", 80, "Maximum of client at the same time", &appl::Router::onPropertyChangeGateWayMax) {
|
||||
m_interfaceClientServer = ememory::makeShared<appl::TcpServerInput>(this, false);
|
||||
m_interfaceGatewayBackEndServer = ememory::makeShared<appl::TcpServerInput>(this, true);
|
||||
m_interfaceGateWayServer = ememory::makeShared<appl::TcpServerInput>(this, true);
|
||||
}
|
||||
|
||||
appl::GateWay::~GateWay() {
|
||||
appl::Router::~Router() {
|
||||
|
||||
}
|
||||
|
||||
void appl::GateWay::start() {
|
||||
void appl::Router::start() {
|
||||
m_interfaceClientServer->start(*propertyClientIp, *propertyClientPort);
|
||||
m_interfaceGatewayBackEndServer->start(*propertyGatewayBackEndIp, *propertyGatewayBackEndPort);
|
||||
m_interfaceGateWayServer->start(*propertyGateWayIp, *propertyGateWayPort);
|
||||
}
|
||||
|
||||
void appl::GateWay::stop() {
|
||||
void appl::Router::stop() {
|
||||
// TODO : Stop all server ...
|
||||
|
||||
}
|
||||
|
||||
ememory::SharedPtr<appl::GateWayInterface> appl::GateWay::get(const std::string& _userName) {
|
||||
ememory::SharedPtr<appl::GateWayInterface> appl::Router::get(const std::string& _userName) {
|
||||
// TODO : Start USer only when needed, not get it all time started...
|
||||
for (auto &it : m_gatewayBackEndList) {
|
||||
for (auto &it : m_GateWayList) {
|
||||
if (it == nullptr) {
|
||||
continue;
|
||||
}
|
||||
@ -121,10 +121,10 @@ ememory::SharedPtr<appl::GateWayInterface> appl::GateWay::get(const std::string&
|
||||
}
|
||||
|
||||
|
||||
std::vector<std::string> appl::GateWay::getAllUserName() {
|
||||
std::vector<std::string> appl::Router::getAllUserName() {
|
||||
std::vector<std::string> out;
|
||||
/*
|
||||
for (auto &it : m_gatewayBackEndList) {
|
||||
for (auto &it : m_GateWayList) {
|
||||
if (it == nullptr) {
|
||||
continue;
|
||||
}
|
||||
@ -135,7 +135,7 @@ std::vector<std::string> appl::GateWay::getAllUserName() {
|
||||
}
|
||||
|
||||
|
||||
void appl::GateWay::answer(uint64_t _userSessionId, const ememory::SharedPtr<zeus::Buffer>& _data) {
|
||||
void appl::Router::answer(uint64_t _userSessionId, const ememory::SharedPtr<zeus::Buffer>& _data) {
|
||||
for (auto &it : m_clientList) {
|
||||
if (it == nullptr) {
|
||||
continue;
|
||||
@ -148,17 +148,17 @@ void appl::GateWay::answer(uint64_t _userSessionId, const ememory::SharedPtr<zeu
|
||||
}
|
||||
}
|
||||
|
||||
void appl::GateWay::cleanIO() {
|
||||
void appl::Router::cleanIO() {
|
||||
|
||||
auto it = m_gatewayBackEndList.begin();
|
||||
while (it != m_gatewayBackEndList.end()) {
|
||||
auto it = m_GateWayList.begin();
|
||||
while (it != m_GateWayList.end()) {
|
||||
if (*it != nullptr) {
|
||||
if ((*it)->isAlive() == false) {
|
||||
it = m_gatewayBackEndList.erase(it);
|
||||
it = m_GateWayList.erase(it);
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
it = m_gatewayBackEndList.erase(it);
|
||||
it = m_GateWayList.erase(it);
|
||||
continue;
|
||||
}
|
||||
++it;
|
||||
@ -179,34 +179,34 @@ void appl::GateWay::cleanIO() {
|
||||
}
|
||||
}
|
||||
|
||||
void appl::GateWay::onClientConnect(const bool& _value) {
|
||||
void appl::Router::onClientConnect(const bool& _value) {
|
||||
ZEUS_TODO("Client connection: " << _value);
|
||||
}
|
||||
|
||||
void appl::GateWay::onServiceConnect(const bool& _value) {
|
||||
void appl::Router::onServiceConnect(const bool& _value) {
|
||||
ZEUS_TODO("Service connection: " << _value);
|
||||
}
|
||||
|
||||
void appl::GateWay::onPropertyChangeClientIp() {
|
||||
void appl::Router::onPropertyChangeClientIp() {
|
||||
|
||||
}
|
||||
|
||||
void appl::GateWay::onPropertyChangeClientPort() {
|
||||
void appl::Router::onPropertyChangeClientPort() {
|
||||
|
||||
}
|
||||
|
||||
void appl::GateWay::onPropertyChangeClientMax() {
|
||||
void appl::Router::onPropertyChangeClientMax() {
|
||||
|
||||
}
|
||||
|
||||
void appl::GateWay::onPropertyChangeGateWayIp() {
|
||||
void appl::Router::onPropertyChangeGateWayIp() {
|
||||
|
||||
}
|
||||
|
||||
void appl::GateWay::onPropertyChangeGateWayPort() {
|
||||
void appl::Router::onPropertyChangeGateWayPort() {
|
||||
|
||||
}
|
||||
|
||||
void appl::GateWay::onPropertyChangeGateWayMax() {
|
||||
void appl::Router::onPropertyChangeGateWayMax() {
|
||||
|
||||
}
|
@ -11,25 +11,25 @@
|
||||
|
||||
namespace appl {
|
||||
class TcpServerInput;
|
||||
class GateWay : public eproperty::Interface {
|
||||
class Router : public eproperty::Interface {
|
||||
private:
|
||||
uint64_t m_clientUID;
|
||||
private:
|
||||
std::vector<ememory::SharedPtr<appl::GateWayInterface>> m_gatewayBackEndList; //!< List of all service availlable with their specific connection interface
|
||||
std::vector<ememory::SharedPtr<appl::GateWayInterface>> m_GateWayList; //!< List of all service availlable with their specific connection interface
|
||||
std::vector<ememory::SharedPtr<appl::ClientInterface>> m_clientList; //!< List of all Client interface with their own connection
|
||||
ememory::SharedPtr<appl::TcpServerInput> m_interfaceClientServer;
|
||||
ememory::SharedPtr<appl::TcpServerInput> m_interfaceGatewayBackEndServer;
|
||||
ememory::SharedPtr<appl::TcpServerInput> m_interfaceGateWayServer;
|
||||
ejson::Document m_listUser;
|
||||
public:
|
||||
eproperty::Value<std::string> propertyClientIp;
|
||||
eproperty::Value<uint16_t> propertyClientPort;
|
||||
eproperty::Value<uint16_t> propertyClientMax;
|
||||
eproperty::Value<std::string> propertyGatewayBackEndIp;
|
||||
eproperty::Value<uint16_t> propertyGatewayBackEndPort;
|
||||
eproperty::Value<uint16_t> propertyGatewayBackEndMax;
|
||||
eproperty::Value<std::string> propertyGateWayIp;
|
||||
eproperty::Value<uint16_t> propertyGateWayPort;
|
||||
eproperty::Value<uint16_t> propertyGateWayMax;
|
||||
public:
|
||||
GateWay();
|
||||
virtual ~GateWay();
|
||||
Router();
|
||||
virtual ~Router();
|
||||
void start();
|
||||
void stop();
|
||||
// Get a specific user gateway:
|
||||
@ -37,7 +37,7 @@ namespace appl {
|
||||
|
||||
std::vector<std::string> getAllUserName();
|
||||
void answer(uint64_t _userSessionId, const ememory::SharedPtr<zeus::Buffer>& _data);
|
||||
void newClientGateWayBackEnd(enet::Tcp _connection);
|
||||
void newClientGateWay(enet::Tcp _connection);
|
||||
void newClient(enet::Tcp _connection);
|
||||
void cleanIO();
|
||||
private:
|
@ -7,6 +7,6 @@
|
||||
#include <appl/debug.hpp>
|
||||
|
||||
int32_t appl::getLogId() {
|
||||
static int32_t g_val = elog::registerInstance("zeus-gateway");
|
||||
static int32_t g_val = elog::registerInstance("zeus-router");
|
||||
return g_val;
|
||||
}
|
@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
#include <appl/debug.hpp>
|
||||
#include <appl/GateWay.hpp>
|
||||
#include <appl/Router.hpp>
|
||||
#include <etk/etk.hpp>
|
||||
#include <zeus/zeus.hpp>
|
||||
|
||||
@ -15,21 +15,21 @@
|
||||
int main(int _argc, const char *_argv[]) {
|
||||
etk::init(_argc, _argv);
|
||||
zeus::init(_argc, _argv);
|
||||
appl::GateWay basicGateway;
|
||||
appl::Router basicRouter;
|
||||
for (int32_t iii=0; iii<_argc ; ++iii) {
|
||||
std::string data = _argv[iii];
|
||||
if (etk::start_with(data, "--client-ip=") == true) {
|
||||
basicGateway.propertyClientIp.set(std::string(&data[12]));
|
||||
basicRouter.propertyClientIp.set(std::string(&data[12]));
|
||||
} else if (etk::start_with(data, "--client-port=") == true) {
|
||||
basicGateway.propertyClientPort.set(etk::string_to_uint16_t(std::string(&data[14])));
|
||||
basicRouter.propertyClientPort.set(etk::string_to_uint16_t(std::string(&data[14])));
|
||||
} else if (etk::start_with(data, "--client-max=") == true) {
|
||||
basicGateway.propertyClientMax.set(etk::string_to_uint16_t(std::string(&data[13])));
|
||||
basicRouter.propertyClientMax.set(etk::string_to_uint16_t(std::string(&data[13])));
|
||||
} else if (etk::start_with(data, "--gw-ip=") == true) {
|
||||
basicGateway.propertyGatewayBackEndIp.set(std::string(&data[8]));
|
||||
basicRouter.propertyGateWayIp.set(std::string(&data[8]));
|
||||
} else if (etk::start_with(data, "--gw-port=") == true) {
|
||||
basicGateway.propertyGatewayBackEndPort.set(etk::string_to_uint16_t(std::string(&data[10])));
|
||||
basicRouter.propertyGateWayPort.set(etk::string_to_uint16_t(std::string(&data[10])));
|
||||
} else if (etk::start_with(data, "--gw-max=") == true) {
|
||||
basicGateway.propertyGatewayBackEndMax.set(etk::string_to_uint16_t(std::string(&data[9])));
|
||||
basicRouter.propertyGateWayMax.set(etk::string_to_uint16_t(std::string(&data[9])));
|
||||
} else if ( data == "-h"
|
||||
|| data == "--help") {
|
||||
APPL_PRINT(etk::getApplicationName() << " - help : ");
|
||||
@ -37,23 +37,23 @@ int main(int _argc, const char *_argv[]) {
|
||||
APPL_PRINT(" --client-ip=XXX Client connection IP (default: 1.7.0.0.1)");
|
||||
APPL_PRINT(" --client-port=XXX Client connection PORT (default: 1983)");
|
||||
APPL_PRINT(" --client-max=XXX Client Maximum parallele connection (default: 80)");
|
||||
APPL_PRINT(" --gw-ip=XXX Back-end Gateway connection IP (default: 1.7.0.0.1)");
|
||||
APPL_PRINT(" --gw-port=XXX Back-end Gateway connection PORT (default: 1984)");
|
||||
APPL_PRINT(" --gw-max=XXX Back-end Gateway Maximum IO (default: 15)");
|
||||
APPL_PRINT(" --gw-ip=XXX Gateway connection IP (default: 1.7.0.0.1)");
|
||||
APPL_PRINT(" --gw-port=XXX Gateway connection PORT (default: 1984)");
|
||||
APPL_PRINT(" --gw-max=XXX Gateway Maximum IO (default: 15)");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
APPL_INFO("==================================");
|
||||
APPL_INFO("== ZEUS gateway start ==");
|
||||
APPL_INFO("== ZEUS router start ==");
|
||||
APPL_INFO("==================================");
|
||||
basicGateway.start();
|
||||
basicRouter.start();
|
||||
while (true) {
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
||||
basicGateway.cleanIO();
|
||||
basicRouter.cleanIO();
|
||||
}
|
||||
basicGateway.stop();
|
||||
basicRouter.stop();
|
||||
APPL_INFO("==================================");
|
||||
APPL_INFO("== ZEUS gateway stop ==");
|
||||
APPL_INFO("== ZEUS router stop ==");
|
||||
APPL_INFO("==================================");
|
||||
return 0;
|
||||
}
|
@ -10,7 +10,7 @@ def get_sub_type():
|
||||
return "TOOLS"
|
||||
|
||||
def get_desc():
|
||||
return "ZEUS generic gateway"
|
||||
return "ZEUS generic router"
|
||||
|
||||
def get_licence():
|
||||
return "APACHE-2"
|
||||
@ -31,7 +31,7 @@ def configure(target, my_module):
|
||||
'appl/debug.cpp',
|
||||
'appl/ClientInterface.cpp',
|
||||
'appl/GateWayInterface.cpp',
|
||||
'appl/GateWay.cpp',
|
||||
'appl/Router.cpp',
|
||||
'appl/main.cpp'
|
||||
])
|
||||
return True
|
Loading…
Reference in New Issue
Block a user