UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
FMessageEndpoint Class Reference

#include <MessageEndpoint.h>

+ Inheritance diagram for FMessageEndpoint:

Public Types

typedef struct FMessageEndpointBuilder Builder
 

Public Member Functions

 FMessageEndpoint (const FName &InName, const TSharedRef< IMessageBus, ESPMode::ThreadSafe > &InBus, const TArray< TSharedPtr< IMessageHandler, ESPMode::ThreadSafe > > &InHandlers, const FOnBusNotification InNotificationDelegate)
 
 ~FMessageEndpoint ()
 
void Disable ()
 
void Enable ()
 
const FMessageAddressGetAddress () const
 
bool IsConnected () const
 
bool IsEnabled () const
 
void SetRecipientThread (const ENamedThreads::Type &NamedThread)
 
void Defer (const TSharedRef< IMessageContext, ESPMode::ThreadSafe > &Context, const FTimespan &Delay)
 
void Forward (const TSharedRef< IMessageContext, ESPMode::ThreadSafe > &Context, const TArray< FMessageAddress > &Recipients, const FTimespan &Delay)
 
void Publish (void *Message, UScriptStruct *TypeInfo, EMessageScope Scope, const FTimespan &Delay, const FDateTime &Expiration)
 
void Publish (void *Message, UScriptStruct *TypeInfo, EMessageScope Scope, const TMap< FName, FString > Annotations, const FTimespan &Delay, const FDateTime &Expiration)
 
void Send (void *Message, UScriptStruct *TypeInfo, const TSharedPtr< IMessageAttachment, ESPMode::ThreadSafe > &Attachment, const TArray< FMessageAddress > &Recipients, const FTimespan &Delay, const FDateTime &Expiration)
 
void Send (void *Message, UScriptStruct *TypeInfo, EMessageFlags Flags, const TSharedPtr< IMessageAttachment, ESPMode::ThreadSafe > &Attachment, const TArray< FMessageAddress > &Recipients, const FTimespan &Delay, const FDateTime &Expiration)
 
void Send (void *Message, UScriptStruct *TypeInfo, EMessageFlags Flags, const TMap< FName, FString > Annotations, const TSharedPtr< IMessageAttachment, ESPMode::ThreadSafe > &Attachment, const TArray< FMessageAddress > &Recipients, const FTimespan &Delay, const FDateTime &Expiration)
 
void Subscribe (const FName &MessageType, const FMessageScopeRange &ScopeRange)
 
void Subscribe (const FTopLevelAssetPath &MessageType, const FMessageScopeRange &ScopeRange)
 
void Unsubscribe (const FName &MessageType)
 
void Unsubscribe (const FTopLevelAssetPath &MessageType)
 
void DisableInbox ()
 
void EnableInbox ()
 
bool IsInboxEmpty () const
 
bool IsInboxEnabled () const
 
void ProcessInbox ()
 
bool ReceiveFromInbox (TSharedPtr< IMessageContext, ESPMode::ThreadSafe > &OutContext)
 
virtual FName GetDebugName () const override
 
virtual const FGuidGetRecipientId () const override
 
virtual ENamedThreads::Type GetRecipientThread () const override
 
virtual bool IsLocal () const override
 
virtual void ReceiveMessage (const TSharedRef< IMessageContext, ESPMode::ThreadSafe > &Context) override
 
virtual ENamedThreads::Type GetListenerThread () const override
 
virtual void NotifyRegistration (const FMessageAddress &InAddress, EMessageBusNotification InNotification)
 
virtual FMessageAddress GetSenderAddress () override
 
virtual void NotifyMessageError (const TSharedRef< IMessageContext, ESPMode::ThreadSafe > &Context, const FString &Error) override
 
void Forward (const TSharedRef< IMessageContext, ESPMode::ThreadSafe > &Context, const FMessageAddress &Recipient)
 
void Forward (const TSharedRef< IMessageContext, ESPMode::ThreadSafe > &Context, const FMessageAddress &Recipient, const FTimespan &Delay)
 
void Forward (const TSharedRef< IMessageContext, ESPMode::ThreadSafe > &Context, const TArray< FMessageAddress > &Recipients)
 
template<typename MessageType >
void Publish (MessageType *Message)
 
template<typename MessageType >
void Publish (MessageType *Message, EMessageScope Scope)
 
