![]() |
UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
|
#include <MessageEndpoint.h>
Inheritance diagram for FMessageEndpoint:Public Types | |
| typedef struct FMessageEndpointBuilder | Builder |
Static Public Member Functions | |
| template<typename T , typename... InArgTypes> | |
| static T * | MakeMessage (InArgTypes &&... Args) |
| static void | SafeRelease (TSharedPtr< FMessageEndpoint, ESPMode::ThreadSafe > &Endpoint) |
Protected Member Functions | |
| void | ClearHandlers () |
| TSharedPtr< IMessageBus, ESPMode::ThreadSafe > | GetBusIfEnabled () const |
| void | ProcessMessage (const TSharedRef< IMessageContext, ESPMode::ThreadSafe > &Context) |
Protected Member Functions inherited from TSharedFromThis< FMessageEndpoint, ESPMode::ThreadSafe > | |
| TSharedFromThis () | |
| TSharedFromThis (TSharedFromThis const &) | |
| UE_FORCEINLINE_HINT TSharedFromThis & | operator= (TSharedFromThis const &) |
| ~TSharedFromThis () | |
Additional Inherited Members | |
Static Protected Member Functions inherited from TSharedFromThis< FMessageEndpoint, ESPMode::ThreadSafe > | |
| static UE_FORCEINLINE_HINT TSharedRef< OtherType, Mode > | SharedThis (OtherType *ThisPtr) |
| static UE_FORCEINLINE_HINT TSharedRef< OtherType const, Mode > | SharedThis (const OtherType *ThisPtr) |
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.
Type definition for the endpoint builder.
When building message endpoints that receive messages on AnyThread, use the SafeRelease helper function to avoid race conditions when destroying the objects that own the endpoints.
|
inline |
Creates and initializes a new instance.
| InName | The endpoint's name (for debugging purposes). |
| InBus | The message bus to attach this endpoint to. |
| InHandlers | The collection of message handlers to register. |
|
inline |
Destructor.
|
inlineprotected |
Clears all handlers in a way that guarantees it won't overlap with message processing. This preserves internal integrity of the array and cases where our owner may be shutting down while receiving messages.
|
inline |
Defers processing of the given message by the specified time delay.
The message is effectively delivered again to this endpoint after the original sent time plus the time delay have elapsed.
| Context | The context of the message to defer. |
| Delay | The time delay. |
|
inline |
|
inline |
Disables the inbox for unhandled messages.
The inbox is disabled by default.
|
inline |
|
inline |
Enables the inbox for unhandled messages.
If enabled, the inbox will queue up all received messages. Use ProcessInbox() to synchronously invoke the registered message handlers for all queued up messages, or ReceiveFromInbox() to manually receive one message from the inbox at a time. The inbox is disabled by default.
|
inline |
Immediately forwards a previously received message to the specified recipient.
Messages can only be forwarded to endpoints within the same process.
| Context | The context of the message to forward. |
| Recipient | The address of the recipient to forward the message to. |
|
inline |
Forwards a previously received message to the specified recipient after a given delay.
Messages can only be forwarded to endpoints within the same process.
| Context | The context of the message to forward. |
| Recipient | The address of the recipient to forward the message to. |
| ForwardingScope | The scope of the forwarded message. |
| Delay | The delay after which to publish the message. |
|
inline |
Immediately forwards a previously received message to the specified list of recipients.
Messages can only be forwarded to endpoints within the same process.
| Context | The context of the message to forward. |
| Recipients | The list of message recipients to forward the message to. |
| ForwardingScope | The scope of the forwarded message. |
|
inline |
Forwards a previously received message.
Messages can only be forwarded to endpoints within the same process.
| Context | The context of the message to forward. |
| Recipients | The list of message recipients to forward the message to. |
| Delay | The time delay. |
|
inline |
Gets the endpoint's message address.
|
inlineprotected |
Gets a shared pointer to the message bus if this endpoint is enabled.
Gets the recipient's name (for debugging purposes).
Implements IMessageReceiver.
|
inlineoverridevirtual |
Gets the name of the thread on which to receive notifications.
If the listener's Notify[*] methods are thread-safe, return ThreadAny for best performance.
Implements IBusListener.
Gets the recipient's unique identifier (for debugging purposes).
Implements IMessageReceiver.
|
inlineoverridevirtual |
Gets the name of the thread on which to receive messages.
If the recipient's ReceiveMessage() is thread-safe, return ThreadAny for best performance.
Implements IMessageReceiver.
|
inlineoverridevirtual |
|
inline |
Checks whether this endpoint is connected to the bus.
|
inline |
Checks whether this endpoint is enabled.
|
inline |
Checks whether the inbox is empty.
|
inline |
Checks whether the inbox is enabled.
Checks whether this recipient represents a local endpoint.
Local recipients are located in the current thread or process. Recipients located in other processes on the same machine or on remote machines are considered remote.
Implements IMessageReceiver.
|
inlinestatic |
Creates a message of the specified template type.
Prefer using this helper rather than explicit new. See FEngineServicePong.
| Args | The constructor arguments to the template type |
|
inlineoverridevirtual |
Notifies the sender of errors.
| Context | The context of the message that generated the error. |
| Error | The error string. |
Implements IMessageSender.
|
inlinevirtual |
Notify a registration event from the bus This is called when a receiver is registered or unregistered from the bus.
| Address | The address of the recipient that just un/registered from the bus. |
| Notification | The even type, either Registered or Unregistered |
Implements IBusListener.
|
inline |
Calls the matching message handlers for all messages queued up in the inbox.
Note that an incoming message will only be queued up in the endpoint's inbox if the inbox has been enabled and no matching message handler handled it. The inbox is disabled by default and must be enabled using the EnableInbox() method.
|
inlineprotected |
Forwards the given message context to matching message handlers.
| Context | The context of the message to handle. |
Immediately publishes a message to all subscribed recipients.
| Message | The message to publish. |
|
inline |
Publishes a message to all subscribed recipients after a given delay.
| Message | The message to publish. |
| Delay | The delay after which to publish the message. |
|
inline |
Immediately publishes a message to all subscribed recipients.
| Message | The message to publish. |
| Annotations | An optional message annotations header. |
|
inline |
Immediately pa message to all subscribed recipients within the specified scope.
| Message | The message to publish. |
| Annotations | An optional message annotations header. |
| Scope | The message scope. |
|
inline |
Publishes a message to all subscribed recipients within the specified scope.
| Message | The message to publish. |
| Annotations | An optional message annotations header. |
| Scope | The message scope. |
| Fields | The message content. |
| Delay | The delay after which to publish the message. |
| Expiration | The time at which the message expires. |
|
inline |
Immediately pa message to all subscribed recipients within the specified scope.
| Message | The message to publish. |
| Scope | The message scope. |
|
inline |
Publishes a message to all subscribed recipients within the specified scope after a given delay.
| Message | The message to publish. |
| Scope | The message scope. |
| Delay | The delay after which to publish the message. |
|
inline |
Publishes a message to all subscribed recipients within the specified scope.
| Message | The message to publish. |
| Scope | The message scope. |
| Fields | The message content. |
| Delay | The delay after which to publish the message. |
| Expiration | The time at which the message expires. |
|
inline |
Publishes a message to all subscribed recipients within the specified scope.
| Message | The message to publish. |
| TypeInfo | The message's type information. |
| Scope | The message scope. |
| Fields | The message content. |
| Delay | The delay after which to publish the message. |
| Expiration | The time at which the message expires. |
|
inline |
Publishes a message to all subscribed recipients within the specified scope.
| Message | The message to publish. |
| TypeInfo | The message's type information. |
| Scope | The message scope. |
| Annotations | An optional message annotations header. |
| Fields | The message content. |
| Delay | The delay after which to publish the message. |
| Expiration | The time at which the message expires. |
|
inline |
Receives a single message from the endpoint's inbox.
Note that an incoming message will only be queued up in the endpoint's inbox if the inbox has been enabled and no matching message handler handled it. The inbox is disabled by default and must be enabled using the EnableInbox() method.
| OutContext | Will hold the context of the received message. |
|
inlineoverridevirtual |
Handles the given message.
| Context | Will hold the context of the received message. |
Implements IMessageReceiver.
|
inlinestatic |
Safely releases a message endpoint that is receiving messages on AnyThread.
When an object that owns a message endpoint receiving on AnyThread is being destroyed, it is possible that the endpoint can outlive the object for a brief period of time if the Messaging system is dispatching messages to it. This helper function is to block the calling thread while any messages are being dispatched, so that the endpoint does not invoke any message handlers after the object has been destroyed.
| Endpoint | The message endpoint to release. |
|
inline |
Immediately sends a message to the specified recipient.
| MessageType | The type of message to send. |
| Message | The message to send. |
| Recipient | The message recipient. |
|
inline |
Sends a message to the specified recipient after a given delay.
| MessageType | The type of message to send. |
| Message | The message to send. |
| Recipient | The message recipient. |
| Delay | The delay after which to send the message. |
|
inline |
Sends a message with fields and expiration to the specified recipient after a given delay.
| MessageType | The type of message to send. |
| Message | The message to send. |
| Recipient | The message recipient. |
| Expiration | The time at which the message expires. |
| Delay | The delay after which to send the message. |
|
inline |
Immediately sends a message to the specified list of recipients.
| MessageType | The type of message to send. |
| Message | The message to send. |
| Recipients | The message recipients. |
|
inline |
Sends a message to the specified list of recipients after a given delay after a given delay.
| MessageType | The type of message to send. |
| Message | The message to send. |
| Recipients | The message recipients. |
| Delay | The delay after which to send the message. |
|
inline |
Immediately sends a message to the specified recipient.
| MessageType | The type of message to send. |
| Message | The message to send. |
| Annotations | An optional message annotations header. |
| Recipient | The message recipient. |
|
inline |
Sends a message with fields, attachment and expiration to the specified recipient after a given delay.
| MessageType | The type of message to send. |
| Message | The message to send. |
| Annotations | An optional message annotations header. |
| Attachment | An optional binary data attachment. |
| Recipient | The message recipient. |
| Expiration | The time at which the message expires. |
| Delay | The delay after which to send the message. |
|
inline |
Sends a message with fields and attachment to the specified recipient.
| MessageType | The type of message to send. |
| Message | The message to send. |
| Attachment | An optional binary data attachment. |
| Recipient | The message recipient. |
|
inline |
Sends a message with fields, attachment and expiration to the specified recipient after a given delay.
| MessageType | The type of message to send. |
| Message | The message to send. |
| Attachment | An optional binary data attachment. |
| Recipient | The message recipient. |
| Expiration | The time at which the message expires. |
| Delay | The delay after which to send the message. |
|
inline |
Sends a message with fields and attachment to the specified list of recipients after a given delay.
| MessageType | The type of message to send. |
| Message | The message to send. |
| Attachment | An optional binary data attachment. |
| Recipients | The message recipients. |
| Delay | The delay after which to send the message. |
|
inline |
Sends a message to the specified list of recipients.
| MessageType | The type of message to send. |
| Message | The message to send. |
| Attachment | An optional binary data attachment. |
| Recipients | The message recipients. |
| Delay | The delay after which to send the message. |
| Expiration | The time at which the message expires. |
|
inline |
Sends a message to the specified list of recipients. Allows to specify message flags
| Message | The message to send. |
| TypeInfo | The message's type information. |
| Flags | The message's type information. |
| Annotations | An optional message annotations header. |
| Attachment | An optional binary data attachment. |
| Recipients | The message recipients. |
| Delay | The delay after which to send the message. |
| Expiration | The time at which the message expires. |
|
inline |
Sends a message to the specified list of recipients. Allows to specify message flags
| Message | The message to send. |
| TypeInfo | The message's type information. |
| Flags | The message's type information. |
| Attachment | An optional binary data attachment. |
| Recipients | The message recipients. |
| Delay | The delay after which to send the message. |
| Expiration | The time at which the message expires. |
|
inline |
Sends a message to the specified list of recipients.
| Message | The message to send. |
| TypeInfo | The message's type information. |
| Attachment | An optional binary data attachment. |
| Recipients | The message recipients. |
| Delay | The delay after which to send the message. |
| Expiration | The time at which the message expires. |
|
inline |
Sends a message to the specified list of recipients.
| Message | The message to send. |
| TypeInfo | The message's type information. |
| Flags | The message's type information. |
| Annotations | An optional message annotations header. |
| Attachment | An optional binary data attachment. |
| Recipients | The message recipients. |
| Delay | The delay after which to send the message. |
| Expiration | The time at which the message expires. |
|
inline |
Sends a message to the specified list of recipients. Allows to specify message flags
| Message | The message to send. |
| TypeInfo | The message's type information. |
| Flags | The message's type information. |
| Attachment | An optional binary data attachment. |
| Recipients | The message recipients. |
| Delay | The delay after which to send the message. |
| Expiration | The time at which the message expires. |
|
inline |
Sets the name of the thread to receive messages on.
Use this method to receive messages on a particular thread, for example, if the consumer owning this endpoint is not thread-safe. The default value is ThreadAny.
ThreadAny is the fastest way to receive messages. It should be used if the receiving code is completely thread-safe and if it is sufficiently fast. ThreadAny MUST NOT be used if the receiving code is not thread-safe. It also SHOULD NOT be used if the code includes time consuming operations, because it will block the message router, causing no other messages to be delivered in the meantime.
| NamedThread | The name of the thread to receive messages on. |
|
inline |
Template method to subscribe the message endpoint to the specified type of messages with the default message scope.
The default message scope is all messages excluding loopback messages.
| HandlerType | The type of the class handling the message. |
| MessageType | The type of messages to subscribe to. |
| Handler | The class handling the messages. |
| HandlerFunc | The class function handling the messages. |
|
inline |
Template method to subscribe the message endpoint to the specified type and scope of messages.
| HandlerType | The type of the class handling the message. |
| MessageType | The type of messages to subscribe to. |
| Handler | The class handling the messages. |
| HandlerFunc | The class function handling the messages. |
| ScopeRange | The range of message scopes to include in the subscription. |
|
inline |
Subscribes a message handler.
| MessageType | The type name of the messages to subscribe to. |
| ScopeRange | The range of message scopes to include in the subscription. |
|
inline |
Subscribes a message handler.
| MessageType | The type name of the messages to subscribe to. |
| ScopeRange | The range of message scopes to include in the subscription. |
|
inline |
Unsubscribes this endpoint from all message types.
|
inline |
Template method to unsubscribe the endpoint from the specified message type.
| MessageType | The type of message to unsubscribe (IMessageBus::PATHNAME_All = all types). |
Unsubscribes this endpoint from the specified message type.
| MessageType | The type of message to unsubscribe (IMessageBus::PATHNAME_All = all types). |
|
inline |
Unsubscribes this endpoint from the specified message type.
| MessageType | The type of message to unsubscribe (IMessageBus::PATHNAME_All = all types). |