15 #ifndef ZYPP_CORE_ZYPPNG_RPC_STOMPFRAMESTREAM_H_INCLUDED 16 #define ZYPP_CORE_ZYPPNG_RPC_STOMPFRAMESTREAM_H_INCLUDED 19 #include <zypp-core/zyppng/base/Base> 20 #include <zypp-core/zyppng/core/String> 21 #include <zypp-core/zyppng/base/Signals> 22 #include <zypp-core/zyppng/base/Timer> 23 #include <zypp-core/zyppng/io/IODevice> 45 return msg.toStompMessage();
58 if constexpr ( std::is_same_v<bool, T> ) {
60 if ( indeterminate(triBool) ) {
63 target =
bool(triBool);
64 }
else if constexpr ( std::is_same_v<std::string, T> ) {
68 auto val = zyppng::str::safe_strtonum<T> ( headerVal );
84 return zypp::PluginFrame ( std::string( T::typeName.data(), T::typeName.length() ) );
98 using Ptr = StompFrameStreamRef;
114 std::optional<zypp::PluginFrame> nextMessage (
const std::string &msgName =
"" );
124 std::optional<zypp::PluginFrame> nextMessageWait (
const std::string &msgName =
"" );
132 template <
typename T>
135 if constexpr ( std::is_same_v<T, zypp::PluginFrame> ) {
136 return sendFrame( message );
140 ERR <<
"Failed to serialize message" << std::endl;
143 return sendFrame( *msg );
149 return rpc::fromStompMessage<T>(m);
156 void readAllMessages ();
171 bool readNextMessage ();
179 } _parserState = ReceiveCommand;
193 #endif // ZYPP_CORE_ZYPPNG_RPC_STOMPFRAMESTREAM_H_INCLUDED
expected< zypp::PluginFrame > toStompMessage(const T &msg)
static Ptr create(IODevice::Ptr iostr)
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.
Command frame for communication with PluginScript.
Signal< void()> _sigNextMessage
bool sendMessage(const T &message)
expected< T > fromStompMessage(const zypp::PluginFrame &message)
TriBool strToTriBool(const C_Str &str)
Parse str into a bool if it's a legal true or false string; else indeterminate.
void parseDataIntoField(const std::string &headerVal, T &target)
Base class for PluginFrame Exception.
std::optional< int64_t > _pendingBodyLen
The Timer class provides repetitive and single-shot timers.
zypp::PluginFrame prepareFrame()
std::shared_ptr< IODevice > Ptr
std::optional< zypp::PluginFrame > _pendingMessage
std::shared_ptr< Timer > Ptr
static std::shared_ptr< Timer > create()
Creates a new Timer object, the timer is not started at this point.
Base class for Exception.
ZYPP_FWD_DECL_TYPE_WITH_REFS(EventDispatcher)
Signal< void()> _sigInvalidMessageReceived
void parseHeaderIntoField(const zypp::PluginFrame &msg, const std::string &name, T &target)
const std::string & getHeader(const std::string &key_r) const
Return header value for key_r.
static expected< T > parseMessage(const zypp::PluginFrame &m)
std::shared_ptr< Base > Ptr
std::deque< zypp::PluginFrame > _messages