template<typename MessageType >
void Publish (MessageType *Message, const TMap< FName, FString > Annotations)
 
template<typename MessageType >
void Publish (MessageType *Message, const TMap< FName, FString > Annotations, EMessageScope Scope)
 
template<typename MessageType >
void Publish (MessageType *Message, const FTimespan &Delay)
 
template<typename MessageType >
void Publish (MessageType *Message, EMessageScope Scope, const FTimespan &Delay)
 
template<typename MessageType >
void Publish (MessageType *Message, EMessageScope Scope, const FTimespan &Delay, const FDateTime &Expiration)
 
template<typename MessageType >
void Publish (MessageType *Message, const TMap< FName, FString > Annotations, EMessageScope Scope, const FTimespan &Delay, const FDateTime &Expiration)
 
template<typename MessageType >
void Send (MessageType *Message, const FMessageAddress &Recipient)
 
template<typename MessageType >
void Send (MessageType *Message, const TMap< FName, FString > Annotations, const FMessageAddress &Recipient)
 
template<typename MessageType >
void Send (MessageType *Message, const FMessageAddress &Recipient, const FTimespan &Delay)
 
template<typename MessageType >
void Send (MessageType *Message, const FMessageAddress &Recipient, const FTimespan &Delay, const FDateTime &Expiration)
 
template<typename MessageType >
void Send (MessageType *Message, const TSharedPtr< IMessageAttachment, ESPMode::ThreadSafe > &Attachment, const FMessageAddress &Recipient)
 
template<typename MessageType >
void Send (MessageType *Message, const TSharedPtr< IMessageAttachment, ESPMode::ThreadSafe > &Attachment, const FMessageAddress &Recipient, const FDateTime &Expiration, const FTimespan &Delay)
 
template<typename MessageType >
void Send (MessageType *Message, const TMap< FName, FString > Annotations, const TSharedPtr< IMessageAttachment, ESPMode::ThreadSafe > &Attachment, const FMessageAddress &Recipient, const FDateTime &Expiration, const FTimespan &Delay)
 
template<typename MessageType >
void Send (MessageType *Message, const TArray< FMessageAddress > &Recipients)
 
template<typename MessageType >
void Send (MessageType *Message, const TArray< FMessageAddress > &Recipients, const FTimespan &Delay)
 
template<typename MessageType >
void Send (MessageType *Message, const TSharedPtr< IMessageAttachment, ESPMode::ThreadSafe > &Attachment, const TArray< FMessageAddress > &Recipients, const FTimespan &Delay)
 
template<typename MessageType >
void Send (MessageType *Message, const TSharedPtr< IMessageAttachment, ESPMode::ThreadSafe > &Attachment, const TArray< FMessageAddress > &Recipients, const FTimespan &Delay, const FDateTime &Expiration)
 
template<typename MessageType >
void Send (MessageType *Message, EMessageFlags Flags, const TSharedPtr< IMessageAttachment, ESPMode::ThreadSafe > &Attachment, const TArray< FMessageAddress > &Recipients, const FTimespan &Delay, const FDateTime &Expiration)
 
template<typename MessageType >
void Send (MessageType *Message, EMessageFlags Flags, const TMap< FName, FString > Annotations, const TSharedPtr< IMessageAttachment, ESPMode::ThreadSafe > &Attachment, const TArray< FMessageAddress > &Recipients, const FTimespan &Delay, const FDateTime &Expiration)
 
template<class MessageType >
void Subscribe ()
 
template<class MessageType >
void Subscribe (const FMessageScopeRange &ScopeRange)
 
void Unsubscribe ()
 
template<class MessageType >
void Unsubscribe ()
 
- Public Member Functions inherited from TSharedFromThis< FMessageEndpoint, ESPMode::ThreadSafe >
TSharedRef< FMessageEndpoint, Mode > AsShared ()
 
TSharedRef< FMessageEndpoint const, Mode > AsShared () const
 
TSharedRef< SubobjectType, Mode > AsSharedSubobject (SubobjectType *SubobjectPtr) const
 
TWeakPtr< FMessageEndpoint, Mode > AsWeak ()
 
TWeakPtr< FMessageEndpoint const, Mode > AsWeak () const
 
TWeakPtr< SubobjectType, Mode > AsWeakSubobject (SubobjectType *SubobjectPtr) const
 
