2016-05-12 22:45:40 +02:00
|
|
|
/** @file
|
|
|
|
* @author Edouard DUPIN
|
|
|
|
* @copyright 2016, Edouard DUPIN, all right reserved
|
2017-01-05 21:28:23 +01:00
|
|
|
* @license MPL v2.0 (see license file)
|
2016-05-12 22:45:40 +02:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2016-10-02 17:01:22 +02:00
|
|
|
#include <zeus/WebServer.hpp>
|
2016-11-23 22:03:04 +01:00
|
|
|
#include <appl/Router.hpp>
|
2016-11-21 22:15:46 +01:00
|
|
|
#include <appl/GateWayInterface.hpp>
|
2016-11-29 21:39:39 +01:00
|
|
|
#include <ememory/memory.hpp>
|
2016-05-12 22:45:40 +02:00
|
|
|
|
2016-06-23 22:08:11 +02:00
|
|
|
namespace appl {
|
2016-11-23 22:03:04 +01:00
|
|
|
class Router;
|
2016-11-29 21:39:39 +01:00
|
|
|
class GateWayInterface;
|
|
|
|
class ClientInterface : public ememory::EnableSharedFromThis<appl::ClientInterface> {
|
2016-05-22 22:40:42 +02:00
|
|
|
private:
|
2016-11-23 22:03:04 +01:00
|
|
|
appl::Router* m_routerInterface;
|
2016-06-23 22:08:11 +02:00
|
|
|
zeus::WebServer m_interfaceClient;
|
2016-11-21 22:15:46 +01:00
|
|
|
bool requestURI(const std::string& _uri);
|
2016-05-23 21:18:37 +02:00
|
|
|
public:
|
2016-11-21 22:15:46 +01:00
|
|
|
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 ...
|
2016-05-12 22:45:40 +02:00
|
|
|
public:
|
2016-11-23 22:03:04 +01:00
|
|
|
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();
|
2016-05-12 22:45:40 +02:00
|
|
|
void stop();
|
2016-12-08 00:16:40 +01:00
|
|
|
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
|
|
|
}
|
2016-12-08 22:13:16 +01:00
|
|
|
uint16_t getId() const {
|
|
|
|
return m_uid;
|
|
|
|
}
|
2016-05-24 22:29:03 +02:00
|
|
|
bool isAlive();
|
2016-05-27 22:21:32 +02:00
|
|
|
|
2016-06-14 21:28:54 +02:00
|
|
|
void answerProtocolError(uint32_t _transactionId, const std::string& _errorHelp);
|
|
|
|
|
|
|
|
|
2016-05-12 22:45:40 +02:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|