libzypp 17.37.10

zyppng::StompFrameStream Class Reference

`#include <zypp-core/zyppng/rpc/stompframestream.h>`

Inheritance diagram for zyppng::StompFrameStream:

## Public Types
using | Ptr = StompFrameStreamRef
Public Types inherited from zyppng::Base
using | Ptr = std::shared_ptr<Base>
using | WeakPtr = std::weak_ptr<Base>

## Public Member Functions
std::optional< zypp::PluginFrame > | nextMessage (const std::string &msgName="")
std::optional< zypp::PluginFrame > | nextMessageWait (const std::string &msgName="")
bool | sendFrame (const zypp::PluginFrame &message)
template<typename T>
bool | sendMessage (const T &message)
void | readAllMessages ()
SignalProxy< void()> | sigMessageReceived ()
SignalProxy< void()> | sigInvalidMessageReceived ()
Public Member Functions inherited from zyppng::Base
| Base ()
virtual | ~Base ()
WeakPtr | parent () const
void | addChild (const Base::Ptr &child)
void | removeChild (const Ptr &child)
const std::unordered_set< Ptr > & | children () const
std::thread::id | threadId () const
template<typename T>
std::vector< std::weak_ptr< T > > | findChildren () const
template<typename T>
std::shared_ptr< T > | shared_this () const
template<typename T>
std::shared_ptr< T > | shared_this ()
template<typename T>
std::weak_ptr< T > | weak_this () const
template<typename T>
std::weak_ptr< T > | weak_this ()
template<typename SenderFunc, typename ReceiverFunc>
auto | connect (SenderFunc &&sFun, typename internal::MemberFunction< ReceiverFunc >::ClassType &recv, ReceiverFunc &&rFunc)
template<typename SenderFunc, typename ReceiverFunc, typename ... Tracker>
std::enable_if_t< std::is_member_function_pointer_v< SenderFunc >, connection > | connectFunc (SenderFunc &&sFun, ReceiverFunc &&rFunc, const Tracker &...trackers)

## Static Public Member Functions
static Ptr | create (IODevice::Ptr iostr)
template<class T>
static expected< T > | parseMessage (const zypp::PluginFrame &m)
Static Public Member Functions inherited from zyppng::Base
template<typename Obj, typename Functor>
static decltype(auto) | make_base_slot (Obj *o, Functor &&f)
template<typename SenderFunc, typename ReceiverFunc>
static auto | connect (typename internal::MemberFunction< SenderFunc >::ClassType &s, SenderFunc &&sFun, typename internal::MemberFunction< ReceiverFunc >::ClassType &recv, ReceiverFunc &&rFunc)
template<typename SenderFunc, typename ReceiverFunc, typename ... Tracker>
static auto | connectFunc (typename internal::MemberFunction< SenderFunc >::ClassType &s, SenderFunc &&sFun, ReceiverFunc &&rFunc, const Tracker &...trackers)

## Private Types
enum | ParserState { ReceiveCommand , ReceiveHeaders , ReceiveBody , ParseError }

## Private Member Functions
| StompFrameStream (IODevice::Ptr iostr)
bool | readNextMessage ()
void | timeout (const zyppng::Timer &)

## Private Attributes
enum zyppng::StompFrameStream::ParserState | _parserState = ReceiveCommand
std::optional< zypp::PluginFrame > | _pendingMessage
std::optional< int64_t > | _pendingBodyLen
IODevice::Ptr | _ioDev
Timer::Ptr | _nextMessageTimer = Timer::create()
std::deque< zypp::PluginFrame > | _messages
Signal< void()> | _sigNextMessage
Signal< void()> | _sigInvalidMessageReceived

## Additional Inherited Members
Protected Member Functions inherited from zyppng::Base
| Base (BasePrivate &dd)
Protected Attributes inherited from zyppng::Base
std::unique_ptr< BasePrivate > | d_ptr

## Detailed Description

Implements the basic protocol for sending zypp RPC messages over a IODevice using the STOMP frame format as message type.

Definition at line 94 of file stompframestream.h.

## Member Typedef Documentation

## ◆ Ptr

using zyppng::StompFrameStream::Ptr = StompFrameStreamRef

Definition at line 98 of file stompframestream.h.

## Member Enumeration Documentation

## ◆ ParserState

enum zyppng::StompFrameStream::ParserState
| private

Enumerator
ReceiveCommand |
ReceiveHeaders |
ReceiveBody |
ParseError |

Definition at line 174 of file stompframestream.h.

## Constructor & Destructor Documentation

## ◆ StompFrameStream()

zyppng::StompFrameStream::StompFrameStream | ( | IODevice::Ptr | iostr | ) |
| private

