Quantum 3 3.1.0

Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Properties | List of all members
Photon.Realtime.ConnectionHandler Class Reference

Handler class to use threading to keep a RealtimeClient connection alive (calling SendAcksOnly if it was not called in time). More...

Public Member Functions

void RealtimeFallback (object state=null)
 A thread which runs independently of the Update() calls. Keeps connections online while loading or in background. See KeepAliveInBackground. More...
 
void RealtimeFallbackInvoke ()
 Used in WebGL builds which can't call RealtimeFallback(object state = null) with the state context parameter. More...
 
void RemoveInstance ()
 Stopping the fallback thread. In Unity, calls Destroy(this). More...
 
void StartFallbackSendAckThread ()
 Starts periodic calls of RealtimeFallbackThread. More...
 
void StopFallbackSendAckThread ()
 Stops the periodic calls of RealtimeFallbackThread. More...
 

Static Public Member Functions

static ConnectionHandler BuildInstance (RealtimeClient client, string id=null)
 Creates an instance of the ConnectionHandler, assigns the given client. In Unity this uses a single GameObject to store all components on and applies DontDestroyOnLoad. More...
 
static bool IsNetworkReachableUnity ()
 When run in Unity, this returns Application.internetReachability != NetworkReachability.NotReachable. More...
 

Public Attributes

bool DisconnectAfterKeepAlive = false
 Option to let the fallback thread call Disconnect after the KeepAliveInBackground time. Default: false. More...
 
string Id
 Optional string identifier for the instance (for debugging). More...
 
int KeepAliveInBackground = 60000
 Defines for how long the Fallback Thread should keep the connection, before it may time out as usual. More...
 

Static Public Attributes

static bool AppOutOfFocus
 Indicates that the app is not in focus. More...
 
static bool AppOutOfFocusRecent
 Indicates that the app was out of focus within the last 5 seconds. More...
 
static bool AppPause
 Indicates that the (Unity) app is Paused. This means the main thread is not running. More...
 
static bool AppPauseRecent
 Indicates that the app was paused within the last 5 seconds. More...
 
static bool AppQuits
 Indicates that the app is closing. Set in OnApplicationQuit(). More...
 

Properties

RealtimeClient Client [get, set]
 Photon client to log information and statistics from. More...
 
int CountSendAcksOnly [get]
 Counts how often the Fallback Thread called SendAcksOnly, which is purely of interest to monitor if the game logic called SendOutgoingCommands as intended. More...
 
bool FallbackThreadRunning [get]
 True if a fallback thread is running. Will call the client's SendAcksOnly() method to keep the connection up. More...
 

Detailed Description

Handler class to use threading to keep a RealtimeClient connection alive (calling SendAcksOnly if it was not called in time).

Member Function Documentation

◆ BuildInstance()

static ConnectionHandler Photon.Realtime.ConnectionHandler.BuildInstance ( RealtimeClient  client,
string  id = null 
)
inlinestatic

Creates an instance of the ConnectionHandler, assigns the given client. In Unity this uses a single GameObject to store all components on and applies DontDestroyOnLoad.

Parameters
clientThe client to handle.
idOptional ID for this handle (could be based / related to the client instance).
Returns

◆ RemoveInstance()

void Photon.Realtime.ConnectionHandler.RemoveInstance ( )
inline

Stopping the fallback thread. In Unity, calls Destroy(this).

◆ IsNetworkReachableUnity()

static bool Photon.Realtime.ConnectionHandler.IsNetworkReachableUnity ( )
inlinestatic

When run in Unity, this returns Application.internetReachability != NetworkReachability.NotReachable.

Returns
Application.internetReachability != NetworkReachability.NotReachable

◆ StartFallbackSendAckThread()

void Photon.Realtime.ConnectionHandler.StartFallbackSendAckThread ( )
inline

Starts periodic calls of RealtimeFallbackThread.

◆ StopFallbackSendAckThread()

void Photon.Realtime.ConnectionHandler.StopFallbackSendAckThread ( )
inline

Stops the periodic calls of RealtimeFallbackThread.

◆ RealtimeFallbackInvoke()

void Photon.Realtime.ConnectionHandler.RealtimeFallbackInvoke ( )
inline

Used in WebGL builds which can't call RealtimeFallback(object state = null) with the state context parameter.

◆ RealtimeFallback()

void Photon.Realtime.ConnectionHandler.RealtimeFallback ( object  state = null)
inline

A thread which runs independently of the Update() calls. Keeps connections online while loading or in background. See KeepAliveInBackground.

Member Data Documentation

◆ Id

string Photon.Realtime.ConnectionHandler.Id

Optional string identifier for the instance (for debugging).

◆ DisconnectAfterKeepAlive

bool Photon.Realtime.ConnectionHandler.DisconnectAfterKeepAlive = false

Option to let the fallback thread call Disconnect after the KeepAliveInBackground time. Default: false.

If set to true, the thread will disconnect the client regularly, should the client not call SendOutgoingCommands / Service. This may happen due to an app being in background (and not getting a lot of CPU time) or when loading assets.

If false, a regular timeout time will have to pass (on top) to time out the client.

◆ KeepAliveInBackground

int Photon.Realtime.ConnectionHandler.KeepAliveInBackground = 60000

Defines for how long the Fallback Thread should keep the connection, before it may time out as usual.

We want to the Client to keep it's connection when an app is in the background (and doesn't call Update / Service Clients should not keep their connection indefinitely in the background, so after some milliseconds, the Fallback Thread should stop keeping it up.

◆ AppQuits

bool Photon.Realtime.ConnectionHandler.AppQuits
static

Indicates that the app is closing. Set in OnApplicationQuit().

◆ AppPause

bool Photon.Realtime.ConnectionHandler.AppPause
static

Indicates that the (Unity) app is Paused. This means the main thread is not running.

◆ AppPauseRecent

bool Photon.Realtime.ConnectionHandler.AppPauseRecent
static

Indicates that the app was paused within the last 5 seconds.

◆ AppOutOfFocus

bool Photon.Realtime.ConnectionHandler.AppOutOfFocus
static

Indicates that the app is not in focus.

◆ AppOutOfFocusRecent

bool Photon.Realtime.ConnectionHandler.AppOutOfFocusRecent
static

Indicates that the app was out of focus within the last 5 seconds.

Property Documentation

◆ Client

RealtimeClient Photon.Realtime.ConnectionHandler.Client
getset

Photon client to log information and statistics from.

◆ CountSendAcksOnly

int Photon.Realtime.ConnectionHandler.CountSendAcksOnly
get

Counts how often the Fallback Thread called SendAcksOnly, which is purely of interest to monitor if the game logic called SendOutgoingCommands as intended.

◆ FallbackThreadRunning

bool Photon.Realtime.ConnectionHandler.FallbackThreadRunning
get

True if a fallback thread is running. Will call the client's SendAcksOnly() method to keep the connection up.