Photon3Unity3D Initializes a new instance of the class. Gets the public key that can be used by another DiffieHellmanCryptoProvider object to generate a shared secret agreement. Derives the shared key is generated from the secret agreement between two parties, given a byte array that contains the second party's public key. The second party's public key. Interface for Photon's DiffieHellman/Payload Encryption. Provides classical Diffie-Hellman Modular Exponentiation Groups defined by the OAKLEY Key Determination Protocol (RFC 2412). Gets the genrator (N) used by the the well known groups 1,2 and 5. Gets the 768 bit prime for the well known group 1. Gets the 1024 bit prime for the well known group 2. Gets the 1536 bit prime for the well known group 5. A slice of memory that should be pooled and reused. Wraps a byte-array. This is a serializable datatype for the .Net clients. It will serialize and transfer as byte[]. If PhotonPeer.UseByteArraySlicePoolForEvents is enabled, byte-arrays in (incoming) events will be deserialized as ByteArraySlice. Adjust your OnEvent code accordingly. The buffer for the slice. The position where the content starts in Buffer. The length of the data in the Buffer. Internal constructor - these instances will be part of the pooling system. The pool to return to. The index to return to (in the related returnPool). Create a new ByteArraySlice. The buffer supplied will be used. Usage is similar to ArraySegment. Not part of pooling. Creates a ByteArraySlice, which is not pooled. It has no Buffer. Not part of pooling. If this item was fetched from a ByteArraySlicePool, this will return it. True if this was a pooled item and it successfully was returned. If it does not belong to a pool nothing will happen, and false will be returned. Resets Count and Offset to 0 each. Tiered pool for ByteArraySlices. Reduces the allocations once enough slices are available. Requests for buffers smaller than 2^minStackIndex will use 2^minStackIndex. This value avoids allocations of smaller rarely used buffers. Set this to a lower value if you will never need sizes larger than byte[2^minStackIndex] Count of allocations this pool did. Creates a new pool. Get a ByteArraySlice from pool. This overload handles user supplied byte[] and byte count and can be used as a non-boxing alternative to ArraySegment<byte>. This effectively pools the ByteArraySlice instances but not their data. ByteArraySlice.Release() will return the slice itself to the pool but delete the reference to the buffer supplied here. Get byte[] wrapper from pool. This overload accepts a bytecount and will return a wrapper with a byte[] that size or greater. Pops a slice from the stack or creates a new slice for that stack. The stack to use. Lock that stack before calling PopOrCreate for thread safety. A slice. Releasing a ByteArraySlice, will put it back into the pool, if it was acquired from one. The ByteArraySlice to return to the pool. The stackIndex for this slice. True if this slice was returned to some pool. False if not (null or stackIndex < 0. Clears all pool items with byte array sizes between lower and upper inclusively. Use this if you sent some unusually large RaiseEvents and believe the buffers of that size will not be needed again, and you would like to free up the buffer memory. Replacement for Dictionary<K,V> which does not allocate memory during usage. Key type. Value type. This is a substitute for the Hashtable class, missing in: Win8RT and Windows Phone. It uses a Dictionary<object,object> as base. Please be aware that this class might act differently than the Hashtable equivalent. As far as Photon is concerned, the substitution is sufficiently precise. Translates the byte key into the pre-boxed byte before doing the lookup. Creates a shallow copy of the Hashtable. A shallow copy of a collection copies only the elements of the collection, whether they are reference types or value types, but it does not copy the objects that the references refer to. The references in the new collection point to the same objects that the references in the original collection point to. Shallow copy of the Hashtable. Used as container for unknown types the client could not deserialize. The type code which was read for this type. The size/length value that was read for this type. May be larger than Data.Length, if the Size exceeded the remaining message content. Container for the data that arrived. If the Size exceeded the remaining message length, only the remaining data is read. This may be null, if the size was somehow less than 1. Interface for DatagramEncryptor implementations. Initialize the encryptor. Encryption/decryption algorithm implementation Packet authentication algorithm impelmenation Number for reliable unsequenced commands (separate from "standard" reliable sequenced). Used to avoid duplicates. The highest number of reliable unsequenced commands that arrived (and all commands before). Any reliable unsequenced number that's been received, which is higher than the current highest in complete sequence (reliableUnsequencedNumbersCompletelyReceived). To store the highest acknowledged sequence number (and get some impression what the server already received and stored). Checks and queues incoming reliable unsequenced commands ("send" or "fragment"), if they haven't been received yet. The command to check and queue. True if the command is new and got queued (or could be executed/dispatched). Quick Resends are suspended if the sent queue is this size or larger. One list for all channels keeps sent commands (for re-sending). One pool of ACK byte arrays ( 20 bytes each) for all channels to keep acknowledgements. Gets enabled by "request" from server (not by client). Initial PeerId as used in Connect command. If EnableServerTracing is false. Initial PeerId to enable Photon Tracing, as used in Connect command. See: EnableServerTracing. Checks the incoming queue and Dispatches received data if possible. If a Dispatch happened or not, which shows if more Dispatches might be needed. Gets the target size for fragments. Caches the result for a specific MTU value. Fragment length is different, when datagram encryption is used (so this caches two values in fact). gathers acks until udp-packet is full and sends it! Queue of received commands. ReceiveIncomingCommands will queue commands, except ACKs which Execute immediately. gathers commands from all (out)queues until udp-packet is full and sends it! Checks connected state and channel before operation is serialized and enqueued for sending. if operation could be enqueued reliable-udp-level function to send some byte[] to the server via un/reliable command only called when a custom operation should be send the invocation ID for this operation (the payload) reads incoming udp-packages to create and queue incoming commands* Queues incoming commands in the correct order as either unreliable, reliable or unsequenced. If queued or not. removes commands which are acknowledged Enumeration of situations that change the peers internal status. Used in calls to OnStatusChanged to inform your application of various situations that might happen. Most of these codes are referenced somewhere else in the documentation when they are relevant to methods. the PhotonPeer is connected.
See {@link PhotonListener#OnStatusChanged}*
the PhotonPeer just disconnected.
See {@link PhotonListener#OnStatusChanged}*
the PhotonPeer encountered an exception and will disconnect, too.
See {@link PhotonListener#OnStatusChanged}*
Exception while opening the incoming connection to the server. Followed by Disconnect. The server could be down / not running or the client has no network or a misconfigured DNS.
See {@link PhotonListener#OnStatusChanged}*
Used on platforms that throw a security exception on connect. Unity3d does this, e.g., if a webplayer build could not fetch a policy-file from a remote server. Sending command failed. Either not connected, or the requested channel is bigger than the number of initialized channels. Exception, if a server cannot be connected. Followed by Disconnect. Most likely, the server is not responding. Ask user to try again later. Disconnection due to a timeout (client did no longer receive ACKs from server). Followed by Disconnect. Timeout disconnect by server. The server didn't receive necessary ACKs in time. Followed by Disconnect. Disconnect by server due to concurrent user limit reached (received a disconnect command). (1043) Disconnect by server due to server's logic. Followed by Disconnect. Disconnect by server due to unspecified reason. Followed by Disconnect. (1048) Value for OnStatusChanged()-call, when the encryption-setup for secure communication finished successfully. (1049) Value for OnStatusChanged()-call, when the encryption-setup failed for some reason. Check debug logs. Callback interface for the Photon client side. Must be provided to a new PhotonPeer in its constructor. These methods are used by your PhotonPeer instance to keep your app updated. Read each method's description and check out the samples to see how to use them. Provides textual descriptions for various error conditions and noteworthy situations. In cases where the application needs to react, a call to OnStatusChanged is used. OnStatusChanged gives "feedback" to the game, DebugReturn provies human readable messages on the background. All debug output of the library will be reported through this method. Print it or put it in a buffer to use it on-screen. Use PhotonPeer.DebugOut to select how verbose the output is. DebugLevel (severity) of the message. Debug text. Print to System.Console or screen. Callback method which gives you (async) responses for called operations. Similar to method-calling, operations can have a result. Because operation-calls are non-blocking and executed on the server, responses are provided after a roundtrip as call to this method. Example: Trying to create a room usually succeeds but can fail if the room's name is already in use (room names are their IDs). This method is used as general callback for all operations. Each response corresponds to a certain "type" of operation by its OperationCode. When you join a room, the server will assign a consecutive number to each client: the "actorNr" or "player number". This is sent back in the operation result. Fetch your actorNr of a Join response like this: int actorNr = (int)operationResponse[(byte)OperationCode.ActorNr]; The response to an operation\-call. OnStatusChanged is called to let the game know when asynchronous actions finished or when errors happen. Not all of the many StatusCode values will apply to your game. Example: If you don't use encryption, the respective status changes are never made. The values are all part of the StatusCode enumeration and described value-by-value. A code to identify the situation. Called whenever an event from the Photon Server is dispatched. Events are used for communication between clients and allow the server to update clients anytime. The creation of an event is often triggered by an operation (called by this client or an other). Each event carries a Code plus optional content in its Parameters. Your application should identify which content to expect by the event's Code. Events can be defined and modified server-side. If you use the LoadBalancing api as basis, several events like EvJoin and EvLeave are pre-defined. The LoadBalancing api provides the EventCode and ParameterCode classes for pre-defined events. Photon also allows you to come up with custom events on the fly, purely client-side. To do so, use OpRaiseEvent. Events are incoming messages and as such buffered in the peer. Calling PhotonPeer.DispatchIncomingCommands will call IPhotonPeerListener.OnEvent, to hand over received events. PhotonPeer.ReuseEventInstance is an option to optimize memory usage by reusing one EventData instance. The event currently being dispatched. The protocol for this socket, defined in constructor. Address, as defined via a Connect() call. Including protocol, port and or path. This is set in the constructor and in Connect() again. Typically the address does not change after the IPhotonSocket is instantiated. Contains only the server's hostname (stripped protocol, port and or path). Set in IPhotonSocket.Connect(). Contains the IP address of the previously resolved ServerAddress (or empty, if GetIpAddress wasn't used). Contains only the server's port address (as string). Set in IphotonSocket.Connect(). Where available, this exposes if the server's address was resolved into an IPv6 address or not. Provides the protocol string, of the current PhotonPeer.SerializationProtocolType to be used for WebSocket connections. Any WebSocket wrapper could access this to get the desired binary protocol for the connection. Some WebSocket implementations use a static value of the same name and need to be updated. The value is not cached and each call will create the needed string on the fly. Separates the given address into address (host name or IP) and port. Port must be included after colon! This method expects any address to include a port. The final ':' in addressAndPort has to separate it. IPv6 addresses have multiple colons and must use brackets to separate address from port. Examples: ns.exitgames.com:5058 http://[2001:db8:1f70::999:de8:7648:6e8]:100/ [2001:db8:1f70::999:de8:7648:6e8]:100 See: http://serverfault.com/questions/205793/how-can-one-distinguish-the-host-and-the-port-in-an-ipv6-url Wraps a DNS call to provide an array of addresses, sorted to have the IPv6 ones first. This skips a DNS lookup, if the hostname is an IPv4 address. Then only this address is used as is. The DNS lookup may take a while, so it is recommended to do this in a thread. Also, it may fail entirely. IPAddress array for hostname, sorted to put any IPv6 addresses first.
If the DNS lookup fails, HandleException(StatusCode.ExceptionOnConnect) gets called and null returned. Then the socket should not attempt to connect.
Returns null or the IPAddress representing the address, doing Dns resolution if needed. Only returns IPv4 or IPv6 adresses, no others. The string address of a server (hostname or IP). IPAddress for the string address or null, if the address is neither IPv4, IPv6 or some hostname that could be resolved. Variants of the Photon specific serialization protocol used for operations, responses, events and data. Version 1.6 (outdated). Version 1.8. Serialize creates a byte-array from the given object and returns it. The object to serialize The serialized byte-array Deserialize returns an object reassembled from the given StreamBuffer. The buffer to be Deserialized The Deserialized object Deserialize returns an object reassembled from the given byte-array. The byte-array to be Deserialized The Deserialized object Interface for (UDP) traffic capturing. Indicates if the PhotonPeer should call Record or not. Implement to record network traffic. Called by PhotonPeer for each UDP message sent and received. The buffer will not contain Ethernet Header, IP, UDP level data. Only the payload received by the client. It is advised to not use NetworkSimulation when recording traffic. The recording is done on the timing of actual receive- and send-calls and internal simulation would offset the timing. Buffer to be sent or received. Check length value for actual content length. Length of the network data. Indicates incoming (true) or outgoing (false) traffic. The local peerId for the connection. Defaults to 0xFFFF until assigned by the Server. The currently used IPhotonSocket of this Peer. Enables you to track the connection endpoint. Internal class for "commands" - the package in which operations are sent. Size of the Payload, which may be null. Checks commandFlags & FV_UNRELIABLE_UNSEQUENCED. Checks commandFlags & FV_RELIABLE. ACKs should never be created as NCommand. use CreateACK to wrtie the serialized ACK right away... this variant does only create outgoing commands and increments . incoming ones are created from a DataInputStream this variant does only create outgoing commands and increments . incoming ones are created from a DataInputStream reads the command values (commandHeader and command-values) from incoming bytestream and populates the incoming command* A simulation item is an action that can be queued to simulate network lag. With this, the actual delay can be measured, compared to the intended lag. Timestamp after which this item must be executed. Action to execute when the lag-time passed. Starts a new Stopwatch A set of network simulation settings, enabled (and disabled) by PhotonPeer.IsSimulationEnabled. For performance reasons, the lag and jitter settings can't be produced exactly. In some cases, the resulting lag will be up to 20ms bigger than the lag settings. Even if all settings are 0, simulation will be used. Set PhotonPeer.IsSimulationEnabled to false to disable it if no longer needed. All lag, jitter and loss is additional to the current, real network conditions. If the network is slow in reality, this will add even more lag. The jitter values will affect the lag positive and negative, so the lag settings describe the medium lag even with jitter. The jitter influence is: [-jitter..+jitter]. Packets "lost" due to OutgoingLossPercentage count for BytesOut and LostPackagesOut. Packets "lost" due to IncomingLossPercentage count for BytesIn and LostPackagesIn. internal internal internal internal internal internal internal This setting overrides all other settings and turns simulation on/off. Default: false. Outgoing packages delay in ms. Default: 100. Randomizes OutgoingLag by [-OutgoingJitter..+OutgoingJitter]. Default: 0. Percentage of outgoing packets that should be lost. Between 0..100. Default: 1. TCP ignores this setting. Incoming packages delay in ms. Default: 100. Randomizes IncomingLag by [-IncomingJitter..+IncomingJitter]. Default: 0. Percentage of incoming packets that should be lost. Between 0..100. Default: 1. TCP ignores this setting. Counts how many outgoing packages actually got lost. TCP connections ignore loss and this stays 0. Counts how many incoming packages actually got lost. TCP connections ignore loss and this stays 0. Provides an overview of the current values in form of a string. String summary. The pool this wrapper should return to when released/disposed. Gets value and if it belongs to the static pool, returns the wrapper to pool. Boxes the value and returns boxed object. Releases the wrapper. Removes this WrapperStruct from pooling. Returns a String which represents the value of this instance. String which represents the value of this instance. Returns a String which represents the type (in brackets and value of this instance. String which represents the type (in brackets) and value of this instance. staticPool is used for implicit casting. This is not threadsafe, so casting between T and StructWrapper should only be done on the Unity main thread. Replacement for object.GetType() that first checks to see if object is a WrappedStruct. If so returns the StructWrapper T type, otherwise just returns object.GetType(). Wrap a struct in a pooled StructWrapper. Wrap a struct in a pooled StructWrapper. Pulls wrapper from the static pool. Wrapper is returned to pool when Unwrapped. Slighty faster version of Wrap() that is hard wired to pull from the static pool. Use the persistant bool argument to make a permanent unpooled wrapper. Tests if object is either a cast T, or a wrapped T Remove all wrappers in hashtable from pooling, so they can remain cached and used later. Unwraps any WrapperStructs, boxes their value, releases hashtable entry with the boxed value. Releases the wrappers. If object is a StructWrapper, the value will be extracted. If not, the object will be cast to T. Wrapper is returned to the wrapper pool if applicable, so it is not considered safe to Unwrap multiple times, as the wrapper may be recycled. If object is a StructWrapper, the value will be extracted. If not, the object will be cast to T. Wrapper is will not be returned to its pool until it is Unwrapped, or the pool is cleared. If object is a StructWrapper, the value will be extracted. If not, the object will be cast to T. Wrapper is returned to the wrapper pool if applicable, so it is not considered safe to Unwrap multiple times, as the wrapper may be recycled. If object is a StructWrapper, the value will be extracted. If not, the object will be cast to T. Wrapper is returned to the wrapper pool if applicable, so it is not considered safe to Unwrap multiple times, as the wrapper may be recycled. If object is a StructWrapper, the value will be extracted. If not, the object will be cast to T. If object is a StructWrapper, the value will be extracted. If not, the object will be cast to T. If object is a StructWrapper, the value will be extracted. If not, the object will be cast to T. Wrapper is returned to the wrapper pool if applicable, so it is not considered safe to Unwrap multiple times, as the wrapper may be recycled. If object is a StructWrapper, the value will be extracted. If not, the object will be cast to T. Wrapper is returned to the wrapper pool if applicable, so it is not considered safe to Unwrap multiple times, as the wrapper may be recycled. If object is a StructWrapper, the value will be extracted. If not, the object will be cast to T. Wrapper is will not be returned to its pool until it is Unwrapped, or the pool is cleared. Will get the object using the key. If the key is invalid, will return null. Dictionary content as string. If true, type-info is also included. Full content of dictionary as string. Param code. Used in internal op: InitEncryption. Encryption-Mode code. Used in internal op: InitEncryption. Param code. Used in internal op: InitEncryption. Code of internal op: InitEncryption. TODO: Code of internal op: Ping (used in PUN binary websockets). Result code for any (internal) operation. This is the replacement for the const values used in eNet like: PS_DISCONNECTED, PS_CONNECTED, etc. No connection is available. Use connect. Establishing a connection already. The app should wait for a status callback. The low level connection with Photon is established. On connect, the library will automatically send an Init package to select the application it connects to (see also PhotonPeer.Connect()). When the Init is done, IPhotonPeerListener.OnStatusChanged() is called with connect. Please note that calling operations is only possible after the OnStatusChanged() with StatusCode.Connect. Connection going to be ended. Wait for status callback. Acknowledging a disconnect from Photon. Wait for status callback. Connection not properly disconnected. The server's address, as set by a Connect() call, including any protocol, ports and or path. If rHTTP is used, this can be set directly. This is the (low level) connection state of the peer. It's internal and based on eNet's states. Applications can read the "high level" state as PhotonPeer.PeerState, which uses a different enum. Byte count of last sent operation (set during serialization). Byte count of last dispatched message (set during dispatch/deserialization). The command that's currently being dispatched. This ID is assigned by the Realtime Server upon connection. The application does not have to care about this, but it is useful in debugging. The serverTimeOffset is serverTimestamp - localTime. Used to approximate the serverTimestamp with help of localTime Count of all bytes going out (including headers) Count of all bytes coming in (including headers) Set via Connect(..., customObject) and sent in Init-Request. Sent on connect in an Init Request. Temporary cache of AppId. Used in Connect() to keep the AppId until we send the Init-Request (after the network-level (and Enet) connect). Set to timeInt, whenever SendOutgoingCommands actually checks outgoing queues to send them. Must be connected. Maximum Transfer Unit to be used for UDP+TCP If IPhotonSocket.Connected is true, this value shows if the server's address resolved as IPv6 address. You must check the socket's IsConnected state. Otherwise, this value is not initialized. Sent to server in Init-Request. Writes and "Init Request", which initializes the connection / application used server-side. Uses this.ServerAddress, this.AppId, this.PhotonToken and CustomInitData and some more values. Bytes of the init request. Called when the server's Init Response arrived. Serializes an operation into our binary messages (magic number, msg-type byte and message). Optionally encrypts. This method is mostly the same in EnetPeer, TPeer and HttpPeerBase. Also, for raw messages, we have another variant. Serializes an operation into our binary messages (magic number, msg-type byte and message). Optionally encrypts. This method is mostly the same in EnetPeer, TPeer and HttpPeerBase. Also, for raw messages, we have another variant. Returns the UDP Payload starting with Magic Number for binary protocol Checks outgoing queues for commands to send and puts them on their way. This creates one package per go in UDP. If commands are not sent, cause they didn't fit into the package that's sent. Checks the incoming queue and Dispatches received data if possible. If a Dispatch happened or not, which shows if more Dispatches might be needed. Internally uses an operation to exchange encryption keys with the server. If the op could be sent. Gets the currently used settings for the built-in network simulation. Please check the description of NetworkSimulationSet for more details. Core of the Network Simulation, which is available in Debug builds. Called by a timer in intervals. EnetPeer will set this value, so trafficstats can use it. TCP has 0 bytes per package extra See PhotonPeer value. See PhotonPeer value. See PhotonPeer value. See PhotonPeer value. Value range for a Peer's connection and initialization state, as returned by the PeerState property. While this is not the same as the StatusCode of IPhotonPeerListener.OnStatusChanged(), it directly relates to it. In most cases, it makes more sense to build a game's state on top of the OnStatusChanged() as you get changes. The peer is disconnected and can't call Operations. Call Connect(). The peer is establishing the connection: opening a socket, exchanging packages with Photon. The connection is established and now sends the application name to Photon. You set the "application name" by calling PhotonPeer.Connect(). The peer is connected and initialized (selected an application). You can now use operations. The peer is disconnecting. It sent a disconnect to the server, which will acknowledge closing the connection. These are the options that can be used as underlying transport protocol. Use UDP to connect to Photon, which allows you to send operations reliable or unreliable on demand. Use TCP to connect to Photon. A TCP-based protocol commonly supported by browsers.For WebGL games mostly. Note: No WebSocket IPhotonSocket implementation is in this Assembly. This protocol is only available in Unity exports to WebGL. A TCP-based, encrypted protocol commonly supported by browsers. For WebGL games mostly. Note: No WebSocket IPhotonSocket implementation is in this Assembly. This protocol is only available in Unity exports to WebGL. Level / amount of DebugReturn callbacks. Each debug level includes output for lower ones: OFF, ERROR, WARNING, INFO, ALL. No debug out. Only error descriptions. Warnings and errors. Information about internal workflows, warnings and errors. Most complete workflow description (but lots of debug output), info, warnings and errors. Build target framework supported by this dll. Instances of the PhotonPeer class are used to connect to a Photon server and communicate with it. A PhotonPeer instance allows communication with the Photon Server, which in turn distributes messages to other PhotonPeer clients. An application can use more than one PhotonPeer instance, which are treated as separate users on the server. Each should have its own listener instance, to separate the operations, callbacks and events. No effect anymore. Removed without replacement. This value was used to get/set the initial capacities of command-lists. These grow on demand but knowing their capacity is of very limited use. Also, various command-lists grow their capacity independent from one another. No effect anymore. Removed without replacement. This was used to skip some received (and buffered) unreliable commands, to avoid situations where the peer has aggregated a lot of (old) messages. The WarningSize was used test all message queues for congestion. Gets a local timestamp in milliseconds by calling SupportClass.GetTickCount(). See LocalMsTimestampDelegate. Where dynamic linking is available, this library will attempt to load a native Photon "Encryptor" plugin library for "Datagram Encryption". Fallback to a managed implementation. This value is always true. Obsolete and ignored. Size of CommandLog. Default is 0, no logging. Obsolete and ignored. Converts the CommandLog into a readable table-like string with summary. False if this library build contains C# Socket code. If true, you must set some type as SocketImplementation before connecting. True if the library was compiled with DEBUG setting. Version of the Native Encryptor API compiled into this assembly. Defines which PhotonEncryptorPlugin needs to be used. Target framework this dll was built for. Global toggle to avoid callbacks from native plugins. Defaults to false, meaning: "callbacks enabled". Callbacks from native code will fail on some platforms, which is why you can disable them. Can be used to remove/hide the AppId from websocket connect paths. A simplified identifier for client SDKs. Photon's APIs might modify this (as a dll can be used in more than one product). Helps debugging. For the Init-request, we shift the ClientId by one and the last bit signals a "debug" (0) or "release" build (1). Version of this library as string. Version of this library as string. A Native Socket implementation is no longer part of this DLL but delivered in a separate add-on. This value always returns false. Native Payload Encryption is no longer part of this DLL but delivered in a separate add-on. This value always returns false. Native Datagram Encryption is no longer part of this DLL but delivered in a separate add-on. This value always returns false. Enables selection of a (Photon-)serialization protocol. Used in Connect methods. Defaults to SerializationProtocol.GpBinaryV16; Optional definition of IPhotonSocket type per ConnectionProtocol. Several platforms have special Socket implementations and slightly different APIs. Customizing the SocketImplementationConfig helps to accomodate this. By default, UDP and TCP have socket implementations assigned. If a native socket plugin is available set the SocketNativeSource class as Type definition here. You only need to set the SocketImplementationConfig once, after creating a PhotonPeer and before connecting. If you switch the TransportProtocol, the correct implementation is being used. Can be used to read the IPhotonSocket implementation at runtime (before connecting). Use the SocketImplementationConfig to define which IPhotonSocket is used per ConnectionProtocol. Sets the level (and amount) of debug output provided by the library. This affects the callbacks to IPhotonPeerListener.DebugReturn. Default Level: Error. Gets the IPhotonPeerListener of this instance (set in constructor). Can be used in derived classes for Listener.DebugReturn(). Called when the client received a Disconnect Message from the server. Signals an error and provides a message to debug the case. Option to make the PhotonPeer reuse a single EventData instance for all incoming events. This reduces memory garbage. If enabled, the event provided via OnEvent(EventData photonEvent) is invalid once the callback finished. That event's content will get modified. Typically this is not a problem as events are rarely cached. Changing this value acquires the same lock that DispatchIncomingCommands() uses. Enables a deserialization optimization for incoming events. Defaults to false. When enabled, byte-arrays in incoming Photon events are deserialized into pooled ByteArraySlice instances (wrappers for byte[]). This improves the memory footprint for receiving byte-arrays in events. When used, you have to release the (pooled) ByteArraySlice instances. Adjust your handling of EventData accordingly: The ByteArraySlice.Buffer will usually be bigger than the send/received byte-array. Check the ByteArraySlice.Count and read only the actually received bytes. The Buffer is reused and not cleared. The Offset will be 0 for incoming events. Important: While the peer will acquire the ByteArraySlice and passes it to OnEvent, the game code has to call ByteArraySlice.Release() when the slice is no longer needed. Send either byte[], ArraySegment or use the ByteArraySlicePool to acquire ByteArraySlices to send. Instance of a ByteArraySlicePool. UseByteArraySlicePoolForEvents defines if this PhotonPeer is using the pool for deserialization of byte[] in Photon events. ByteArraySlice is a serializable datatype of the Photon .Net client library. It helps avoid allocations by being pooled and (optionally) used in incoming Photon events (see: UseByteArraySlicePoolForEvents). You can also use the pool to acquire ByteArraySlice instances for serialization. RaiseEvent will auto-release all ByteArraySlice instances passed in. This debug setting enables a new send-ordering for commands. Defaults to true and commands are sent in the order they are created. Set to false to use Enet ordering. Skips resending (individual) commands if their reliable sequence number is this amount larger than the highest acknowledged sequence number. This puts focus on resending commands that are older and are needed on the receiver side to dispatch commands. It queues more on the client side than on the server. Affects only reliable UDP (based on enet). Skips sending reliable and unreliable commands if their reliable sequence number is this amount larger than the highest acknowledged sequence number. This puts focus on resending commands that are older and are needed on the receiver side to dispatch commands. It queues more on the client side than on the server. Affects only reliable UDP (based on enet). Gets count of all bytes coming in (including headers, excluding UDP/TCP overhead) Gets count of all bytes going out (including headers, excluding UDP/TCP overhead) Gets the size of the dispatched event or operation-result in bytes. This value is set before OnEvent() or OnOperationResponse() is called (within DispatchIncomingCommands()). Get this value directly in OnEvent() or OnOperationResponse(). Example: void OnEvent(...) { int eventSizeInBytes = this.peer.ByteCountCurrentDispatch; //... void OnOperationResponse(...) { int resultSizeInBytes = this.peer.ByteCountCurrentDispatch; //... Returns the debug string of the event or operation-response currently being dispatched or string. Empty if none. In a release build of the lib, this will always be empty. Gets the size of the last serialized operation call in bytes. The value includes all headers for this single operation but excludes those of UDP, Enet Package Headers and TCP. Get this value immediately after calling an operation. Example: this.loadbalancingClient.OpJoinRoom("myroom"); int opjoinByteCount = this.loadbalancingClient.ByteCountLastOperation; If set, the TrafficRecorder will be used to capture all traffic. If null or not Enabled, the recorder is not being used. Release builds of this library will never record traffic for performance reasons. See ITrafficRecorder docs. Debugging option to tell the Photon Server to log all datagrams. Up to 4 resend attempts for a reliable command can be done in quick succession (after RTT+4*Variance). By default 0. Any later resend attempt will then double the time before the next resend. Max value = 4; Make sure to adjust SentCountAllowance to a slightly higher value, as more repeats will get done. This is the (low level) state of the connection to the server of a PhotonPeer. Managed internally and read-only. Don't mix this up with the StatusCode provided in IPhotonListener.OnStatusChanged(). Applications should use the StatusCode of OnStatusChanged() to track their state, as it also covers the higher level initialization between a client and Photon. This peer's ID as assigned by the server or 0 if not using UDP. Will be 0xFFFF before the client connects. Used for debugging only. This value is not useful in everyday Photon usage. Count of all currently received but not-yet-Dispatched reliable commands (events and operation results) from all channels. Count of all commands currently queued as outgoing, including all channels and reliable, unreliable. Sets a new (temporary) size of the MessageBufferPool to reuse memory where possible. The MessageBufferPool is a Queue<StreamBuffer> for performance reasons. This methods dequeues from the MessageBufferPool to get the Count equal to countOfBuffers, then it calls MessageBufferPool.TrimExcess(). New size of the pool. Clears the pool if <= 0. Gets / sets the number of channels available in UDP connections with Photon. Photon Channels are only supported for UDP. The default ChannelCount is 2. Channel IDs start with 0 and 255 is a internal channel. Enables the client so send the "encrypted" flag on secure connections. Incompatible with Server SDK 4.x. While not connected, this controls if the next connection(s) should use a per-package CRC checksum. While turned on, the client and server will add a CRC checksum to every sent package. The checksum enables both sides to detect and ignore packages that were corrupted during transfer. Corrupted packages have the same impact as lost packages: They require a re-send, adding a delay and could lead to timeouts. Building the checksum has a low processing overhead but increases integrity of sent and received data. Packages discarded due to failed CRC cecks are counted in PhotonPeer.PacketLossByCrc. Count of packages dropped due to failed CRC checks for this connection. Count of packages dropped due to wrong challenge for this connection. Gets the count of sent but not yet acknowledged commands (for UDP connections). Count of commands that got repeated (due to local repeat-timing before an ACK was received). Number of send retries before a peer is considered lost/disconnected. Default: 7. The initial timeout countdown of a command is calculated by the current roundTripTime + 4 * roundTripTimeVariance. Please note that the timeout span until a command will be resent is not constant, but based on the roundtrip time at the initial sending, which will be doubled with every failed retry. DisconnectTimeout and SentCountAllowance are competing settings: either might trigger a disconnect on the client first, depending on the values and Roundtrip Time. Caps the initial timing for repeats of reliable commands. In milliseconds. Default: 400ms. Unless acknowledged, reliable commands are repeated initially after: current roundTripTime + 4 * roundTripTimeVariance. As this value can be very high when there was exceptional lag, InitialResendTimeMax makes sure that commands get repeated several times before they may trigger a timeout. Sets the time between pings being sent automatically. They measure the roundtrip time and keep connections from closing. Default: 1000. For Photon's reliable UDP connections, pings are skipped if any reliable command was sent during the specified TimePingInterval. Any reliable command is used to update the RoundTripTime and RoundTripTimeVariance. When using TCP and WebSockets, the ping is of interest to measure the roundtrip and to keep a connection open, should nothing else With those two protocols, the ping is used to update the RoundTripTime and RoundTripTimeVariance. Time in milliseconds before any sent reliable command triggers a timeout disconnect, unless acknowledged by the receiver. Default: 10000. DisconnectTimeout is not an exact value for a timeout. The exact timing of the timeout depends on the frequency of Service() calls and the roundtrip time. Commands sent with long roundtrip-times and variance are checked less often for re-sending. DisconnectTimeout and SentCountAllowance are competing settings: either might trigger a disconnect on the client first, depending on the values and Roundtrip Time. Default: 10000 ms. Maximum setting: 65535. Setting a negative value will apply the default timeout. Approximated Environment.TickCount value of server (while connected). UDP: The server's timestamp is automatically fetched after connecting (once). This is done internally by a command which is acknowledged immediately by the server. TCP: The server's timestamp fetched with each ping but set only after connecting (once). The approximation will be off by +/- 10ms in most cases. Per peer/client and connection, the offset will be constant (unless FetchServerTimestamp() is used). A constant offset should be better to adjust for. Unfortunately there is no way to find out how much the local value differs from the original. The approximation adds RoundtripTime / 2 and uses this.LocalTimeInMilliSeconds to calculate in-between values (this property returns a new value per tick). The value sent by Photon equals Environment.TickCount in the logic layer. 0 until connected. While connected, the value is an approximation of the server's current timestamp. This setter for the (local-) timestamp delegate replaces the default Environment.TickCount with any equal function. The internally used per PhotonPeer time value. Returns the integer part of a Stopwatch ElapsedMilliseconds value. If the PhotonPeer runs continuously the ClientTime will increment from zero to Int32..::.MaxValue for approximately 24.9 days, then jump to Int32..::.MinValue (a negative number), then increment back to zero during the next 24.9 days. It is recommended to use this int only for delta times, to avoid handling the overflow. The last ConnectionTime value, when some ACKs were sent out by this client. Only applicable to UDP connections. The last ConnectionTime value, when SendOutgoingCommands actually checked outgoing queues to send them. Must be connected. Available for UDP and TCP connections. Measures the maximum milliseconds spent in PhotonSocket.Send(). Time until a reliable command is acknowledged by the server. The value measures network latency and for UDP it includes the server's ACK-delay (setting in config). In TCP, there is no ACK-delay, so the value is slightly lower (if you use default settings for Photon). RoundTripTime is updated constantly. Every reliable command will contribute a fraction to this value. This is also the approximate time until a raised event reaches another client or until an operation result is available. Changes of the roundtriptime as variance value. Gives a hint about how much the time is changing. The last measured roundtrip time for this connection. Timestamp of the last time anything (!) was received from the server (including low level Ping, ACKs, events and operation-returns). This is not the time when something was dispatched. If you enable NetworkSimulation, this value is affected as well. The server address which was used in PhotonPeer.Connect() or null (before Connect() was called). Contains the IP address of the previously resolved ServerAddress (or empty, if address wasn't resolved with the internal methods). The protocol this peer is currently connected/connecting with (or 0). This is the transport protocol to be used for next connect (see remarks). The TransportProtocol can be changed anytime but it will not change the currently active connection. Instead, TransportProtocol will be applied on next Connect. Gets or sets the network simulation "enabled" setting. Changing this value also locks this peer's sending and when setting false, the internally used queues are executed (so setting to false can take some cycles). Gets the settings for built-in Network Simulation for this peer instance while IsSimulationEnabled will enable or disable them. Once obtained, the settings can be modified by changing the properties. Defines the initial size of an internally used StreamBuffer for Tcp. The StreamBuffer is used to aggregate operation into (less) send calls, which uses less resoures. The size is not restricing the buffer and does not affect when outgoing data is actually sent. The Maximum Trasfer Unit (MTU) defines the (network-level) packet-content size that is guaranteed to arrive at the server in one piece. The Photon Protocol uses this size to split larger data into packets and for receive-buffers of packets. This value affects the Packet-content. The resulting UDP packages will have additional headers that also count against the package size (so it's bigger than this limit in the end) Setting this value while being connected is not allowed and will throw an Exception. Minimum is 576. Huge values won't speed up connections in most cases! This property is set internally, when OpExchangeKeysForEncryption successfully finished. While it's true, encryption can be used for operations. While true, the peer will not send any other commands except ACKs (used in UDP connections). Defines if Key Exchange for Encryption is done asynchronously in another thread. Indicates if sequence numbers should be randomized. Initialization array, used to modify the sequence numbers of channels. If GCM is used for DatagramEncryption. If true, the randomization-value gets added to the current value, else (CBC/old style) the randomization-value replaces the current value. Gets the byte-count of incoming "low level" messages, which are either Enet Commands or Tcp Messages. These include all headers, except those of the underlying internet protocol Udp or Tcp. Gets the byte-count of outgoing "low level" messages, which are either Enet Commands or Tcp Messages. These include all headers, except those of the underlying internet protocol Udp or Tcp. Gets a statistic of incoming and outgoing traffic, split by operation, operation-result and event. Operations are outgoing traffic, results and events are incoming. Includes the per-command header sizes (Udp: Enet Command Header or Tcp: Message Header). Returns the count of milliseconds the stats are enabled for tracking. Enables or disables collection of statistics in TrafficStatsIncoming, TrafficStatsOutgoing and TrafficstatsGameLevel. Setting this to true, also starts the stopwatch to measure the timespan the stats are collected. Enables the traffic statistics of a peer: TrafficStatsIncoming, TrafficStatsOutgoing and TrafficstatsGameLevel (nothing else). Default value: false (disabled). Creates new instances of TrafficStats and starts a new timer for those. Creates new TrafficStats values and the related Stopwatch instance. To be called when the peer is created / reset. Returns a string of the most interesting connection statistics. When you have issues on the client side, these might contain hints about the issue's cause. If true, Incoming and Outgoing low-level stats are included in the string. Stats as string. Implements the message-protocol, based on the underlying network protocol (udp, tcp, http). Setter for the Payload Encryptor type. Used for next connection. If null, the PhotonPeer will create a DiffieHellmanCryptoProvider, which is the default. This is only needed in rare cases, where using native payload encryption makes sense. Get in touch about this, if you got questions: developer@photonengine.com PayloadEncryption Secret. Message payloads get encrypted with it individually and on demand. Setter for the Datagram Encryptor type. Used at next connect. If null, the PhotonPeer will create a default datagram encryptor instance. The datagram encryptor used for the current connection. Applied internally in InitDatagramEncryption. Count of unreliable commands being discarded in case this client already dispatched a command that was newer (higher sequence number). Set per dispatch in DispatchIncomingCommands to: commandUnreliableSequenceNumber - channel.incomingUnreliableSequenceNumber. Indicates how big the (sequence)gap is, compared to the last dispatched unreliable command. Creates a new PhotonPeer with specified transport protocol (without a IPhotonPeerListener). Make sure to set the Listener, before using the peer. Creates a new PhotonPeer instance to communicate with Photon and selects the transport protocol. We recommend UDP. a IPhotonPeerListener implementation Protocol to use to connect to Photon. Starts connecting to the given Photon server. Non-blocking. Connecting to the Photon server is done asynchronous. Unless an error happens right away (and this returns false), wait for the call of IPhotonPeerListener.OnStatusChanged. Address of a Photon server as IP:port or hostname. WebSocket connections must contain a scheme (ws:// or wss://). The ID of the app to use. Typically this is a guid (for the Photon Cloud). Max 32 characters. Optional custom data to be used by server during peer creation. If used for authentication, the server is able to reject a client without creating a peer. Must be a serializable data type of Photon. Custom data to send to the server in the Init request. Might be used to identify a client / user. True if a connection attempt will be made. False if some error could be detected early-on. Starts connecting to the given Photon server. Non-blocking. Connecting to the Photon server is done asynchronous. Unless an error happens right away (and this returns false), wait for the call of IPhotonPeerListener.OnStatusChanged. Address of a Photon server as IP:port or hostname. WebSocket connections must contain a scheme (ws:// or wss://). Optional address of a proxy server. Only used by WebSocket connections. Set null to use none. The ID of the app to use. Typically this is a guid (for the Photon Cloud). Max 32 characters. Optional Photon token data to be used by server during peer creation. If used for authentication, the server is able to reject a client without creating a peer. Must be of type string or byte[] (as provided by server). Custom data to send to the server in the Init request. Might be used to identify a client / user. True if a connection attempt will be made. False if some error could be detected early-on. This method initiates a mutual disconnect between this client and the server. Calling this method does not immediately close a connection. Disconnect lets the server know that this client is no longer listening. For the server, this is a much faster way to detect that the client is gone but it requires the client to send a few final messages. On completion, OnStatusChanged is called with the StatusCode.Disconnect. If the client is disconnected already or the connection thread is stopped, then there is no callback. The default server logic will leave any joined game and trigger the respective event. This method immediately closes a connection (pure client side) and ends related listening Threads. Unlike Disconnect, this method will simply stop to listen to the server. Udp connections will timeout. If the connections was open, this will trigger a callback to OnStatusChanged with code StatusCode.Disconnect. This will fetch the server's timestamp and update the approximation for property ServerTimeInMilliseconds. The server time approximation will NOT become more accurate by repeated calls. Accuracy currently depends on a single roundtrip which is done as fast as possible. The command used for this is immediately acknowledged by the server. This makes sure the roundtrip time is low and the timestamp + rountriptime / 2 is close to the original value. This method creates a public key for this client and exchanges it with the server. Encryption is not instantly available but calls OnStatusChanged when it finishes. Check for StatusCode EncryptionEstablished and EncryptionFailedToEstablish. Calling this method sets IsEncryptionAvailable to false. This method must be called before the "encrypt" parameter of OpCustom can be used. If operation could be enqueued for sending Initializes Datagram Encryption. Optionally, the EncryptorType is being used, if set. Secret used to cipher udp packets. Secret used for authentication of udp packets. Sets if enet Sequence Numbers will be randomized or not. Preferably should be true. Sets if the chaining mode should be CBC (false, default) or GCM (true). GCM mode is only available with a native encryption plugin. Photon's Payload Encryption secret may be set by a response from the server. The secret in form of a byte[]. This method excutes DispatchIncomingCommands and SendOutgoingCommands in your application Thread-context. The Photon client libraries are designed to fit easily into a game or application. The application is in control of the context (thread) in which incoming events and responses are executed and has full control of the creation of UDP/TCP packages. Sending packages and dispatching received messages are two separate tasks. Service combines them into one method at the cost of control. It calls DispatchIncomingCommands and SendOutgoingCommands. Call this method regularly (2..20 times a second). This will Dispatch ANY remaining buffered responses and events AND will send queued outgoing commands. Fewer calls might be more effective if a device cannot send many packets per second, as multiple operations might be combined into one package. You could replace Service by: while (DispatchIncomingCommands()); //Dispatch until everything is Dispatched... SendOutgoingCommands(); //Send a UDP/TCP package with outgoing messages Creates and sends a UDP/TCP package with outgoing commands (operations and acknowledgements). Also called by Service(). As the Photon library does not create any UDP/TCP packages by itself. Instead, the application fully controls how many packages are sent and when. A tradeoff, an application will lose connection, if it is no longer calling SendOutgoingCommands or Service. If multiple operations and ACKs are waiting to be sent, they will be aggregated into one package. The package fills in this order: ACKs for received commands A "Ping" - only if no reliable data was sent for a while Starting with the lowest Channel-Nr: Reliable Commands in channel Unreliable Commands in channel This gives a higher priority to lower channels. A longer interval between sends will lower the overhead per sent operation but increase the internal delay (which adds "lag"). Call this 2..20 times per second (depending on your target platform). The if commands are not yet sent. Udp limits it's package size, Tcp doesnt. Dispatching received messages (commands), causes callbacks for events, responses and state changes within a IPhotonPeerListener. DispatchIncomingCommands only executes a single received command per call. If a command was dispatched, the return value is true and the method should be called again. This method is called by Service() until currently available commands are dispatched. In general, this method should be called until it returns false. In a few cases, it might make sense to pause dispatching (if a certain state is reached and the app needs to load data, before it should handle new events). The callbacks to the peer's IPhotonPeerListener are executed in the same thread that is calling DispatchIncomingCommands. This makes things easier in a game loop: Event execution won't clash with painting objects or the game logic. Prepares your operation (code and parameters) to be sent to the Photon Server with specified SendOptions. This method serializes and enqueues the operation right away while the actual sending happens later. To be able to aggregate operations/messages, the Photon client sends packages only when you call SendOutgoingCommands(). The sendOptions specify how the operation gets sent exactly. Keep in mind that some transport protocols don't support unreliable or unsequenced transport. In that case, the sendOptions might be ignored. The operationCode must be known by the server's logic or won't be processed. In almost all cases, sending an operation will result in a OperationResponse (see: IPhotonPeerListener.OnOperationResponse). Operations are handled by their byte\-typed code. The codes are defined in the Realtime API (a.k.a. LoadBalancing API). Containing parameters as key\-value pair. The key is byte\-typed, while the value is any serializable datatype. Wraps up DeliveryMode (reliability), Encryption and Channel values for sending. If operation could be enqueued for sending. Registers new types/classes for de/serialization and the fitting methods to call for this type. SerializeMethod and DeserializeMethod are complementary: Feed the product of serializeMethod to the constructor, to get a comparable instance of the object. After registering a Type, it can be used in events and operations and will be serialized like built-in types. Type (class) to register. A byte-code used as shortcut during transfer of this Type. Method delegate to create a byte[] from a customType instance. Method delegate to create instances of customType's from byte[]. If the Type was registered successfully. Container for an Operation request, which is a code and parameters. On the lowest level, Photon only allows byte-typed keys for operation parameters. The values of each such parameter can be any serializable datatype: byte, int, hashtable and many more. Byte-typed code for an operation - the short identifier for the server's method to call. The parameters of the operation - each identified by a byte-typed code in Photon. Contains the server's response for an operation called by this peer. The indexer of this class actually provides access to the Parameters Dictionary. The OperationCode defines the type of operation called on Photon and in turn also the Parameters that are set in the request. Those are provided as Dictionary with byte-keys. There are pre-defined constants for various codes defined in the LoadBalancing application. Check: OperationCode, ParameterCode, etc. An operation's request is summarized by the ReturnCode: a short typed code for "Ok" or some different result. The code's meaning is specific per operation. An optional DebugMessage can be provided to simplify debugging. Each call of an operation gets an ID, called the "invocID". This can be matched to the IDs returned with any operation calls. This way, an application could track if a certain OpRaiseEvent call was successful. The code for the operation called initially (by this peer). Use enums or constants to be able to handle those codes, like OperationCode does. A code that "summarizes" the operation's success or failure. Specific per operation. 0 usually means "ok". An optional string sent by the server to provide readable feedback in error-cases. Might be null. A Dictionary of values returned by an operation, using byte-typed keys per value. Alternative access to the Parameters, which wraps up a TryGetValue() call on the Parameters Dictionary. The byte-code of a returned value. The value returned by the server, or null if the key does not exist in Parameters. ToString() override. Relatively short output of OpCode and returnCode. Extensive output of operation results. To be used in debug situations only, as it returns a string for each value. A Photon Event consists of a Code value and a Parameters Dictionary with the event's content (if any). The indexer of this class provides access to the values in Parameters. It wraps the null check for Parameters and uses TryGetValue() for the provided key. Photon servers use events to send information which is not triggered by a client's operation requests (those get responses). The Realtime API allows you to send custom events with any Code and content via OpRaiseEvent. The event code identifies the type of event. The Parameters of an event is a Dictionary<byte, object>. Access to the Parameters of a Photon-defined event. Custom Events only use Code, Sender and CustomData. The key byte-code of a Photon event value. The Parameters value, or null if the key does not exist in Parameters. Defines the event key containing the Sender of the event. Defaults to Sender key of Realtime API events (RaiseEvent): 254. Can be set to Chat API's ChatParameterCode.Sender: 5. Accesses the Sender of the event via the indexer and SenderKey. The result is cached. Accesses this event's Parameters[CustomDataKey], which may be null. In that case, this returns 0 (identifying the server as sender). Defines the event key containing the Custom Data of the event. Defaults to Data key of Realtime API events (RaiseEvent): 245. Can be set to any other value on demand. Accesses the Custom Data of the event via the indexer and CustomDataKey. The result is cached. Accesses this event's Parameters[CustomDataKey], which may be null. ToString() override. Short output of "Event" and it's Code. Extensive output of the event content. To be used in debug situations only, as it returns a string for each value. Type of serialization methods to add custom type support. Use PhotonPeer.ReisterType() to register new types with serialization and deserialization methods. The method will get objects passed that were registered with it in RegisterType(). Return a byte[] that resembles the object passed in. The framework will surround it with length and type info, so don't include it. Serialization method delegate. StreamBuffer based custom serialization methods must use this form. Type of deserialization methods to add custom type support. Use PhotonPeer.RegisterType() to register new types with serialization and deserialization methods. The framwork passes in the data it got by the associated SerializeMethod. The type code and length are stripped and applied before a DeserializeMethod is called. Return a object of the type that was associated with this method through RegisterType(). Deserialization method delegate. StreamBuffer based custom deserialization methods must use this form. Provides tools for the Exit Games Protocol Serialize creates a byte-array from the given object and returns it. The object to serialize The serialized byte-array Deserialize returns an object reassembled from the given byte-array. The byte-array to be Deserialized The Deserialized object Serializes a short typed value into a byte-array (target) starting at the also given targetOffset. The altered offset is known to the caller, because it is given via a referenced parameter. The short value to be serialized The byte-array to serialize the short to The offset in the byte-array Serializes an int typed value into a byte-array (target) starting at the also given targetOffset. The altered offset is known to the caller, because it is given via a referenced parameter. The int value to be serialized The byte-array to serialize the short to The offset in the byte-array Serializes an float typed value into a byte-array (target) starting at the also given targetOffset. The altered offset is known to the caller, because it is given via a referenced parameter. The float value to be serialized The byte-array to serialize the short to The offset in the byte-array Deserialize fills the given int typed value with the given byte-array (source) starting at the also given offset. The result is placed in a variable (value). There is no need to return a value because the parameter value is given by reference. The altered offset is this way also known to the caller. The int value to deserialize into The byte-array to deserialize from The offset in the byte-array Deserialize fills the given short typed value with the given byte-array (source) starting at the also given offset. The result is placed in a variable (value). There is no need to return a value because the parameter value is given by reference. The altered offset is this way also known to the caller. The short value to deserialized into The byte-array to deserialize from The offset in the byte-array Deserialize fills the given float typed value with the given byte-array (source) starting at the also given offset. The result is placed in a variable (value). There is no need to return a value because the parameter value is given by reference. The altered offset is this way also known to the caller. The float value to deserialize The byte-array to deserialize from The offset in the byte-array Exit Games GpBinaryV16 protocol implementation The gp type. Unkown type. An array of objects. This type is new in version 1.5. A boolean Value. A byte value. An array of bytes. An array of objects. A 16-bit integer value. A 32-bit floating-point value. This type is new in version 1.5. A dictionary This type is new in version 1.6. A 64-bit floating-point value. This type is new in version 1.5. A Hashtable. A 32-bit integer value. An array of 32-bit integer values. A 64-bit integer value. A string value. An array of string values. A custom type. 0x63 Null value don't have types. Calls the correct serialization method for the passed object. DeserializeInteger returns an Integer typed value from the given stream. Exception type for de/serialization issues. Used in Protocol 1.8. Constructor for the exception. Unkown. GpType: 0. Boolean. GpType: 2. See: BooleanFalse, BooleanTrue. Byte. GpType: 3. Short. GpType: 4. 32-bit floating-point value. GpType: 5. 64-bit floating-point value. GpType: 6. String. GpType: 7. Null value don't have types. GpType: 8. CompressedInt. GpType: 9. CompressedLong. GpType: 10. Int1. GpType: 11. Int1_. GpType: 12. Int2. GpType: 13. Int2_. GpType: 14. L1. GpType: 15. L1_. GpType: 16. L2. GpType: 17. L2_. GpType: 18. Custom Type. GpType: 19. Custom Type Slim. GpType: 128 (0x80) and up. Dictionary. GpType: 20. Hashtable. GpType: 21. ObjectArray. GpType: 23. OperationRequest. GpType: 24. OperationResponse. GpType: 25. EventData. GpType: 26. Boolean False. GpType: 27. Boolean True. GpType: 28. ShortZero. GpType: 29. IntZero. GpType: 30. LongZero. GpType: 3. FloatZero. GpType: 32. DoubleZero. GpType: 33. ByteZero. GpType: 34. Array for nested Arrays. GpType: 64 (0x40). Element count and type follows. Writes integers as compressed. Either directly as zigzag-encoded or (when a type is written for this value) it can use an optimized sub-type. Enum of the three options for reliability and sequencing in Photon's reliable-UDP. The operation/message gets sent just once without acknowledgement or repeat. The sequence (order) of messages is guaranteed. The operation/message asks for an acknowledgment. It's resent until an ACK arrived. The sequence (order) of messages is guaranteed. The operation/message gets sent once (unreliable) and might arrive out of order. Best for your own sequencing (e.g. for streams). The operation/message asks for an acknowledgment. It's resent until an ACK arrived and might arrive out of order. Best for your own sequencing (e.g. for streams). Wraps up DeliveryMode, Encryption and Channel values for sending operations and messages. Default SendOptions instance for reliable sending. Default SendOptions instance for unreliable sending. Chose the DeliveryMode for this operation/message. Defaults to Unreliable. If true the operation/message gets encrypted before it's sent. Defaults to false. Before encryption can be used, it must be established. Check PhotonPeer.IsEncryptionAvailable is true. The Enet channel to send in. Defaults to 0. Channels in Photon relate to "message channels". Each channel is a sequence of messages. Sets the DeliveryMode either to true: Reliable or false: Unreliable, overriding any current value. Use this to conveniently select reliable/unreliable delivery. Encapsulates the network i/o functionality for the realtime library. used by PhotonPeer* Endless loop, run in Receive Thread. Internal class to encapsulate the network i/o functionality for the realtime libary. used by PhotonPeer* Encapsulates the network i/o functionality for the realtime library. used by PhotonPeer* Endless loop, run in Receive Thread. Internal class to encapsulate the network i/o functionality for the realtime libary. used by PhotonPeer* Allocates a new byte[] that is the exact used length. Use GetBuffer for nonalloc operations. Allocates a new byte[] that is the exact used length. Use GetBuffer for nonalloc operations. The bytes between Position and Length are copied to the beginning of the buffer. Length decreased by Position. Position set to 0. Brings StreamBuffer to the state as after writing of 'length' bytes. Returned buffer and offset can be used to actually fill "written" segment with data. Remaining bytes in this StreamBuffer. Returns 0 if len - pos is less than 0. Sets stream length. If current position is greater than specified value, it's set to the value. SetLength(0) resets the stream to initial state but preserves underlying byte[] buffer. Guarantees that the buffer is at least neededSize bytes. Contains several (more or less) useful static methods, mostly used for debugging. 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). Fraction of the current time in Milliseconds (this is not a proper datetime timestamp). 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. The function to call. Must return true, if it should be called again. Returning false ends the thread. Milliseconds to sleep between calls of myThread. Default: 100ms. An optional name for the task to help debugging. Null or empty won't set the thread.Name. Calls Abort on the thread with the given id (= index of the thread list) The resulting ThreadAbortException is caught and discarded. The unique ID of the thread. True if the thread is canceled and false otherwise, e.g. if the thread with the given ID does not exist. Calls Abort on all threads that were started via StartBackgroundCalls. The resulting ThreadAbortException is caught and discarded. True if any thread got aborted. Writes the exception's stack trace to the received stream. Exception to obtain information from. Output sream used to write to. Writes the exception's stack trace to the received stream. Writes to: System.Diagnostics.Debug. Exception to obtain information from. This method returns a string, representing the content of the given IDictionary. Returns "null" if parameter is null. IDictionary to return as string. Converts a byte-array to string (useful as debugging output). Uses BitConverter.ToString(list) internally after a null-check of list. Byte-array to convert to string. List of bytes as string. Class to wrap static access to the random.Next() call in a thread safe manner. An Attribute named "Preserve" tells Unity to not strip the code. TCP "Package" header: 7 bytes TCP "Message" header: 2 bytes TCP header combined: 9 bytes Defines if the (TCP) socket implementation needs to do "framing". The WebSocket protocol (e.g.) includes framing, so when that is used, we set DoFraming to false. Checks the incoming queue and Dispatches received data if possible. Returns if a Dispatch happened or not, which shows if more Dispatches might be needed. gathers commands from all (out)queues until udp-packet is full and sends it! Sends a ping in intervals to keep connection alive (server will timeout connection if nothing is sent). Always false in this case (local queues are ignored. true would be: "call again to send remaining data"). enqueues serialized operations to be sent as tcp stream / package Sends a ping and modifies this.lastPingResult to avoid another ping for a while. reads incoming tcp-packages to create and queue incoming commands* Only in use as long as PhotonPeer.TrafficStatsEnabled = true; Gets sum of outgoing operations in bytes. Gets count of outgoing operations. Gets sum of byte-cost of incoming operation-results. Gets count of incoming operation-results. Gets sum of byte-cost of incoming events. Gets count of incoming events. Gets longest time it took to complete a call to OnOperationResponse (in your code). If such a callback takes long, it will lower the network performance and might lead to timeouts. Gets OperationCode that causes the LongestOpResponseCallback. See that description. Gets longest time a call to OnEvent (in your code) took. If such a callback takes long, it will lower the network performance and might lead to timeouts. Gets EventCode that caused the LongestEventCallback. See that description. Gets longest time between subsequent calls to DispatchIncomgingCommands in milliseconds. Note: This is not a crucial timing for the networking. Long gaps just add "local lag" to events that are available already. Gets longest time between subsequent calls to SendOutgoingCommands in milliseconds. Note: This is a crucial value for network stability. Without calling SendOutgoingCommands, nothing will be sent to the server, who might time out this client. Gets number of calls of DispatchIncomingCommands. Gets number of calls of DispatchIncomingCommands. Gets number of calls of SendOutgoingCommands. Gets sum of byte-cost of all "logic level" messages. Gets sum of counted "logic level" messages. Gets sum of byte-cost of all incoming "logic level" messages. Gets sum of counted incoming "logic level" messages. Gets sum of byte-cost of all outgoing "logic level" messages (= OperationByteCount). Gets sum of counted outgoing "logic level" messages (= OperationCount). Resets the values that can be maxed out, like LongestDeltaBetweenDispatching. See remarks. Set to 0: LongestDeltaBetweenDispatching, LongestDeltaBetweenSending, LongestEventCallback, LongestEventCallbackCode, LongestOpResponseCallback, LongestOpResponseCallbackOpCode. Also resets internal values: timeOfLastDispatchCall and timeOfLastSendCall (so intervals are tracked correctly). Gets the byte-size of per-package headers. Counts commands created/received by this client, ignoring repeats (out command count can be higher due to repeats). Gets count of bytes as traffic, excluding UDP/TCP headers (42 bytes / x bytes). Timestamp of the last incoming ACK that has been read (every PhotonPeer.TimePingInterval milliseconds this client sends a PING which must be ACKd). Timestamp of last incoming reliable command (every second we expect a PING).