mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-23 05:34:48 +02:00
JsonRpc::ReadMessage(): add Boost ASIO overload
This commit is contained in:
parent
b26808414c
commit
c76947e8b9
@ -9,6 +9,7 @@
|
|||||||
#include "base/tlsstream.hpp"
|
#include "base/tlsstream.hpp"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <utility>
|
||||||
#include <boost/asio/spawn.hpp>
|
#include <boost/asio/spawn.hpp>
|
||||||
|
|
||||||
using namespace icinga;
|
using namespace icinga;
|
||||||
@ -95,6 +96,18 @@ StreamReadStatus JsonRpc::ReadMessage(const Stream::Ptr& stream, String *message
|
|||||||
return StatusNewItem;
|
return StatusNewItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String JsonRpc::ReadMessage(const std::shared_ptr<AsioTlsStream>& stream, boost::asio::yield_context yc, ssize_t maxMessageLength)
|
||||||
|
{
|
||||||
|
String jsonString = NetString::ReadStringFromStream(stream, yc, maxMessageLength);
|
||||||
|
|
||||||
|
#ifdef I2_DEBUG
|
||||||
|
if (GetDebugJsonRpcCached())
|
||||||
|
std::cerr << ConsoleColorTag(Console_ForegroundBlue) << "<< " << jsonString << ConsoleColorTag(Console_Normal) << "\n";
|
||||||
|
#endif /* I2_DEBUG */
|
||||||
|
|
||||||
|
return std::move(jsonString);
|
||||||
|
}
|
||||||
|
|
||||||
Dictionary::Ptr JsonRpc::DecodeMessage(const String& message)
|
Dictionary::Ptr JsonRpc::DecodeMessage(const String& message)
|
||||||
{
|
{
|
||||||
Value value = JsonDecode(message);
|
Value value = JsonDecode(message);
|
||||||
|
@ -24,6 +24,7 @@ public:
|
|||||||
static size_t SendMessage(const Stream::Ptr& stream, const Dictionary::Ptr& message);
|
static size_t SendMessage(const Stream::Ptr& 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 SendMessage(const std::shared_ptr<AsioTlsStream>& stream, const Dictionary::Ptr& message, boost::asio::yield_context yc);
|
||||||
static StreamReadStatus ReadMessage(const Stream::Ptr& stream, String *message, StreamReadContext& src, bool may_wait = false, ssize_t maxMessageLength = -1);
|
static StreamReadStatus ReadMessage(const Stream::Ptr& stream, String *message, StreamReadContext& src, bool may_wait = false, 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);
|
static Dictionary::Ptr DecodeMessage(const String& message);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user