void UpdateWeakReferenceInternal (TSharedPtr< SharedPtrType, SharedPtrMode > const *InSharedPtr, OtherType *InObject) const
 
void UpdateWeakReferenceInternal (TSharedRef< SharedRefType, SharedPtrMode > const *InSharedRef, OtherType *InObject) const
 
UE_FORCEINLINE_HINT bool DoesSharedInstanceExist () const
 
- Public Member Functions inherited from IMessageReceiver
bool IsRemote () const
 
virtual ~IMessageReceiver ()
 
- Public Member Functions inherited from IMessageSender
virtual ~IMessageSender ()
 
- Public Member Functions inherited from IBusListener
virtual ~IBusListener ()
 

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::ThreadSafeGetBusIfEnabled () 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 TSharedFromThisoperator= (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)
 

Detailed Description

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.

Member Typedef Documentation

◆ Builder

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.

See also
SafeRelease

Constructor & Destructor Documentation

◆ FMessageEndpoint()

FMessageEndpoint::FMessageEndpoint ( const FName InName,
const TSharedRef< IMessageBus, ESPMode::ThreadSafe > &  InBus,
const TArray< TSharedPtr< IMessageHandler, ESPMode::ThreadSafe > > &  InHandlers,
const FOnBusNotification  InNotificationDelegate 
)
inline

Creates and initializes a new instance.

Parameters
InNameThe endpoint's name (for debugging purposes).
InBusThe message bus to attach this endpoint to.
InHandlersThe collection of message handlers to register.

◆ ~FMessageEndpoint()

FMessageEndpoint::~FMessageEndpoint ( )
inline

Destructor.

Member Function Documentation

◆ ClearHandlers()

void FMessageEndpoint::ClearHandlers ( )
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.

◆ Defer()

void FMessageEndpoint::Defer ( const TSharedRef< IMessageContext, ESPMode::ThreadSafe > &  Context,
const FTimespan Delay 
)
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.

Parameters
ContextThe context of the message to defer.
DelayThe time delay.

◆ Disable()

void FMessageEndpoint::Disable ( )
inline

Disables this endpoint.

A disabled endpoint will not receive any subscribed messages until it is enabled again. Endpoints should be created in an enabled state by default.

See also
Enable, IsEnabled

◆ DisableInbox()

void FMessageEndpoint::DisableInbox ( )
inline

Disables the inbox for unhandled messages.

The inbox is disabled by default.

See also
EnableInbox, IsInboxEmpty, IsInboxEnabled, ProcessInbox, ReceiveFromInbox

◆ Enable()

void FMessageEndpoint::Enable ( )
inline

Enables this endpoint.

An activated endpoint will receive subscribed messages. Endpoints should be created in an enabled state by default.

See also
Disable, IsEnabled

◆ EnableInbox()

void FMessageEndpoint::EnableInbox ( )
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.

See also
DisableInbox, IsInboxEmpty, IsInboxEnabled, ProcessInbox, ReceiveFromInbox

◆ Forward() [1/4]

void FMessageEndpoint::Forward ( const TSharedRef< IMessageContext, ESPMode::ThreadSafe > &  Context,
const FMessageAddress Recipient 
)
inline

Immediately forwards a previously received message to the specified recipient.

Messages can only be forwarded to endpoints within the same process.

Parameters
ContextThe context of the message to forward.
RecipientThe address of the recipient to forward the message to.

◆ Forward() [2/4]

void FMessageEndpoint::Forward ( const TSharedRef< IMessageContext, ESPMode::ThreadSafe > &  Context,
const FMessageAddress Recipient,
const FTimespan Delay 
)
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.

Parameters
ContextThe context of the message to forward.
RecipientThe address of the recipient to forward the message to.
ForwardingScopeThe scope of the forwarded message.
DelayThe delay after which to publish the message.

◆ Forward() [3/4]

void FMessageEndpoint::Forward ( const TSharedRef< IMessageContext, ESPMode::ThreadSafe > &  Context,
const TArray< FMessageAddress > &  Recipients 
)
inline

Immediately forwards a previously received message to the specified list of recipients.

Messages can only be forwarded to endpoints within the same process.

Parameters
ContextThe context of the message to forward.
RecipientsThe list of message recipients to forward the message to.
ForwardingScopeThe scope of the forwarded message.