Definition at line 27 of file stompframestream.cc.

## Member Function Documentation

## ◆ create()

Ptr zyppng::StompFrameStream::create | ( | IODevice::Ptr | iostr | ) |
| inline static

Uses the given iostream to send and receive messages. If the device is already open and readable tries to read messages right away. So make sure to check if messages have already been received via nextMessage

Definition at line 105 of file stompframestream.h.

## ◆ nextMessage()

std::optional< zypp::PluginFrame > zyppng::StompFrameStream::nextMessage | ( | const std::string & | msgName = "" | ) |

Returns the next message in the queue, wait for the sigMessageReceived signal to know when new messages have arrived. If msgName is specified returns the next message in the queue that matches the msgName

Definition at line 217 of file stompframestream.cc.

## ◆ nextMessageWait()

std::optional< zypp::PluginFrame > zyppng::StompFrameStream::nextMessageWait | ( | const std::string & | msgName = "" | ) |

Waits until at least one message is in the queue and returns it. Will return a empty optional if a error occurs.

If msgName is set this will block until a message with the given message name arrives and returns it

Note
  Make sure to check if there are more than one messages in the queue after this function returns

Definition at line 259 of file stompframestream.cc.

## ◆ sendFrame()

bool zyppng::StompFrameStream::sendFrame | ( | const zypp::PluginFrame & | message | ) |

Send out a PluginFrame to the other side, depending on the underlying device state this will be buffered and send when the device is writeable again.

Definition at line 292 of file stompframestream.cc.

## ◆ sendMessage()

template<typename T>

bool zyppng::StompFrameStream::sendMessage | ( | const T & | message | ) |
| inline

Definition at line 133 of file stompframestream.h.

## ◆ parseMessage()

template<class T>

expected< T > zyppng::StompFrameStream::parseMessage | ( | const zypp::PluginFrame & | m | ) |
| inline static

Definition at line 148 of file stompframestream.h.

## ◆ readAllMessages()

void zyppng::StompFrameStream::readAllMessages | ( |  | ) |

Reads all messages from the underlying IO Device, this is usually called automatically but when shutting down this can be used to process all remaining messages.

Definition at line 320 of file stompframestream.cc.

## ◆ sigMessageReceived()

SignalProxy< void()> zyppng::StompFrameStream::sigMessageReceived | ( |  | ) |

Emitted when new messages have arrived. This will continuously be emitted as long as messages are in the queue.

Definition at line 310 of file stompframestream.cc.

## ◆ sigInvalidMessageReceived()

SignalProxy< void()> zyppng::StompFrameStream::sigInvalidMessageReceived | ( |  | ) |

Signal is emitted every time there was data on the line that could not be parsed

Definition at line 315 of file stompframestream.cc.

## ◆ readNextMessage()

bool zyppng::StompFrameStream::readNextMessage | ( |  | ) |
| private

Definition at line 37 of file stompframestream.cc.

## ◆ timeout()

void zyppng::StompFrameStream::timeout | ( | const zyppng::Timer & |  | ) |
| private

Definition at line 208 of file stompframestream.cc.

## Member Data Documentation

## ◆ _parserState

enum zyppng::StompFrameStream::ParserState zyppng::StompFrameStream::_parserState = ReceiveCommand
| private

## ◆ _pendingMessage

std::optional<zypp::PluginFrame> zyppng::StompFrameStream::_pendingMessage
| private

Definition at line 181 of file stompframestream.h.

## ◆ _pendingBodyLen

std::optional<int64_t> zyppng::StompFrameStream::_pendingBodyLen
| private

Definition at line 182 of file stompframestream.h.

## ◆ _ioDev

IODevice::Ptr zyppng::StompFrameStream::_ioDev
| private

Definition at line 184 of file stompframestream.h.

## ◆ _nextMessageTimer

Timer::Ptr zyppng::StompFrameStream::_nextMessageTimer = Timer::create()
| private

Definition at line 185 of file stompframestream.h.

## ◆ _messages

std::deque<zypp::PluginFrame> zyppng::StompFrameStream::_messages
| private

Definition at line 186 of file stompframestream.h.

## ◆ _sigNextMessage

Signal<void()> zyppng::StompFrameStream::_sigNextMessage
| private

Definition at line 187 of file stompframestream.h.

## ◆ _sigInvalidMessageReceived

Signal<void()> zyppng::StompFrameStream::_sigInvalidMessageReceived
| private

Definition at line 188 of file stompframestream.h.

The documentation for this class was generated from the following files:

- zypp-core/zyppng/rpc/stompframestream.h
- zypp-core/zyppng/rpc/stompframestream.cc