icinga2/lib/remote/jsonrpc.hpp

40 lines
1.1 KiB
C++
Raw Normal View History

/* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
2013-03-10 03:09:01 +01:00
2013-04-04 16:08:02 +02:00
#ifndef JSONRPC_H
#define JSONRPC_H
2013-03-10 03:09:01 +01:00
2014-05-25 16:23:35 +02:00
#include "base/stream.hpp"
#include "base/dictionary.hpp"
#include "base/tlsstream.hpp"
2014-05-25 16:23:35 +02:00
#include "remote/i2-remote.hpp"
#include <memory>
#include <boost/asio/spawn.hpp>
2013-03-17 20:19:29 +01:00
2013-04-04 16:08:02 +02:00
namespace icinga
2013-03-10 03:09:01 +01:00
{
2013-04-04 16:08:02 +02:00
/**
* A JSON-RPC connection.
*
* @ingroup remote
2013-04-04 16:08:02 +02:00
*/
2017-12-31 07:22:16 +01:00
class JsonRpc
2013-03-10 03:09:01 +01:00
{
public:
static size_t SendMessage(const std::shared_ptr<AsioTlsStream>& stream, const Dictionary::Ptr& message);
static size_t SendMessage(const std::shared_ptr<AsioTlsStream>& stream, const Dictionary::Ptr& message, boost::asio::yield_context yc);
static size_t SendRawMessage(const std::shared_ptr<AsioTlsStream>& stream, const String& json, boost::asio::yield_context yc);
static String ReadMessage(const std::shared_ptr<AsioTlsStream>& stream, ssize_t maxMessageLength = -1);
static String ReadMessage(const std::shared_ptr<AsioTlsStream>& stream, boost::asio::yield_context yc, ssize_t maxMessageLength = -1);
static Dictionary::Ptr DecodeMessage(const String& message);
2013-03-10 05:10:51 +01:00
2013-04-04 16:08:02 +02:00
private:
JsonRpc();
2013-03-10 03:09:01 +01:00
};
}
2013-04-04 16:08:02 +02:00
#endif /* JSONRPC_H */