◆ Forward() [4/4]

void FMessageEndpoint::Forward ( const TSharedRef< IMessageContext, ESPMode::ThreadSafe > &  Context,
const TArray< FMessageAddress > &  Recipients,
const FTimespan Delay 
)
inline

Forwards a previously received message.

Messages can only be forwarded to endpoints within the same process.

Parameters
ContextThe context of the message to forward.
RecipientsThe list of message recipients to forward the message to.
DelayThe time delay.

◆ GetAddress()

const FMessageAddress & FMessageEndpoint::GetAddress ( ) const
inline

Gets the endpoint's message address.

Returns
Message address.

◆ GetBusIfEnabled()

TSharedPtr< IMessageBus, ESPMode::ThreadSafe > FMessageEndpoint::GetBusIfEnabled ( ) const
inlineprotected

Gets a shared pointer to the message bus if this endpoint is enabled.

Returns
The message bus.

◆ GetDebugName()

virtual FName FMessageEndpoint::GetDebugName ( ) const
inlineoverridevirtual

Gets the recipient's name (for debugging purposes).

Returns
The debug name.
See also
GetRecipientId, GetRecipientThread

Implements IMessageReceiver.

◆ GetListenerThread()

virtual ENamedThreads::Type FMessageEndpoint::GetListenerThread ( ) const
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.

Returns
Name of the listener thread.

Implements IBusListener.

◆ GetRecipientId()

virtual const FGuid & FMessageEndpoint::GetRecipientId ( ) const
inlineoverridevirtual

Gets the recipient's unique identifier (for debugging purposes).

Returns
The recipient's identifier.
See also
GetDebugName, GetRecipientThread

Implements IMessageReceiver.

◆ GetRecipientThread()

virtual ENamedThreads::Type FMessageEndpoint::GetRecipientThread ( ) const
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.

Returns
Name of the receiving thread.
See also
GetDebugName, GetRecipientId

Implements IMessageReceiver.

◆ GetSenderAddress()

virtual FMessageAddress FMessageEndpoint::GetSenderAddress ( )
inlineoverridevirtual

Gets the sender's address.

Returns
The message address.

Implements IMessageSender.

◆ IsConnected()

bool FMessageEndpoint::IsConnected ( ) const
inline

Checks whether this endpoint is connected to the bus.

Returns
true if connected, false otherwise.
See also
IsEnabled

◆ IsEnabled()

bool FMessageEndpoint::IsEnabled ( ) const
inline

Checks whether this endpoint is enabled.

Returns
true if the endpoint is enabled, false otherwise.
See also
Disable, Enable, IsConnected

◆ IsInboxEmpty()

bool FMessageEndpoint::IsInboxEmpty ( ) const
inline

Checks whether the inbox is empty.

Returns
true if the inbox is empty, false otherwise.
See also
DisableInbox, EnableInbox, IsInboxEnabled, ProcessInbox, ReceiveFromInbox

◆ IsInboxEnabled()

bool FMessageEndpoint::IsInboxEnabled ( ) const
inline

Checks whether the inbox is enabled.

See also
DisableInbox, EnableInbox, IsInboxEmpty, ProcessInbox, ReceiveFromInbox

◆ IsLocal()

virtual bool FMessageEndpoint::IsLocal ( ) const
inlineoverridevirtual

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.

Returns
true if this recipient is local, false otherwise.
See also
IsRemote

Implements IMessageReceiver.

◆ MakeMessage()

template<typename T , typename... InArgTypes>
static T * FMessageEndpoint::MakeMessage ( InArgTypes &&...  Args)
inlinestatic

Creates a message of the specified template type.

Prefer using this helper rather than explicit new. See FEngineServicePong.

Parameters
ArgsThe constructor arguments to the template type

◆ NotifyMessageError()

virtual void FMessageEndpoint::NotifyMessageError ( const TSharedRef< IMessageContext, ESPMode::ThreadSafe > &  Context,
const FString &  Error 
)
inlineoverridevirtual

Notifies the sender of errors.

Parameters
ContextThe context of the message that generated the error.
ErrorThe error string.

Implements IMessageSender.

◆ NotifyRegistration()

virtual void FMessageEndpoint::NotifyRegistration ( const FMessageAddress Address,
EMessageBusNotification  Notification 
)
inlinevirtual

