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

#include <MessageBus.h>

+ Inheritance diagram for FMessageBus:

Public Member Functions

 FMessageBus (FString InName, const TSharedPtr< IAuthorizeMessageRecipients > &InRecipientAuthorizer)
 
virtual ~FMessageBus ()
 
virtual void Forward (const TSharedRef< IMessageContext, ESPMode::ThreadSafe > &Context, const TArray< FMessageAddress > &Recipients, const FTimespan &Delay, const TSharedRef< IMessageSender, ESPMode::ThreadSafe > &Forwarder) override
 
virtual TSharedRef< IMessageTracer, ESPMode::ThreadSafeGetTracer () override
 
virtual void Intercept (const TSharedRef< IMessageInterceptor, ESPMode::ThreadSafe > &Interceptor, const FTopLevelAssetPath &MessageType) override
 
virtual FOnMessageBusShutdownOnShutdown () override
 
virtual void Publish (void *Message, UScriptStruct *TypeInfo, EMessageScope Scope, const TMap< FName, FString > &Annotations, const FTimespan &Delay, const FDateTime &Expiration, const TSharedRef< IMessageSender, ESPMode::ThreadSafe > &Publisher) override
 
virtual void Register (const FMessageAddress &Address, const TSharedRef< IMessageReceiver, ESPMode::ThreadSafe > &Recipient) override
 
virtual 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, const TSharedRef< IMessageSender, ESPMode::ThreadSafe > &Sender) override
 
virtual void Shutdown () override
 
virtual TSharedPtr< IMessageSubscription, ESPMode::ThreadSafeSubscribe (const TSharedRef< IMessageReceiver, ESPMode::ThreadSafe > &Subscriber, const FTopLevelAssetPath &MessageType, const FMessageScopeRange &ScopeRange) override
 
virtual void Unintercept (const TSharedRef< IMessageInterceptor, ESPMode::ThreadSafe > &Interceptor, const FTopLevelAssetPath &MessageType) override
 
virtual void Unregister (const FMessageAddress &Address) override
 
virtual void Unsubscribe (const TSharedRef< IMessageReceiver, ESPMode::ThreadSafe > &Subscriber, const FTopLevelAssetPath &MessageType) override
 
virtual void AddNotificationListener (const TSharedRef< IBusListener, ESPMode::ThreadSafe > &Listener) override
 
virtual void RemoveNotificationListener (const TSharedRef< IBusListener, ESPMode::ThreadSafe > &Listener) override
 
virtual const FString & GetName () const override
 
- Public Member Functions inherited from TSharedFromThis< FMessageBus, ESPMode::ThreadSafe >
TSharedRef< FMessageBus, Mode > AsShared ()
 
TSharedRef< FMessageBus const, Mode > AsShared () const
 
TSharedRef< SubobjectType, Mode > AsSharedSubobject (SubobjectType *SubobjectPtr) const
 
TWeakPtr< FMessageBus, Mode > AsWeak ()
 
TWeakPtr< FMessageBus 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 IMessageBus
virtual MESSAGING_API void Intercept (const TSharedRef< IMessageInterceptor, ESPMode::ThreadSafe > &Interceptor, const FName &MessageType)
 
virtual MESSAGING_API TSharedPtr< IMessageSubscription, ESPMode::ThreadSafeSubscribe (const TSharedRef< IMessageReceiver, ESPMode::ThreadSafe > &Subscriber, const FName &MessageType, const TRange< EMessageScope > &ScopeRange)
 
virtual MESSAGING_API void Unintercept (const TSharedRef< IMessageInterceptor, ESPMode::ThreadSafe > &Interceptor, const FName &MessageType)
 
virtual MESSAGING_API void Unsubscribe (const TSharedRef< IMessageReceiver, ESPMode::ThreadSafe > &Subscriber, const FName &MessageType)
 
virtual ~IMessageBus ()
 

Additional Inherited Members

- Static Public Attributes inherited from IMessageBus
static MESSAGING_API const FTopLevelAssetPath PATHNAME_All
 
- Protected Member Functions inherited from TSharedFromThis< FMessageBus, ESPMode::ThreadSafe >
 TSharedFromThis ()
 
 TSharedFromThis (TSharedFromThis const &)
 
UE_FORCEINLINE_HINT TSharedFromThisoperator= (TSharedFromThis const &)
 
 ~TSharedFromThis ()
 
- Static Protected Member Functions inherited from TSharedFromThis< FMessageBus, 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 bus.

Constructor & Destructor Documentation

◆ FMessageBus()

FMessageBus::FMessageBus ( FString  InName,
const TSharedPtr< IAuthorizeMessageRecipients > &  InRecipientAuthorizer 
)

Creates and initializes a new instance.

Parameters
InDebugNameThe debug name of this message bus.
InRecipientAuthorizerAn optional recipient authorizer.

◆ ~FMessageBus()

FMessageBus::~FMessageBus ( )
virtual

Virtual destructor.

Member Function Documentation

◆ AddNotificationListener()

void FMessageBus::AddNotificationListener ( const TSharedRef< IBusListener, ESPMode::ThreadSafe > &  Listener)
overridevirtual

Add a listener to the bus notifications

Parameters
ListenerThe listener to as to the registration notifications

Implements IMessageBus.

◆ Forward()

void FMessageBus::Forward ( const TSharedRef< IMessageContext, ESPMode::ThreadSafe > &  Context,
const TArray< FMessageAddress > &  Recipients,
const FTimespan Delay,
const TSharedRef< IMessageSender, ESPMode::ThreadSafe > &  Forwarder 
)
overridevirtual

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 deferral time.
ForwarderThe sender that forwards the message.
See also
Publish, Send

