Navigation
Unreal Engine C++ API Reference > Runtime > MessagingCommon
Inheritance Hierarchy
- TSharedFromThis
- IMessageReceiver
- IMessageSender
- IBusListener
- FMessageEndpoint
References
Module | MessagingCommon |
Header | /Engine/Source/Runtime/MessagingCommon/Public/MessageEndpoint.h |
Include | #include "MessageEndpoint.h" |
Syntax
class FMessageEndpoint :
public TSharedFromThis< FMessageEndpoint, ESPMode::ThreadSafe >,
public IMessageReceiver,
public IMessageSender,
public IBusListener
Remarks
Implements a message endpoint for sending and receiving messages on a message bus.
This class provides a convenient implementation of the IMessageReceiver and IMessageSender interfaces, which allow consumers to send and receive messages on a message bus. The endpoint allows for receiving messages asynchronously as they arrive, as well as synchronously through an inbox that can be polled.
By default, messages are received synchronously on the thread that the endpoint was created on. If the message consumer is thread-safe, a more efficient message dispatch can be enabled by calling the SetRecipientThread() method with ENamedThreads::AnyThread.
Endpoints that are destroyed or receive messages on non-Game threads should use the static function FMessageEndpoint::SafeRelease() to dispose of the endpoint. This will ensure that there are no race conditions between endpoint destruction and the receiving of messages.
The underlying message bus will take ownership of all sent and published message objects. The memory held by the messages must therefore NOT be freed by the caller.
Constructors
Type | Name | Description | |
---|---|---|---|
![]() |
FMessageEndpoint
(
const FName& InName, |
Creates and initializes a new instance. |
Destructors
Type | Name | Description | |
---|---|---|---|
![]() |
Destructor. |
Functions
Type | Name | Description | |
---|---|---|---|
![]() |
void | Clears all handlers in a way that guarantees it won't overlap with message processing. | |
![]() |
void | Defer
(
const TSharedRef< IMessageContext, ESPMode::ThreadSafe >& Context, |
Defers processing of the given message by the specified time delay. |
![]() |
void | Disable () |
Disables this endpoint. |
![]() |
void | DisableInbox () |
Disables the inbox for unhandled messages.The inbox is disabled by default. |
![]() |
void | Enable () |
Enables this endpoint. |
![]() |
void | EnableInbox () |
Enables the inbox for unhandled messages. |
![]() |
void | Forward
(
const TSharedRef< IMessageContext, ESPMode::ThreadSafe >& Context, |
Forwards a previously received message. |
![]() |
void | Forward
(
const TSharedRef< IMessageContext, ESPMode::ThreadSafe >& Context, |
Forwards a previously received message to the specified recipient after a given delay. |
![]() |
void | Forward
(
const TSharedRef< IMessageContext, ESPMode::ThreadSafe >& Context, |
Immediately forwards a previously received message to the specified recipient. |
![]() |
void | Forward
(
const TSharedRef< IMessageContext, ESPMode::ThreadSafe >& Context, |
Immediately forwards a previously received message to the specified list of recipients. |
![]() ![]() |
const FMessageAddress & | GetAddress () |
Gets the endpoint's message address. |
![]() ![]() |
TSharedPtr< IMessageBus, ESPMode::ThreadSafe > | Gets a shared pointer to the message bus if this endpoint is enabled. | |
![]() ![]() |
bool | IsConnected () |
Checks whether this endpoint is connected to the bus. |
![]() ![]() |
bool | IsEnabled () |
Checks whether this endpoint is enabled. |
![]() ![]() |
bool | IsInboxEmpty () |
Checks whether the inbox is empty. |
![]() ![]() |
bool | Checks whether the inbox is enabled. | |
![]() ![]() |
T * | MakeMessage
(
InArgTypes&&... Args |
Creates a message of the specified template type. |
![]() |
void | ProcessInbox () |
Calls the matching message handlers for all messages queued up in the inbox. |
![]() |
void | ProcessMessage
(
const TSharedRef< IMessageContext, ESPMode::ThreadSafe >& Context |
Forwards the given message context to matching message handlers. |
![]() |
void | Publishes a message to all subscribed recipients within the specified scope. | |
![]() |
void | Publishes a message to all subscribed recipients within the specified scope. | |
![]() |
void |
Publish
(
void* Message, |
Publishes a message to all subscribed recipients within the specified scope. |
![]() |
void | Publishes a message to all subscribed recipients within the specified scope. | |
![]() |
void | Immediately pa message to all subscribed recipients within the specified scope. | |
![]() |
void | Publishes a message to all subscribed recipients within the specified scope after a given delay. | |
![]() |
void | Publishes a message to all subscribed recipients after a given delay. | |
![]() |
void |
Publish
(
MessageType* Message |
Immediately publishes a message to all subscribed recipients. |
![]() |
void |
Publish
(
MessageType* Message, |
Immediately pa message to all subscribed recipients within the specified scope. |
![]() |
void | Immediately publishes a message to all subscribed recipients. | |
![]() |
bool | ReceiveFromInbox
(
TSharedPtr< IMessageContext, ESPMode::ThreadSafe >& OutContext |
Receives a single message from the endpoint's inbox. |
![]() ![]() |
void | SafeRelease
(
TSharedPtr< FMessageEndpoint, ESPMode::ThreadSafe >& Endpoint |
Safely releases a message endpoint that is receiving messages on AnyThread. |
![]() |
void | Send
(
void* Message, |
Sends a message to the specified list of recipients. |
![]() |
void | Send
(
MessageType* Message, |
Sends a message to the specified list of recipients. Allows to specify message flags |
![]() |
void | Send
(
void* Message, |
Sends a message to the specified list of recipients. Allows to specify message flags |
![]() |
void | Send
(
MessageType* Message, |
Sends a message to the specified list of recipients. Allows to specify message flags |
![]() |
void | Send
(
MessageType* Message, |
Sends a message with fields, attachment and expiration to the specified recipient after a given delay. |
![]() |
void | Send
(
MessageType* Message, |
Sends a message to the specified list of recipients. |
![]() |
void | Send
(
MessageType* Message, |
Sends a message with fields and attachment to the specified list of recipients after a given delay. |
![]() |
void | Send
(
MessageType* Message, |
Sends a message with fields, attachment and expiration to the specified recipient after a given delay. |
![]() |
void | Send
(
MessageType* Message, |
Sends a message to the specified list of recipients after a given delay after a given delay. |
![]() |
void | Send
(
MessageType* Message, |
Sends a message with fields and attachment to the specified recipient. |
![]() |
void | Send
(
MessageType* Message, |
Sends a message to the specified recipient after a given delay. |
![]() |
void | Send
(
MessageType* Message, |
Immediately sends a message to the specified recipient. |
![]() |
void | Send
(
MessageType* Message, |
Immediately sends a message to the specified list of recipients. |
![]() |
void | Send
(
MessageType* Message, |
Immediately sends a message to the specified recipient. |
![]() |
void | Send
(
MessageType* Message, |
Sends a message with fields and expiration to the specified recipient after a given delay. |
![]() |
void | SetRecipientThread
(
const ENamedThreads::Type& NamedThread |
Sets the name of the thread to receive messages on. |
![]() |
void | Subscribe () |
Template method to subscribe the message endpoint to the specified type of messages with the default message scope. |
![]() |
void | Subscribe
(
const FMessageScopeRange& ScopeRange |
Template method to subscribe the message endpoint to the specified type and scope of messages. |
![]() |
void | Subscribe
(
const FTopLevelAssetPath& MessageType, |
Subscribes a message handler. |
![]() |
void | Unsubscribe () |
Unsubscribes this endpoint from all message types. |
![]() |
void | Unsubscribe () |
Template method to unsubscribe the endpoint from the specified message type. |
![]() |
void | Unsubscribe
(
const FTopLevelAssetPath& MessageType |
Unsubscribes this endpoint from the specified message type. |
Overridden from IMessageReceiver
Type | Name | Description | |
---|---|---|---|
![]() ![]() ![]() |
FName | GetDebugName () |
Gets the recipient's name (for debugging purposes). |
![]() ![]() ![]() |
const FGuid & | Gets the recipient's unique identifier (for debugging purposes). | |
![]() ![]() ![]() |
ENamedThreads::Type | Gets the name of the thread on which to receive messages. | |
![]() ![]() ![]() |
bool | IsLocal () |
Checks whether this recipient represents a local endpoint. |
![]() ![]() |
void | ReceiveMessage
(
const TSharedRef< IMessageContext, ESPMode::ThreadSafe >& Context |
Handles the given message. |
Overridden from IMessageSender
Type | Name | Description | |
---|---|---|---|
![]() ![]() |
FMessageAddress | Gets the sender's address. | |
![]() ![]() |
void | NotifyMessageError
(
const TSharedRef< IMessageContext, ESPMode::ThreadSafe >& Context, |
Notifies the sender of errors. |
Overridden from IBusListener
Type | Name | Description | |
---|---|---|---|
![]() ![]() ![]() |
ENamedThreads::Type | Gets the name of the thread on which to receive notifications. | |
![]() ![]() |
void | NotifyRegistration
(
const FMessageAddress& Address, |
Notify a registration event from the bus This is called when a receiver is registered or unregistered from the bus. |
Typedefs
Name | Description |
---|---|
Builder | Type definition for the endpoint builder. |
Deprecated Functions
Type | Name | Description | |
---|---|---|---|
![]() |
void | Send
(
void* Message, |
FMessageEndpoint::Send with 6 params is deprecated. Please use FMessageEndpoint::Send that takes additionnal EMessageFlags instead! |
![]() |
void | Types names are now represented by path names. Please use a version of this function that takes an FTopLevelAssetPath as MessageType. | |
![]() |
void | Unsubscribe
(
const FName& MessageType |
Types names are now represented by path names. Please use a version of this function that takes an FTopLevelAssetPath as MessageType. |