Photon .NET Client API 4.1.4.8

Classes | Public Member Functions | Static Public Member Functions | Static Protected Attributes | List of all members
ExitGames.Client.Photon.SupportClass Class Reference

Contains several (more or less) useful static methods, mostly used for debugging. More...

Classes

class  ThreadSafeRandom
 Class to wrap static access to the random.Next() call in a thread safe manner. More...
 

Public Member Functions

delegate int IntegerMillisecondsDelegate ()
 

Static Public Member Functions

static List< MethodInfo > GetMethods (Type type, Type attribute)
 
static int GetTickCount ()
 Gets the local machine's "milliseconds since start" value (precision is described in remarks). More...
 
static byte StartBackgroundCalls (Func< bool > myThread, int millisecondsInterval=100, string taskName="")
 Creates a background thread that calls the passed function in intervals, as long as that returns true. More...
 
static bool StopBackgroundCalls (byte id)
 Calls Abort on the thread with the given id (= index of the thread list) More...
 
static bool StopAllBackgroundCalls ()
 Calls Abort on all threads that were started via StartBackgroundCalls. More...
 
static void WriteStackTrace (System.Exception throwable, System.IO.TextWriter stream)
 Writes the exception's stack trace to the received stream. More...
 
static void WriteStackTrace (System.Exception throwable)
 Writes the exception's stack trace to the received stream. Writes to: System.Diagnostics.Debug. More...
 
static string DictionaryToString (IDictionary dictionary, bool includeTypes=true)
 This method returns a string, representing the content of the given IDictionary. Returns "null" if parameter is null. More...
 
static string DictionaryToString (NonAllocDictionary< byte, object > dictionary, bool includeTypes=true)
 
static string HashtableToString (Hashtable hash)
 
static string ByteArrayToString (byte[] list)
 Converts a byte-array to string (useful as debugging output). Uses BitConverter.ToString(list) internally after a null-check of list. More...
 
static uint CalculateCrc (byte[] buffer, int length)
 

Static Protected Attributes

static IntegerMillisecondsDelegate IntegerMilliseconds = () => (int)(Environment.TickCount)
 

Detailed Description

Contains several (more or less) useful static methods, mostly used for debugging.

Member Function Documentation

◆ ByteArrayToString()

static string ExitGames.Client.Photon.SupportClass.ByteArrayToString ( byte[]  list)
inlinestatic

Converts a byte-array to string (useful as debugging output). Uses BitConverter.ToString(list) internally after a null-check of list.

Parameters
listByte-array to convert to string.
Returns
List of bytes as string.

◆ CalculateCrc()

static uint ExitGames.Client.Photon.SupportClass.CalculateCrc ( byte[]  buffer,
int  length 
)
inlinestatic

◆ DictionaryToString() [1/2]

static string ExitGames.Client.Photon.SupportClass.DictionaryToString ( IDictionary  dictionary,
bool  includeTypes = true 
)
inlinestatic

This method returns a string, representing the content of the given IDictionary. Returns "null" if parameter is null.

Parameters
dictionaryIDictionary to return as string.
includeTypes

◆ DictionaryToString() [2/2]

static string ExitGames.Client.Photon.SupportClass.DictionaryToString ( NonAllocDictionary< byte, object >  dictionary,
bool  includeTypes = true 
)
inlinestatic

◆ GetMethods()

static List<MethodInfo> ExitGames.Client.Photon.SupportClass.GetMethods ( Type  type,
Type  attribute 
)
inlinestatic

◆ GetTickCount()

static int ExitGames.Client.Photon.SupportClass.GetTickCount ( )
inlinestatic

Gets the local machine's "milliseconds since start" value (precision is described in remarks).

This method uses Environment.TickCount (cheap but with only 16ms precision). PhotonPeer.LocalMsTimestampDelegate is available to set the delegate (unless already connected).

Returns
Fraction of the current time in Milliseconds (this is not a proper datetime timestamp).

◆ HashtableToString()

static string ExitGames.Client.Photon.SupportClass.HashtableToString ( Hashtable  hash)
inlinestatic

◆ IntegerMillisecondsDelegate()

delegate int ExitGames.Client.Photon.SupportClass.IntegerMillisecondsDelegate ( )

◆ StartBackgroundCalls()

static byte ExitGames.Client.Photon.SupportClass.StartBackgroundCalls ( Func< bool >  myThread,
int  millisecondsInterval = 100,
string  taskName = "" 
)
inlinestatic

Creates a background thread that calls the passed function in intervals, as long as that returns true.

With StopBackgroundCalls, you can stop threads started with this method. The resulting ThreadAbortException is caught and discarded.

Parameters
myThreadThe function to call. Must return true, if it should be called again. Returning false ends the thread.
millisecondsIntervalMilliseconds to sleep between calls of myThread. Default: 100ms.
taskNameAn optional name for the task to help debugging. Null or empty won't set the thread.Name.

◆ StopAllBackgroundCalls()

static bool ExitGames.Client.Photon.SupportClass.StopAllBackgroundCalls ( )
inlinestatic

Calls Abort on all threads that were started via StartBackgroundCalls.

The resulting ThreadAbortException is caught and discarded.

Returns
True if any thread got aborted.

◆ StopBackgroundCalls()

static bool ExitGames.Client.Photon.SupportClass.StopBackgroundCalls ( byte  id)
inlinestatic

Calls Abort on the thread with the given id (= index of the thread list)

The resulting ThreadAbortException is caught and discarded.

Parameters
idThe unique ID of the thread.
Returns
True if the thread is canceled and false otherwise, e.g. if the thread with the given ID does not exist.

◆ WriteStackTrace() [1/2]

static void ExitGames.Client.Photon.SupportClass.WriteStackTrace ( System.Exception  throwable)
inlinestatic

Writes the exception's stack trace to the received stream. Writes to: System.Diagnostics.Debug.

Parameters
throwableException to obtain information from.

◆ WriteStackTrace() [2/2]

static void ExitGames.Client.Photon.SupportClass.WriteStackTrace ( System.Exception  throwable,
System.IO.TextWriter  stream 
)
inlinestatic

Writes the exception's stack trace to the received stream.

Parameters
throwableException to obtain information from.
streamOutput sream used to write to.

Member Data Documentation

◆ IntegerMilliseconds

IntegerMillisecondsDelegate ExitGames.Client.Photon.SupportClass.IntegerMilliseconds = () => (int)(Environment.TickCount)
staticprotected

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