Implements IMessageBus.

◆ GetName()

const FString & FMessageBus::GetName ( ) const
overridevirtual
Returns
The name of this message bus.

Implements IMessageBus.

◆ GetTracer()

TSharedRef< IMessageTracer, ESPMode::ThreadSafe > FMessageBus::GetTracer ( )
overridevirtual

Gets the message bus tracer.

Returns
Weak pointer to the tracer object.

Implements IMessageBus.

◆ Intercept()

void FMessageBus::Intercept ( const TSharedRef< IMessageInterceptor, ESPMode::ThreadSafe > &  Interceptor,
const FTopLevelAssetPath MessageType 
)
overridevirtual

Adds an interceptor for messages of the specified type.

Parameters
InterceptorThe interceptor.
MessageTypeThe type of messages to intercept.
See also
Unintercept

Implements IMessageBus.

◆ OnShutdown()

FOnMessageBusShutdown & FMessageBus::OnShutdown ( )
overridevirtual

Returns a delegate that is executed when the message bus is shutting down.

Returns
The delegate.
See also
Shutdown

Implements IMessageBus.

◆ Publish()

void FMessageBus::Publish ( void Message,
UScriptStruct TypeInfo,
EMessageScope  Scope,
const TMap< FName, FString > &  Annotations,
const FTimespan Delay,
const FDateTime Expiration,
const TSharedRef< IMessageSender, ESPMode::ThreadSafe > &  Publisher 
)
overridevirtual

Sends a message to subscribed recipients.

The bus takes over ownership of the message's memory. It must NOT be freed by the caller.

Parameters
MessageThe message to publish.
TypeInfoThe message's type information.
ScopeThe message scope.
AnnotationsAn optional message annotations header.
DelayThe delay after which to send the message.
ExpirationThe time at which the message expires.
PublisherThe message publisher.
See also
Forward, Send

Implements IMessageBus.

◆ Register()

void FMessageBus::Register ( const FMessageAddress Address,
const TSharedRef< IMessageReceiver, ESPMode::ThreadSafe > &  Recipient 
)
overridevirtual

Registers a message recipient with the message bus.

Parameters
AddressThe address of the recipient to register.
RecipientThe message recipient.
See also
Unregister

Implements IMessageBus.

◆ RemoveNotificationListener()

void FMessageBus::RemoveNotificationListener ( const TSharedRef< IBusListener, ESPMode::ThreadSafe > &  Listener)
overridevirtual

Remove a listener to the bus notifications

Parameters
ListenerThe listener to remove from the registration notifications

Implements IMessageBus.

◆ Send()

void FMessageBus::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,
const TSharedRef< IMessageSender, ESPMode::ThreadSafe > &  Sender 
)
overridevirtual

Sends a message to multiple recipients.

The bus takes over ownership of the message's memory. It must NOT be freed by the caller.

Parameters
MessageThe message to send.
TypeInfoThe message's type information.
FlagsThe message flags.
AnnotationsAn optional message annotations header.
AttachmentThe binary data to attach to the message.
RecipientsThe list of message recipients.
DelayThe delay after which to send the message.
ExpirationThe time at which the message expires.
SenderThe message sender.
See also
Forward, Publish

Implements IMessageBus.

◆ Shutdown()

void FMessageBus::Shutdown ( )
overridevirtual

Shuts down the message bus.

See also
OnShutdown

Implements IMessageBus.

◆ Subscribe()

TSharedPtr< IMessageSubscription, ESPMode::ThreadSafe > FMessageBus::Subscribe ( const TSharedRef< IMessageReceiver, ESPMode::ThreadSafe > &  Subscriber,
const FTopLevelAssetPath MessageType,
const FMessageScopeRange ScopeRange 
)
overridevirtual

Adds a subscription for published messages of the specified type.

Subscriptions allow message consumers to receive published messages from the message bus. The returned interface can be used to query the subscription's details and its enabled state.

Parameters
SubscriberThe subscriber wishing to receive the messages.
MessageTypeThe type of messages to subscribe to (IMessageBus::PATHNAME_All = subscribe to all message types).
ScopeRangeThe range of message scopes to include in the subscription.
Returns
The added subscription, or nullptr if the subscription failed.
See also
Unsubscribe

Implements IMessageBus.

◆ Unintercept()

void FMessageBus::Unintercept ( const TSharedRef< IMessageInterceptor, ESPMode::ThreadSafe > &  Interceptor,
const FTopLevelAssetPath MessageType 
)
overridevirtual

Removes an interceptor for messages of the specified type.

Parameters
InterceptorThe interceptor to remove.
MessageTypeThe type of messages to stop intercepting.
See also
Intercept

Implements IMessageBus.

◆ Unregister()

void FMessageBus::Unregister ( const FMessageAddress Address)
overridevirtual

Unregisters a message recipient from the message bus.

Parameters
AddressThe address of the recipient to unregister.
See also
Register

Implements IMessageBus.

◆ Unsubscribe()

void FMessageBus::Unsubscribe ( const TSharedRef< IMessageReceiver, ESPMode::ThreadSafe > &  Subscriber,
const FTopLevelAssetPath MessageType 
)
overridevirtual

Cancels the specified message subscription.

Parameters
SubscriberThe subscriber wishing to stop receiving the messages.
MessageTypeThe type of messages to unsubscribe from (IMessageBus::PATHNAME_All = all types).
See also
Subscribe

Implements IMessageBus.


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