2016-05-12 22:45:40 +02:00
|
|
|
/** @file
|
|
|
|
* @author Edouard DUPIN
|
|
|
|
* @copyright 2016, Edouard DUPIN, all right reserved
|
|
|
|
* @license APACHE v2.0 (see license file)
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2016-06-23 22:08:11 +02:00
|
|
|
#include <zeus/WebServer.h>
|
|
|
|
#include <appl/GateWay.h>
|
|
|
|
#include <appl/ServiceInterface.h>
|
2016-05-12 22:45:40 +02:00
|
|
|
|
2016-06-23 22:08:11 +02:00
|
|
|
namespace appl {
|
2016-05-22 22:40:42 +02:00
|
|
|
class GateWay;
|
2016-06-23 22:08:11 +02:00
|
|
|
class ClientInterface {
|
2016-05-25 23:26:59 +02:00
|
|
|
private:
|
|
|
|
enum class state {
|
|
|
|
unconnect, // starting sate
|
2016-06-20 23:07:25 +02:00
|
|
|
connect, // zeust get a TCP connection
|
2016-05-25 23:26:59 +02:00
|
|
|
userIdentify, // client set the user it want to access
|
|
|
|
clientIdentify, // client defien the mode of the acces (anonymous,client/user)
|
|
|
|
disconnect // client is dead or loal disconnection
|
|
|
|
};
|
|
|
|
enum state m_state; // state machine ...
|
2016-05-22 22:40:42 +02:00
|
|
|
private:
|
2016-06-23 22:08:11 +02:00
|
|
|
appl::GateWay* m_gatewayInterface;
|
|
|
|
zeus::WebServer m_interfaceClient;
|
2016-05-23 21:18:37 +02:00
|
|
|
public:
|
2016-06-23 22:08:11 +02:00
|
|
|
ememory::SharedPtr<appl::ServiceInterface> m_userService;
|
|
|
|
std::vector<ememory::SharedPtr<appl::ServiceInterface>> m_listConnectedService;
|
2016-05-26 22:12:37 +02:00
|
|
|
uint64_t m_uid;
|
|
|
|
uint64_t m_uid2;
|
2016-05-22 23:15:09 +02:00
|
|
|
std::string m_userConnectionName;
|
2016-05-25 21:25:33 +02:00
|
|
|
std::string m_clientName;
|
|
|
|
std::vector<std::string> m_clientgroups;
|
2016-05-27 22:21:32 +02:00
|
|
|
std::vector<std::string> m_clientServices;
|
2016-05-12 22:45:40 +02:00
|
|
|
public:
|
2016-06-23 22:08:11 +02:00
|
|
|
ClientInterface(enet::Tcp _connection, appl::GateWay* _gatewayInterface);
|
|
|
|
virtual ~ClientInterface();
|
2016-05-26 22:12:37 +02:00
|
|
|
void start(uint64_t _uid, uint64_t _uid2);
|
2016-05-12 22:45:40 +02:00
|
|
|
void stop();
|
2016-07-19 22:31:27 +02:00
|
|
|
void onClientData(ememory::SharedPtr<zeus::Buffer> _value);
|
|
|
|
void returnMessage(ememory::SharedPtr<zeus::Buffer> _data);
|
2016-05-26 22:12:37 +02:00
|
|
|
bool checkId(uint64_t _id) const {
|
|
|
|
return m_uid == _id
|
|
|
|
|| m_uid2 == _id;
|
2016-05-23 21:18:37 +02:00
|
|
|
}
|
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
|
|
|
};
|
|
|
|
}
|
|
|
|
|