zeus/tools/gateway-front-end/appl/ClientInterface.hpp

51 lines
1.3 KiB
C++
Raw Normal View History

/** @file
* @author Edouard DUPIN
* @copyright 2016, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
*/
#pragma once
2016-10-02 17:01:22 +02:00
#include <zeus/WebServer.hpp>
#include <appl/GateWay.hpp>
#include <appl/GateWayInterface.hpp>
2016-06-23 22:08:11 +02:00
namespace appl {
class GateWay;
2016-06-23 22:08:11 +02:00
class ClientInterface {
private:
enum class state {
unconnect, // starting sate
connect, // zeust get a TCP connection
disconnect // client is dead or loal disconnection
};
enum state m_state; // state machine ...
private:
2016-06-23 22:08:11 +02:00
appl::GateWay* m_gatewayInterface;
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;
uint64_t m_uid;
std::string m_userConnectionName;
2016-05-25 21:25:33 +02:00
std::string m_clientName;
std::vector<std::string> m_clientgroups;
std::vector<std::string> m_clientServices;
public:
2016-06-23 22:08:11 +02:00
ClientInterface(enet::Tcp _connection, appl::GateWay* _gatewayInterface);
virtual ~ClientInterface();
2016-11-22 21:19:00 +01:00
void start(uint64_t _uid);
void stop();
2016-07-19 22:31:27 +02:00
void onClientData(ememory::SharedPtr<zeus::Buffer> _value);
void returnMessage(ememory::SharedPtr<zeus::Buffer> _data);
bool checkId(uint64_t _id) const {
2016-11-22 21:19:00 +01:00
return m_uid == _id;
2016-05-23 21:18:37 +02:00
}
bool isAlive();
void answerProtocolError(uint32_t _transactionId, const std::string& _errorHelp);
};
}