Notify a registration event from the bus This is called when a receiver is registered or unregistered from the bus.

Parameters
AddressThe address of the recipient that just un/registered from the bus.
NotificationThe even type, either Registered or Unregistered

Implements IBusListener.

◆ ProcessInbox()

void FMessageEndpoint::ProcessInbox ( )
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.

See also
IsInboxEmpty, ReceiveFromInbox

◆ ProcessMessage()

void FMessageEndpoint::ProcessMessage ( const TSharedRef< IMessageContext, ESPMode::ThreadSafe > &  Context)
inlineprotected

Forwards the given message context to matching message handlers.

Parameters
ContextThe context of the message to handle.

◆ Publish() [1/10]

template<typename MessageType >
void FMessageEndpoint::Publish ( MessageType *  Message)
inline

Immediately publishes a message to all subscribed recipients.

Parameters
MessageThe message to publish.

◆ Publish() [2/10]

template<typename MessageType >
void FMessageEndpoint::Publish ( MessageType *  Message,
const FTimespan Delay 
)
inline

Publishes a message to all subscribed recipients after a given delay.

Parameters
MessageThe message to publish.
DelayThe delay after which to publish the message.

◆ Publish() [3/10]

template<typename MessageType >
void FMessageEndpoint::Publish ( MessageType *  Message,
const TMap< FName, FString >  Annotations 
)
inline

Immediately publishes a message to all subscribed recipients.

Parameters
MessageThe message to publish.
AnnotationsAn optional message annotations header.

◆ Publish() [4/10]

template<typename MessageType >
void FMessageEndpoint::Publish ( MessageType *  Message,
const TMap< FName, FString >  Annotations,
EMessageScope  Scope 
)
inline

Immediately pa message to all subscribed recipients within the specified scope.

Parameters
MessageThe message to publish.
AnnotationsAn optional message annotations header.
ScopeThe message scope.

◆ Publish() [5/10]

template<typename MessageType >
void FMessageEndpoint::Publish ( MessageType *  Message,
const TMap< FName, FString >  Annotations,
EMessageScope  Scope,
const FTimespan Delay,
const FDateTime Expiration 
)
inline

Publishes a message to all subscribed recipients within the specified scope.

Parameters
MessageThe message to publish.
AnnotationsAn optional message annotations header.
ScopeThe message scope.
FieldsThe message content.
DelayThe delay after which to publish the message.
ExpirationThe time at which the message expires.

◆ Publish() [6/10]

template<typename MessageType >
void FMessageEndpoint::Publish ( MessageType *  Message,
EMessageScope  Scope 
)
inline

Immediately pa message to all subscribed recipients within the specified scope.

Parameters
MessageThe message to publish.
ScopeThe message scope.

◆ Publish() [7/10]

template<typename MessageType >
void FMessageEndpoint::Publish ( MessageType *  Message,
EMessageScope  Scope,
const FTimespan Delay 
)
inline

Publishes a message to all subscribed recipients within the specified scope after a given delay.

Parameters
MessageThe message to publish.
ScopeThe message scope.
DelayThe delay after which to publish the message.

◆ Publish() [8/10]

template<typename MessageType >
void FMessageEndpoint::Publish ( MessageType *  Message,
EMessageScope  Scope,
const FTimespan Delay,
const FDateTime Expiration 
)
inline

Publishes a message to all subscribed recipients within the specified scope.

Parameters
MessageThe message to publish.
ScopeThe message scope.
FieldsThe message content.
DelayThe delay after which to publish the message.
ExpirationThe time at which the message expires.

◆ Publish() [9/10]

void FMessageEndpoint::Publish ( void Message,
UScriptStruct TypeInfo,
EMessageScope  Scope,
const FTimespan Delay,
const FDateTime Expiration 
)
inline

Publishes a message to all subscribed recipients within the specified scope.

Parameters
MessageThe message to publish.
TypeInfoThe message's type information.
ScopeThe message scope.
FieldsThe message content.
DelayThe delay after which to publish the message.
ExpirationThe time at which the message expires.

◆ Publish() [10/10]

void FMessageEndpoint::Publish ( void Message,
UScriptStruct TypeInfo,
EMessageScope  Scope,
const TMap< FName, FString >  Annotations,
const FTimespan Delay,
const FDateTime Expiration 
)
inline

