2019-02-25 14:48:22 +01:00
|
|
|
/* 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"
|
2019-02-18 15:23:41 +01:00
|
|
|
#include "base/tlsstream.hpp"
|
2014-05-25 16:23:35 +02:00
|
|
|
#include "remote/i2-remote.hpp"
|
2019-02-18 15:23:41 +01:00
|
|
|
#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.
|
|
|
|
*
|
2014-03-07 17:40:10 +01:00
|
|
|
* @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:
|
2019-02-25 18:15:47 +01:00
|
|
|
static size_t SendMessage(const std::shared_ptr<AsioTlsStream>& stream, const Dictionary::Ptr& message);
|
2019-02-18 15:23:41 +01:00
|
|
|
static size_t SendMessage(const std::shared_ptr<AsioTlsStream>& stream, const Dictionary::Ptr& message, boost::asio::yield_context yc);
|
2019-02-26 11:13:34 +01:00
|
|
|
static size_t SendRawMessage(const std::shared_ptr<AsioTlsStream>& stream, const String& json, boost::asio::yield_context yc);
|
2019-05-23 17:25:56 +02:00
|
|
|
|
2019-02-25 18:15:47 +01:00
|
|
|
static String ReadMessage(const std::shared_ptr<AsioTlsStream>& stream, ssize_t maxMessageLength = -1);
|
2019-02-19 11:29:45 +01:00
|
|
|
static String ReadMessage(const std::shared_ptr<AsioTlsStream>& stream, boost::asio::yield_context yc, ssize_t maxMessageLength = -1);
|
2019-05-23 17:25:56 +02:00
|
|
|
|
2016-01-27 16:43:23 +01:00
|
|
|
static Dictionary::Ptr DecodeMessage(const String& message);
|
2013-03-10 05:10:51 +01:00
|
|
|
|
2013-04-04 16:08:02 +02:00
|
|
|
private:
|
2018-01-04 04:25:35 +01:00
|
|
|
JsonRpc();
|
2013-03-10 03:09:01 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-04-04 16:08:02 +02:00
|
|
|
#endif /* JSONRPC_H */
|