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