Publishes a message to all subscribed recipients within the specified scope.

Parameters
MessageThe message to publish.
TypeInfoThe message's type information.
ScopeThe message scope.
AnnotationsAn optional message annotations header.
FieldsThe message content.
DelayThe delay after which to publish the message.
ExpirationThe time at which the message expires.

◆ ReceiveFromInbox()

bool FMessageEndpoint::ReceiveFromInbox ( TSharedPtr< IMessageContext, ESPMode::ThreadSafe > &  OutContext)
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.

Parameters
OutContextWill hold the context of the received message.
Returns
true if a message was received, false if the inbox was empty.
See also
DisableInbox, EnableInbox, IsInboxEnabled, ProcessInbox

◆ ReceiveMessage()

virtual void FMessageEndpoint::ReceiveMessage ( const TSharedRef< IMessageContext, ESPMode::ThreadSafe > &  Context)
inlineoverridevirtual

Handles the given message.

Parameters
ContextWill hold the context of the received message.

Implements IMessageReceiver.

◆ SafeRelease()

static void FMessageEndpoint::SafeRelease ( TSharedPtr< FMessageEndpoint, ESPMode::ThreadSafe > &  Endpoint)
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.

Parameters
EndpointThe message endpoint to release.

◆ Send() [1/16]

template<typename MessageType >
void FMessageEndpoint::Send ( MessageType *  Message,
const FMessageAddress Recipient 
)
inline

Immediately sends a message to the specified recipient.

Parameters
MessageTypeThe type of message to send.
MessageThe message to send.
RecipientThe message recipient.

◆ Send() [2/16]

template<typename MessageType >
void FMessageEndpoint::Send ( MessageType *  Message,
const FMessageAddress Recipient,
const FTimespan Delay 
)
inline

Sends a message to the specified recipient after a given delay.

Parameters
MessageTypeThe type of message to send.
MessageThe message to send.
RecipientThe message recipient.
DelayThe delay after which to send the message.

◆ Send() [3/16]

template<typename MessageType >
void FMessageEndpoint::Send ( MessageType *  Message,
const FMessageAddress Recipient,
const FTimespan Delay,
const FDateTime Expiration 
)
inline

Sends a message with fields and expiration to the specified recipient after a given delay.

Parameters
MessageTypeThe type of message to send.
MessageThe message to send.
RecipientThe message recipient.
ExpirationThe time at which the message expires.
DelayThe delay after which to send the message.

◆ Send() [4/16]

template<typename MessageType >
void FMessageEndpoint::Send ( MessageType *  Message,
const TArray< FMessageAddress > &  Recipients 
)
inline

Immediately sends a message to the specified list of recipients.

Parameters
MessageTypeThe type of message to send.
MessageThe message to send.
RecipientsThe message recipients.

◆ Send() [5/16]

template<typename MessageType >
void FMessageEndpoint::Send ( MessageType *  Message,
const TArray< FMessageAddress > &  Recipients,
const FTimespan Delay 
)
inline

Sends a message to the specified list of recipients after a given delay after a given delay.

Parameters
MessageTypeThe type of message to send.
MessageThe message to send.
RecipientsThe message recipients.
DelayThe delay after which to send the message.

◆ Send() [6/16]

template<typename MessageType >
void FMessageEndpoint::Send ( MessageType *  Message,
const TMap< FName, FString >  Annotations,
const FMessageAddress Recipient 
)
inline

Immediately sends a message to the specified recipient.

Parameters
MessageTypeThe type of message to send.
MessageThe message to send.
AnnotationsAn optional message annotations header.
RecipientThe message recipient.

◆ Send() [7/16]

template<typename MessageType >
void FMessageEndpoint::Send ( MessageType *  Message,
const TMap< FName, FString >  Annotations,
const TSharedPtr< IMessageAttachment, ESPMode::ThreadSafe > &  Attachment,
const FMessageAddress Recipient,
const FDateTime Expiration,
const FTimespan Delay 
)
inline

Sends a message with fields, attachment and expiration to the specified recipient after a given delay.

Parameters
MessageTypeThe type of message to send.
MessageThe message to send.
AnnotationsAn optional message annotations header.
AttachmentAn optional binary data attachment.
RecipientThe message recipient.
ExpirationThe time at which the message expires.
DelayThe delay after which to send the message.

