2019-02-25 14:48:22 +01:00
|
|
|
/* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
|
2014-04-12 04:21:09 +02:00
|
|
|
|
2015-08-29 01:16:16 +02:00
|
|
|
#ifndef HTTPSERVERCONNECTION_H
|
|
|
|
#define HTTPSERVERCONNECTION_H
|
2014-04-12 04:21:09 +02:00
|
|
|
|
2015-06-22 11:11:21 +02:00
|
|
|
#include "remote/apiuser.hpp"
|
2019-02-14 16:10:41 +01:00
|
|
|
#include "base/string.hpp"
|
2014-10-16 12:27:09 +02:00
|
|
|
#include "base/tlsstream.hpp"
|
2019-02-14 16:10:41 +01:00
|
|
|
#include <memory>
|
2019-02-20 14:56:12 +01:00
|
|
|
#include <boost/asio/io_service_strand.hpp>
|
2019-02-14 16:10:41 +01:00
|
|
|
#include <boost/asio/spawn.hpp>
|
2014-04-12 04:21:09 +02:00
|
|
|
|
|
|
|
namespace icinga
|
|
|
|
{
|
|
|
|
|
|
|
|
/**
|
2014-05-03 20:02:22 +02:00
|
|
|
* An API client connection.
|
2014-04-12 04:21:09 +02:00
|
|
|
*
|
2014-05-03 20:02:22 +02:00
|
|
|
* @ingroup remote
|
2014-04-12 04:21:09 +02:00
|
|
|
*/
|
2018-01-04 06:11:04 +01:00
|
|
|
class HttpServerConnection final : public Object
|
2014-04-12 04:21:09 +02:00
|
|
|
{
|
|
|
|
public:
|
2015-08-29 01:16:16 +02:00
|
|
|
DECLARE_PTR_TYPEDEFS(HttpServerConnection);
|
2014-05-03 20:02:22 +02:00
|
|
|
|
2019-02-14 16:10:41 +01:00
|
|
|
HttpServerConnection(const String& identity, bool authenticated, const std::shared_ptr<AsioTlsStream>& stream);
|
2014-05-03 20:02:22 +02:00
|
|
|
|
2018-01-04 04:25:35 +01:00
|
|
|
void Start();
|
2019-02-20 14:56:12 +01:00
|
|
|
void Disconnect();
|
2019-04-02 17:37:29 +02:00
|
|
|
void StartStreaming();
|
2014-05-03 20:02:22 +02:00
|
|
|
|
2019-04-03 09:59:45 +02:00
|
|
|
bool Disconnected();
|
|
|
|
|
2014-04-12 04:21:09 +02:00
|
|
|
private:
|
2015-06-22 11:11:21 +02:00
|
|
|
ApiUser::Ptr m_ApiUser;
|
2019-02-14 16:10:41 +01:00
|
|
|
std::shared_ptr<AsioTlsStream> m_Stream;
|
2019-02-20 15:27:15 +01:00
|
|
|
double m_Seen;
|
2018-10-09 15:40:16 +02:00
|
|
|
String m_PeerAddress;
|
2019-02-20 14:56:12 +01:00
|
|
|
boost::asio::io_service::strand m_IoStrand;
|
|
|
|
bool m_ShuttingDown;
|
2019-04-02 17:37:29 +02:00
|
|
|
bool m_HasStartedStreaming;
|
2014-05-03 20:02:22 +02:00
|
|
|
|
2019-02-14 16:10:41 +01:00
|
|
|
void ProcessMessages(boost::asio::yield_context yc);
|
2019-02-20 15:27:15 +01:00
|
|
|
void CheckLiveness(boost::asio::yield_context yc);
|
2014-04-12 04:21:09 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2015-08-29 01:16:16 +02:00
|
|
|
#endif /* HTTPSERVERCONNECTION_H */
|