Quantum 3 3.1.0

Classes | Public Member Functions | List of all members
Photon.Realtime.EventBetter Class Reference

Allows registering for individual callbacks of the Photon Realtime API, using Message Types. More...

Classes

class  YieldListener
 Listener for specific message type. More...
 

Public Member Functions

void Clear ()
 Unregisters everything. More...
 
IDisposable ListenManual< MessageType > (System.Action< MessageType > handler)
 Register a message handler. No listener, you unregister by calling Dispose on returned object. Handler is not limited in what it is allowed to capture. More...
 
YieldListener< MessageType > ListenWait< MessageType > ()
 Use this in coroutines. Yield will return when at least one event of type MessageType has been raised. To get the messages use YieldListener<MessageType>.First or YieldListener<MessageType>.Messages More...
 
bool Raise< MessageType > (MessageType message)
 Invoke all registered handlers for this message type immediately. More...
 
void RemoveUnusedHandlers ()
 Removes handlers that will now longer be called because their listeners have been destroyed. Normally there's no reason to call that, since EventBetter does it behind the scenes in every LateUpdate. More...
 

Detailed Description

Allows registering for individual callbacks of the Photon Realtime API, using Message Types.

Intentionally made partial, in case you want to extend it easily.

In Unity, the EventBetterWorker is used to clean up unused registrations in LateUpdate() automatically. In .Net apps, the game logic should RemoveUnusedHandlers.

Member Function Documentation

◆ ListenManual< MessageType >()

IDisposable Photon.Realtime.EventBetter.ListenManual< MessageType > ( System.Action< MessageType >  handler)
inline

Register a message handler. No listener, you unregister by calling Dispose on returned object. Handler is not limited in what it is allowed to capture.

Template Parameters
MessageType
Parameters
handler
Returns

◆ Raise< MessageType >()

bool Photon.Realtime.EventBetter.Raise< MessageType > ( MessageType  message)
inline

Invoke all registered handlers for this message type immediately.

Template Parameters
MessageType
Parameters
message
Returns
True if there are any handlers for this message type, false otherwise.

◆ Clear()

void Photon.Realtime.EventBetter.Clear ( )
inline

Unregisters everything.

◆ RemoveUnusedHandlers()

void Photon.Realtime.EventBetter.RemoveUnusedHandlers ( )
inline

Removes handlers that will now longer be called because their listeners have been destroyed. Normally there's no reason to call that, since EventBetter does it behind the scenes in every LateUpdate.

◆ ListenWait< MessageType >()

YieldListener<MessageType> Photon.Realtime.EventBetter.ListenWait< MessageType > ( )
inline

Use this in coroutines. Yield will return when at least one event of type MessageType has been raised. To get the messages use YieldListener<MessageType>.First or YieldListener<MessageType>.Messages

Template Parameters
MessageType
Returns
Type Constraints
MessageType :class