mirror of
https://github.com/Icinga/icinga2.git
synced 2025-08-30 22:18:17 +02:00
All usages of `AsioTlsStream` were already using `Shared<AsioTlsStream>` to keep a reference-counted instance. This commit moves the reference counting to `AsioTlsStream` itself by inheriting from `SharedObject`. This will allow to implement methods making use of the fact that these objects are reference-counted. The changes outside of `lib/base/tlsstream.hpp` are merely replacing `Shared<AsioTlsStream>::Ptr` with `AsioTlsStream::Ptr` everywhere.
55 lines
1.2 KiB
C++
55 lines
1.2 KiB
C++
/* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
|
|
|
|
#ifndef HTTPSERVERCONNECTION_H
|
|
#define HTTPSERVERCONNECTION_H
|
|
|
|
#include "remote/apiuser.hpp"
|
|
#include "base/string.hpp"
|
|
#include "base/tlsstream.hpp"
|
|
#include <memory>
|
|
#include <boost/asio/deadline_timer.hpp>
|
|
#include <boost/asio/io_context.hpp>
|
|
#include <boost/asio/io_context_strand.hpp>
|
|
#include <boost/asio/spawn.hpp>
|
|
|
|
namespace icinga
|
|
{
|
|
|
|
/**
|
|
* An API client connection.
|
|
*
|
|
* @ingroup remote
|
|
*/
|
|
class HttpServerConnection final : public Object
|
|
{
|
|
public:
|
|
DECLARE_PTR_TYPEDEFS(HttpServerConnection);
|
|
|
|
HttpServerConnection(const String& identity, bool authenticated, const AsioTlsStream::Ptr& stream);
|
|
|
|
void Start();
|
|
void Disconnect();
|
|
void StartStreaming();
|
|
|
|
bool Disconnected();
|
|
|
|
private:
|
|
ApiUser::Ptr m_ApiUser;
|
|
AsioTlsStream::Ptr m_Stream;
|
|
double m_Seen;
|
|
String m_PeerAddress;
|
|
boost::asio::io_context::strand m_IoStrand;
|
|
bool m_ShuttingDown;
|
|
bool m_HasStartedStreaming;
|
|
boost::asio::deadline_timer m_CheckLivenessTimer;
|
|
|
|
HttpServerConnection(const String& identity, bool authenticated, const AsioTlsStream::Ptr& stream, boost::asio::io_context& io);
|
|
|
|
void ProcessMessages(boost::asio::yield_context yc);
|
|
void CheckLiveness(boost::asio::yield_context yc);
|
|
};
|
|
|
|
}
|
|
|
|
#endif /* HTTPSERVERCONNECTION_H */
|