XII Release 0.1.0
Loading...
Searching...
No Matches
xiiIpcProcessMessageProtocol Class Reference

A protocol wrapper around xiiIpcChannel to send and receive reflected messages instead of raw byte arrays. More...

#include <IpcProcessMessageProtocol.h>

Classes

struct  Event
 Event data structure for message notifications. More...
 

Public Member Functions

 xiiIpcProcessMessageProtocol (xiiIpcChannel *pChannel)
 Constructs the protocol wrapper for a given IPC channel.
 
 ~xiiIpcProcessMessageProtocol ()
 Destructor. Cleans up any queued messages and detaches from the channel.
 
bool Send (xiiProcessMessage *pMsg)
 Sends a reflected process message over the IPC channel.
 
bool ProcessMessages ()
 Processes all pending incoming messages.
 
xiiResult WaitForMessages (xiiTime timeout=xiiTime::MakeZero())
 Waits for new messages to arrive and processes them.
 

Public Attributes

xiiEvent< const Event & > m_MessageEvent
 Event fired when a new message is processed.
 

Detailed Description

A protocol wrapper around xiiIpcChannel to send and receive reflected messages instead of raw byte arrays.

This class hooks into an existing xiiIpcChannel instance to provide a high-level messaging protocol using reflected messages derived from xiiProcessMessage. The underlying xiiIpcChannel remains responsible for all connection logic, while this protocol focuses solely on message serialization, deserialization, and dispatch.

Note
When using this protocol, do not call xiiIpcChannel::Send directly. Instead, use xiiIpcProcessMessageProtocol::Send to ensure proper message formatting and handling.

Received messages are stored in an internal queue and must be processed explicitly by calling ProcessMessages() or WaitForMessages().

Constructor & Destructor Documentation

◆ xiiIpcProcessMessageProtocol()

xiiIpcProcessMessageProtocol::xiiIpcProcessMessageProtocol ( xiiIpcChannel * pChannel)

Constructs the protocol wrapper for a given IPC channel.

Parameters
pChannel- Pointer to an existing xiiIpcChannel instance. The channel must remain valid for the lifetime of this protocol object.

Member Function Documentation

◆ ProcessMessages()

bool xiiIpcProcessMessageProtocol::ProcessMessages ( )

Processes all pending incoming messages.

This method dequeues all received messages and broadcasts them via m_MessageEvent. It is not re-entrant; calling it from within a message handler is not supported.

Returns
True if any messages were processed, false otherwise.

◆ Send()

bool xiiIpcProcessMessageProtocol::Send ( xiiProcessMessage * pMsg)

Sends a reflected process message over the IPC channel.

Parameters
pMsg- Pointer to the message to send. Ownership is not transferred; the message can be safely destroyed after this call returns.
Returns
True if the message was successfully queued for sending, false otherwise.

◆ WaitForMessages()

xiiResult xiiIpcProcessMessageProtocol::WaitForMessages ( xiiTime timeout = xiiTime::MakeZero())

Waits for new messages to arrive and processes them.

This method blocks until either a message is received or the specified timeout elapses. Once unblocked, it calls ProcessMessages() to handle all queued messages.

Parameters
timeoutMaximum time to wait for a message. Defaults to zero (non-blocking).
Returns
xiiResult::Success if messages were processed, xiiResult::Failure on timeout or error.

Member Data Documentation

◆ m_MessageEvent

xiiEvent<const Event&> xiiIpcProcessMessageProtocol::m_MessageEvent

Event fired when a new message is processed.

This event is triggered from the thread calling ProcessMessages() or WaitForMessages().


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