◆ Send() [8/16]

template<typename MessageType >
void FMessageEndpoint::Send ( MessageType *  Message,
const TSharedPtr< IMessageAttachment, ESPMode::ThreadSafe > &  Attachment,
const FMessageAddress Recipient 
)
inline

Sends a message with fields and attachment to the specified recipient.

Parameters
MessageTypeThe type of message to send.
MessageThe message to send.
AttachmentAn optional binary data attachment.
RecipientThe message recipient.

◆ Send() [9/16]

template<typename MessageType >
void FMessageEndpoint::Send ( MessageType *  Message,
const TSharedPtr< IMessageAttachment, ESPMode::ThreadSafe > &  Attachment,
const FMessageAddress Recipient,
const FDateTime Expiration,
const FTimespan Delay 
)
inline

Sends a message with fields, attachment and expiration to the specified recipient after a given delay.

Parameters
MessageTypeThe type of message to send.
MessageThe message to send.
AttachmentAn optional binary data attachment.
RecipientThe message recipient.
ExpirationThe time at which the message expires.
DelayThe delay after which to send the message.

◆ Send() [10/16]

template<typename MessageType >
void FMessageEndpoint::Send ( MessageType *  Message,
const TSharedPtr< IMessageAttachment, ESPMode::ThreadSafe > &  Attachment,
const TArray< FMessageAddress > &  Recipients,
const FTimespan Delay 
)
inline

Sends a message with fields and attachment to the specified list of recipients after a given delay.

Parameters
MessageTypeThe type of message to send.
MessageThe message to send.
AttachmentAn optional binary data attachment.
RecipientsThe message recipients.
DelayThe delay after which to send the message.

◆ Send() [11/16]

template<typename MessageType >
void FMessageEndpoint::Send ( MessageType *  Message,
const TSharedPtr< IMessageAttachment, ESPMode::ThreadSafe > &  Attachment,
const TArray< FMessageAddress > &  Recipients,
const FTimespan Delay,
const FDateTime Expiration 
)
inline

Sends a message to the specified list of recipients.

Parameters
MessageTypeThe type of message to send.
MessageThe message to send.
AttachmentAn optional binary data attachment.
RecipientsThe message recipients.
DelayThe delay after which to send the message.
ExpirationThe time at which the message expires.

◆ Send() [12/16]

template<typename MessageType >
void FMessageEndpoint::Send ( MessageType *  Message,
EMessageFlags  Flags,
const TMap< FName, FString >  Annotations,
const TSharedPtr< IMessageAttachment, ESPMode::ThreadSafe > &  Attachment,
const TArray< FMessageAddress > &  Recipients,
const FTimespan Delay,
const FDateTime Expiration 
)
inline

Sends a message to the specified list of recipients. Allows to specify message flags

Parameters
MessageThe message to send.
TypeInfoThe message's type information.
FlagsThe message's type information.
AnnotationsAn optional message annotations header.
AttachmentAn optional binary data attachment.
RecipientsThe message recipients.
DelayThe delay after which to send the message.
ExpirationThe time at which the message expires.

◆ Send() [13/16]

template<typename MessageType >
void FMessageEndpoint::Send ( MessageType *  Message,
EMessageFlags  Flags,
const TSharedPtr< IMessageAttachment, ESPMode::ThreadSafe > &  Attachment,
const TArray< FMessageAddress > &  Recipients,
const FTimespan Delay,
const FDateTime Expiration 
)
inline

Sends a message to the specified list of recipients. Allows to specify message flags

Parameters
MessageThe message to send.
TypeInfoThe message's type information.
FlagsThe message's type information.
AttachmentAn optional binary data attachment.
RecipientsThe message recipients.
DelayThe delay after which to send the message.
ExpirationThe time at which the message expires.

◆ Send() [14/16]

void FMessageEndpoint::Send ( void Message,
UScriptStruct TypeInfo,
const TSharedPtr< IMessageAttachment, ESPMode::ThreadSafe > &  Attachment,
const TArray< FMessageAddress > &  Recipients,
const FTimespan Delay,
const FDateTime Expiration 
)
inline

Sends a message to the specified list of recipients.

Parameters
MessageThe message to send.
TypeInfoThe message's type information.
AttachmentAn optional binary data attachment.
RecipientsThe message recipients.
DelayThe delay after which to send the message.
ExpirationThe time at which the message expires.

