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>
# 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-06-23 22:08:11 +02:00
class ClientInterface ;
2016-11-21 22:15:46 +01:00
class GateWayInterface {
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-29 21:39:39 +01:00
uint16_t m_lastSourceID ; //!< The source dynbamic generated ID is manage in 2 part the value <= 0x7FFF is used by the gateway and the value >= 0x8000 is manage by the router
std : : vector < ememory : : SharedPtr < appl : : ClientInterface > > m_clientConnected ;
2016-05-12 22:45:40 +02:00
std : : string m_name ;
2016-11-21 22:15:46 +01:00
bool requestURI ( const std : : string & _uri ) ;
2016-05-12 22:45:40 +02:00
public :
2016-11-23 22:03:04 +01:00
GateWayInterface ( enet : : Tcp _connection , appl : : Router * _routerInterface ) ;
2016-11-21 22:15:46 +01:00
virtual ~ GateWayInterface ( ) ;
2016-05-23 21:18:37 +02:00
void start ( ) ;
2016-05-22 22:40:42 +02:00
void stop ( ) ;
2016-12-08 00:16:40 +01:00
void onServiceData ( ememory : : SharedPtr < zeus : : Message > _value ) ;
2016-05-22 22:40:42 +02:00
public :
2016-11-29 21:39:39 +01:00
uint16_t addClient ( ememory : : SharedPtr < appl : : ClientInterface > _value ) ;
void rmClient ( ememory : : SharedPtr < appl : : ClientInterface > _value ) ;
2016-12-08 00:16:40 +01:00
void send ( ememory : : SharedPtr < zeus : : Message > _data ) ;
2016-05-22 22:40:42 +02:00
const std : : string & getName ( ) {
return m_name ;
}
2016-05-24 22:29:03 +02:00
bool isAlive ( ) ;
2016-06-14 21:28:54 +02:00
protected :
void answerProtocolError ( uint32_t _transactionId , const std : : string & _errorHelp ) ;
2016-05-12 22:45:40 +02:00
} ;
}