Operating System Simulator Plugin  3.5.1
Unreal Engine plugin that simulates an Operating System Environment
Loading...
Searching...
No Matches
FGlobalMessenger Class Reference

Represents a global messenger for sending messages to multiple listeners. More...

#include "GlobalMessenger.h"

Inheritance diagram for FGlobalMessenger:
[legend]
Collaboration diagram for FGlobalMessenger:
[legend]

Public Member Functions

 ~FGlobalMessenger ()
 
void BroadcastMessage (const FGameplayTag &FilterTag, UObject *Payload)
 Broadcasts a global message to all registered listeners.
 
void AddListener (const UObject *NewListener, const FGameplayTag &FilterTag, const FGlobalMessageReceiveDelegate &Callback)
 Adds a listener to the global message system.
 
bool RemoveListener (const UObject *TestObject)
 Removes a listener from the global message system.
 
void ClearMappedDelegates ()
 Clears all mapped delegates in the global messenger.
 

Detailed Description

Represents a global messenger for sending messages to multiple listeners.

The FGlobalMessenger class allows broadcasting messages to multiple listeners and managing those listeners. Messages can be filtered using gameplay tags to control which listeners receive the message.

Constructor & Destructor Documentation

◆ ~FGlobalMessenger()

FGlobalMessenger::~FGlobalMessenger ( )

Member Function Documentation

◆ AddListener()

void FGlobalMessenger::AddListener ( const UObject * NewListener,
const FGameplayTag & FilterTag,
const FGlobalMessageReceiveDelegate & Callback )

Adds a listener to the global message system.

This method adds a listener to the global message system by mapping it with the provided filter tag and callback. The listener will receive messages that match the filter tag when the messages are broadcasted using the BroadcastMessage method.

Parameters
NewListenerThe pointer to the object that will receive the global message.
FilterTagThe tag that represents the message. Only listeners with matching tags will receive the message.
CallbackThe delegate function to be executed when the message is received.
Note
The NewListener must be a valid UObject pointer, otherwise the method will return without adding the listener.
It is recommended to call RemoveListener on the object before destroying it to prevent warnings.
Do not use directly. Use UGlobalMessengerSubsystem instead.
See also
BroadcastMessage
RemoveListener

◆ BroadcastMessage()

void FGlobalMessenger::BroadcastMessage ( const FGameplayTag & FilterTag,
UObject * Payload )

Broadcasts a global message to all registered listeners.

This method iterates over all registered listeners and executes their corresponding callbacks. The callbacks are only executed if they are bound. If an unbound callback is encountered, a warning message is logged indicating that the owning object could be destroyed. It is recommended to call 'RemoveListener' on the object before destroying it to prevent this warning.

Parameters
FilterTagThe tag used to filter the listeners. Only listeners with matching tags will receive the message. If the tag is not valid, all listeners will receive the message.
PayloadThe payload object to pass to the listeners. *
Note
Do not use directly. Use UGlobalMessengerSubsystem instead.

◆ ClearMappedDelegates()

void FGlobalMessenger::ClearMappedDelegates ( )

Clears all mapped delegates in the global messenger.

This method clears all mapped delegates in the global messenger. It empties the container of mapped delegates, effectively removing all listeners from the global message system. The cleared delegates will no longer receive any messages.

Note
This method is automatically called in the destructor of the FGlobalMessenger class.
See also
FGlobalMessenger::~FGlobalMessenger

◆ RemoveListener()

bool FGlobalMessenger::RemoveListener ( const UObject * TestObject)

Removes a listener from the global message system.

This method removes the listener from the global message system by finding and removing the associated delegate from the mapped delegates container. The listener will no longer receive messages matching its filter tag. It is recommended to call this method before destroying the object to prevent warnings.

Parameters
TestObjectThe pointer to the object that needs to be removed as a listener.
Returns
True if the listener was removed successfully, false otherwise.
Note
The TestObject must be a valid UObject pointer, otherwise this method will return false without removing the listener.
Do not use directly. Use UGlobalMessengerSubsystem instead.

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