◆ Send() [15/16]

void FMessageEndpoint::Send ( void Message,
UScriptStruct TypeInfo,
EMessageFlags  Flags,
const TMap< FName, FString >  Annotations,
const TSharedPtr< IMessageAttachment, ESPMode::ThreadSafe > &  Attachment,
const TArray< FMessageAddress > &  Recipients,
const FTimespan Delay,
const FDateTime Expiration 
)
inline

Sends a message to the specified list of recipients.

Parameters
MessageThe message to send.
TypeInfoThe message's type information.
FlagsThe message's type information.
AnnotationsAn optional message annotations header.
AttachmentAn optional binary data attachment.
RecipientsThe message recipients.
DelayThe delay after which to send the message.
ExpirationThe time at which the message expires.

◆ Send() [16/16]

void FMessageEndpoint::Send ( void Message,
UScriptStruct TypeInfo,
EMessageFlags  Flags,
const TSharedPtr< IMessageAttachment, ESPMode::ThreadSafe > &  Attachment,
const TArray< FMessageAddress > &  Recipients,
const FTimespan Delay,
const FDateTime Expiration 
)
inline

Sends a message to the specified list of recipients. Allows to specify message flags

Parameters
MessageThe message to send.
TypeInfoThe message's type information.
FlagsThe message's type information.
AttachmentAn optional binary data attachment.
RecipientsThe message recipients.
DelayThe delay after which to send the message.
ExpirationThe time at which the message expires.

◆ SetRecipientThread()

void FMessageEndpoint::SetRecipientThread ( const ENamedThreads::Type NamedThread)
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.

Parameters
NamedThreadThe name of the thread to receive messages on.

◆ Subscribe() [1/4]

template<class MessageType >
void FMessageEndpoint::Subscribe ( )
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.

Parameters
HandlerTypeThe type of the class handling the message.
MessageTypeThe type of messages to subscribe to.
HandlerThe class handling the messages.
HandlerFuncThe class function handling the messages.

◆ Subscribe() [2/4]

template<class MessageType >
void FMessageEndpoint::Subscribe ( const FMessageScopeRange ScopeRange)
inline

Template method to subscribe the message endpoint to the specified type and scope of messages.

Parameters
HandlerTypeThe type of the class handling the message.
MessageTypeThe type of messages to subscribe to.
HandlerThe class handling the messages.
HandlerFuncThe class function handling the messages.
ScopeRangeThe range of message scopes to include in the subscription.

◆ Subscribe() [3/4]

void FMessageEndpoint::Subscribe ( const FName MessageType,
const FMessageScopeRange ScopeRange 
)
inline

Subscribes a message handler.

Parameters
MessageTypeThe type name of the messages to subscribe to.
ScopeRangeThe range of message scopes to include in the subscription.

◆ Subscribe() [4/4]

void FMessageEndpoint::Subscribe ( const FTopLevelAssetPath MessageType,
const FMessageScopeRange ScopeRange 
)
inline

Subscribes a message handler.

Parameters
MessageTypeThe type name of the messages to subscribe to.
ScopeRangeThe range of message scopes to include in the subscription.

◆ Unsubscribe() [1/4]

void FMessageEndpoint::Unsubscribe ( )
inline

Unsubscribes this endpoint from all message types.

See also
Subscribe

◆ Unsubscribe() [2/4]

template<class MessageType >
void FMessageEndpoint::Unsubscribe ( )
inline

Template method to unsubscribe the endpoint from the specified message type.

Parameters
MessageTypeThe type of message to unsubscribe (IMessageBus::PATHNAME_All = all types).
See also
Subscribe

◆ Unsubscribe() [3/4]

void FMessageEndpoint::Unsubscribe ( const FName MessageType)
inline

Unsubscribes this endpoint from the specified message type.

Parameters
MessageTypeThe type of message to unsubscribe (IMessageBus::PATHNAME_All = all types).
See also
Subscribe

◆ Unsubscribe() [4/4]

void FMessageEndpoint::Unsubscribe ( const FTopLevelAssetPath MessageType)
inline

Unsubscribes this endpoint from the specified message type.

Parameters
MessageTypeThe type of message to unsubscribe (IMessageBus::PATHNAME_All = all types).
See also
Subscribe

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