zeus/tools/router/appl/ClientInterface.hpp

45 lines
1.2 KiB
C++
Raw Normal View History

/** @file
* @author Edouard DUPIN
* @copyright 2016, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
#pragma once
2016-10-02 17:01:22 +02:00
#include <zeus/WebServer.hpp>
#include <appl/Router.hpp>
#include <appl/GateWayInterface.hpp>
2016-11-29 21:39:39 +01:00
#include <ememory/memory.hpp>
2016-06-23 22:08:11 +02:00
namespace appl {
class Router;
2016-11-29 21:39:39 +01:00
class GateWayInterface;
class ClientInterface : public ememory::EnableSharedFromThis<appl::ClientInterface> {
private:
appl::Router* m_routerInterface;
2016-06-23 22:08:11 +02:00
zeus::WebServer m_interfaceClient;
bool requestURI(const std::string& _uri);
2016-05-23 21:18:37 +02:00
public:
ememory::SharedPtr<appl::GateWayInterface> m_userGateWay;
2016-11-29 21:39:39 +01:00
uint16_t m_uid; //!< gateway unique ID ==> to have an internal routage ...
public:
ClientInterface(enet::Tcp _connection, appl::Router* _routerInterface);
2016-06-23 22:08:11 +02:00
virtual ~ClientInterface();
2016-11-29 21:39:39 +01:00
void start();
void stop();
void onClientData(ememory::SharedPtr<zeus::Message> _value);
void send(ememory::SharedPtr<zeus::Message> _data);
2016-11-29 21:39:39 +01:00
bool checkId(uint16_t _id) const {
2016-11-22 21:19:00 +01:00
return m_uid == _id;
2016-05-23 21:18:37 +02:00
}
uint16_t getId() const {
return m_uid;
}
bool isAlive();
void answerProtocolError(uint32_t _transactionId, const std::string& _errorHelp);
};
}