Photon C++ Client API  4.1.15.3
Public Member Functions | Static Public Member Functions | List of all members
Client Class Reference
Inheritance diagram for Client:
Inheritance graph
[legend]
Collaboration diagram for Client:
Collaboration graph
[legend]

Public Member Functions

 Client (Listener &listener, const Common::JString &applicationID, const Common::JString &appVersion, nByte connectionProtocol=Photon::ConnectionProtocol::DEFAULT)
 
virtual ~Client (void)
 
virtual bool connect (const AuthenticationValues &authenticationValues=AuthenticationValues(), const Common::JString &nameServerAddress=M_NAMESERVER)
 
virtual void disconnect (void)
 
virtual void service (bool dispatchIncomingCommands=true)
 
virtual void serviceBasic (void)
 
virtual bool sendOutgoingCommands (void)
 
virtual bool sendAcksOnly (void)
 
virtual bool dispatchIncomingCommands (void)
 
virtual void fetchServerTimestamp (void)
 
virtual void resetTrafficStats (void)
 
virtual void resetTrafficStatsMaximumCounters (void)
 
virtual Common::JString vitalStatsToString (bool all) const
 
virtual bool opSubscribe (const Common::JVector< Common::JString > &channels, int messagesFromHistory=0)
 
virtual bool opUnsubscribe (const Common::JVector< Common::JString > &channels)
 
template<typename Ftype >
bool opPublishMessage (const Common::JString &channelName, const Ftype &message)
 
template<typename Ftype >
bool opPublishMessage (const Common::JString &channelName, const Ftype pMessageArray, typename Common::Helpers::ArrayLengthType< Ftype >::type arrSize)
 
template<typename Ftype >
bool opPublishMessage (const Common::JString &channelName, const Ftype pMessageArray, const short *pArrSizes)
 
template<typename Ftype >
bool opSendPrivateMessage (const Common::JString &userName, const Ftype &message, bool encrypt=false)
 
template<typename Ftype >
bool opSendPrivateMessage (const Common::JString &userName, const Ftype pMessageArray, typename Common::Helpers::ArrayLengthType< Ftype >::type arrSize, bool encrypt=false)
 
template<typename Ftype >
bool opSendPrivateMessage (const Common::JString &userName, const Ftype pMessageArray, const short *pArrSizes, bool encrypt=false)
 
virtual bool opSetOnlineStatus (int status)
 
template<typename Ftype >
bool opSetOnlineStatus (int status, const Ftype &message)
 
template<typename Ftype >
bool opSetOnlineStatus (int status, const Ftype pMessageArray, typename Common::Helpers::ArrayLengthType< Ftype >::type arrSize)
 
template<typename Ftype >
bool opSetOnlineStatus (int status, const Ftype pMessageArray, const short *pArrSizes)
 
virtual bool opAddFriends (const Common::JVector< Common::JString > &userIDs)
 
virtual bool opRemoveFriends (const Common::JVector< Common::JString > &userIDs)
 
int getServerTimeOffset (void) const
 
int getServerTime (void) const
 
int getBytesOut (void) const
 
int getBytesIn (void) const
 
int getByteCountCurrentDispatch (void) const
 
int getByteCountLastOperation (void) const
 
int getSentCountAllowance (void) const
 
void setSentCountAllowance (int sentCountAllowance)
 
int getTimePingInterval (void) const
 
void setTimePingInterval (int timePingInterval)
 
int getRoundTripTime (void) const
 
int getRoundTripTimeVariance (void) const
 
int getTimestampOfLastSocketReceive (void) const
 
int getDebugOutputLevel (void) const
 
bool setDebugOutputLevel (int debugLevel)
 
const Common::LogFormatOptionsgetLogFormatOptions (void) const
 
void setLogFormatOptions (const Common::LogFormatOptions &formatOptions)
 
int getIncomingReliableCommandsCount (void) const
 
short getPeerID (void) const
 
int getDisconnectTimeout (void) const
 
void setDisconnectTimeout (int disconnectTimeout)
 
int getQueuedIncomingCommands (void) const
 
int getQueuedOutgoingCommands (void) const
 
bool getIsPayloadEncryptionAvailable (void) const
 
int getResentReliableCommands (void) const
 
int getLimitOfUnreliableCommands (void) const
 
void setLimitOfUnreliableCommands (int value)
 
bool getCRCEnabled (void) const
 
void setCRCEnabled (bool crcEnabled)
 
int getPacketLossByCRC (void) const
 
bool getTrafficStatsEnabled (void) const
 
void setTrafficStatsEnabled (bool trafficStatsEnabled)
 
int getTrafficStatsElapsedMs (void) const
 
const Photon::TrafficStatsgetTrafficStatsIncoming (void) const
 
const Photon::TrafficStatsgetTrafficStatsOutgoing (void) const
 
const Photon::TrafficStatsGameLevelgetTrafficStatsGameLevel (void) const
 
nByte getQuickResendAttempts (void) const
 
void setQuickResendAttempts (nByte quickResendAttempts)
 
nByte getChannelCountUserChannels (void) const
 
const Common::JStringgetUserID (void) const
 
int getState (void) const
 
int getDisconnectedCause (void) const
 
const Common::JStringgetRegion (void) const
 
void setRegion (const Common::JString &region)
 
const Common::JVector< Channel * > & getPublicChannels (void) const
 
const Common::JVector< Channel * > & getPrivateChannels (void) const
 
const ChannelgetPublicChannel (const Common::JString &channelName) const
 
const ChannelgetPrivateChannel (const Common::JString &userName) const
 

Static Public Member Functions

static short getPeerCount (void)
 

Detailed Description

Central class of the Photon Chat API to connect, handle channels and messages.

This class must be instantiated with a Chat::Listener instance to get the callbacks and with application id that is setup as Photon Chat application. Integrate it into your game loop by calling service() regularly. Call connect() with an Name Server address. Note: Connect covers multiple messages between this client and the servers. A short workflow will connect you to a Chat server. Each Chat::Client resembles a user in chat. Before you send messages in any public channel, that channel must be subscribed. Private channels represent private chats and created automatically on private message sent or received. getPublicChannels() returns list of subscribed channels, containing messages and senders. getPrivateChannels() contains all incoming and sent private messages.

Constructor & Destructor Documentation

§ Client()

Client ( Listener listener,
const Common::JString applicationID,
const Common::JString appVersion,
nByte  connectionProtocol = Photon::ConnectionProtocol::DEFAULT 
)

Constructor.

Parameters
listenerpointer to the application's implementation of the Chat:Listener callback interface.
applicationIDPhoton Chat application id
appVersionPhoton Chat application version
connectionProtocolconnection protocol

§ ~Client()

~Client ( void  )
virtual

Destructor.

Member Function Documentation

§ connect()

bool connect ( const AuthenticationValues authenticationValues = AuthenticationValues(),
const Common::JString nameServerAddress = M_NAMESERVER 
)
virtual

Initiates a connection to the Photon name server. After a successful connection the client automatically connects to a chat front end server and goes to ConnectedToFrontEnd state. After that the client can subscribe to channels and send and receive messages.

Parameters
authenticationValuesa user's authentication values used during connect for Custom Authentication with Photon.
nameServerAddressused to specify a name server address different from the public Photon Cloud name server

§ disconnect()

void disconnect ( void  )
virtual

Disconnects from servers.

§ service()

void service ( bool  dispatchIncomingCommands = true)
virtual

This function executes the PhotonPeer internal processes. Call this regularly!

This function is meant to be called frequently, like once per game loop. It handles the internal calls for keeping the PhotonPeer communication alive, and will take care of sending all local outgoing acknowledgements and messages, as well as dispatching incoming messages to the application and firing the corresponding callbacks. Internally service() calls the following functions:

  1. serviceBasic()
  2. dispatchIncomingCommands() (called withing a loop until all incoming commands have been dispatched.)
  3. sendOutgoingCommands() (called withing a loop until everything queued for sending has been sent.)

service() is provided for convenience. If you need to tweak the performance, you can ignore service() and call its three subfunctions directly with individual time intervals, to gain more control over the internal communication process. For instance, calling sendOutgoingCommands() more rarely will result in less packets to be generated, as more commands will be accumulated into a single packet. See sendOutgoingCommands() for more information on efficiency.

For situations where you want to keep the connection alive, but can't process incoming messages (e.g. when loading a level), you can temporarily pass false for dispatchIncomingCommands to skip the calls to dispatchIncomingCommands(). Incoming commands will be stored in the incoming queue until they are dispatched again.

Parameters
dispatchIncomingCommandstrue = dispatchIncomingCommands() will be called; false = dispatchIncomingCommands() won't be called, default is true

§ serviceBasic()

void serviceBasic ( void  )
virtual

This function takes care of exchanging data with the system's network layer.

You only need to call this function in case you choose not to use service(), but call the subfunctions of service() directly. Please see the documentation of service() for more information.

serviceBasic() is called from within service(). If you decide not to use service(), then serviceBasic() needs to be called frequently, like once per game loop.

See also
service()

§ sendOutgoingCommands()

bool sendOutgoingCommands ( void  )
virtual

This function initiates the transmission of outgoing commands.

Any Photon function that generates messages will store these messages as a "command" in an outgoing queue for later transmission. Commands can either be explicitly created operations generated for example by opCustom() or internally generated messages like acknowledgements for reliable messages from other players. sendOutgoingCommands() will initiate the data transmission by passing the outgoing commands to the system's sockets for immediate transmission.

In case of UDP sendOutgoingCommands() will also split the commands into multiple packets if needed and/of aggregate multiple commands together into one packet, if possible. Because of the latter calling sendOutgoingcommands() more rarely will result in less overhead, as there will be fewer packets for the clients to be sent and processed. The underlying platform can also limit the frequency in which outgoing packets can be sent and received. The downside of lower sending frequencies is a higher latency, until messages are exchanged and acknowledged, which may lead to a jerky gameplay.

To help you keeping track of the incoming and outgoing queues at development time and adjust your sending frequency, there will be a warning message sent to your debugReturn callback if a queue has exceeded the warning threshold.

Note
While service() is calling serviceBasic() implicitly, you will have to regularly call it yourself explictly , when you use sendOutgoingCommands() and dispatchIncomingCommands() directly instead.

Usually you don't have to call sendOutgoingCommands() this explicitly, as this is done within service().

See also
service()

§ sendAcksOnly()

bool sendAcksOnly ( void  )
virtual

Sends only ACKs (UDP) or Ping (TCP) instead of queued outgoing commands. Useful to pause sending actual data.

Note
While service() is calling serviceBasic() implicitly, you will have to regularly call it yourself explictly , when you use sendAcksOnly() and dispatchIncomingCommands() instead.

§ dispatchIncomingCommands()

bool dispatchIncomingCommands ( void  )
virtual

Checks for incoming commands waiting in the queue, and dispatches a single command to the application.

Dispatching means, that if the command is an operation response or an event, the appropriate callback function will be called). dispatchIncomingCommands() will also take care of generating and queuing acknowledgments for incoming reliable commands. Please note that this function will only dispatch one command per all. If you want to dispatch every single command which is waiting in the queue, call dipatchIncomingCommands() within a while loop, until its return code is false.

Note
While service() is calling serviceBasic() implicitly, you will have to regularly call it yourself explictly, when you use sendOutgoingCommands() and dispatchIncomingCommands() directly instead.
Returns
true if it has successfully dispatched a command, false otherwise (for example, when there has not been any command left in the queue, waiting for dispatching).
See also
service()

§ fetchServerTimestamp()

void fetchServerTimestamp ( void  )
virtual

This will fetch the server's timestamp and update the approximation for getServerTime() and getServerTimeOffset().

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 roundtriptime is low and the timestamp + roundtriptime / 2 is close to the original value.

§ resetTrafficStats()

void resetTrafficStats ( void  )
virtual

Creates new instances of TrafficStats and starts a new timer for those.

§ resetTrafficStatsMaximumCounters()

void resetTrafficStatsMaximumCounters ( void  )
virtual

Resets traffic stats values that can be maxed out.

§ vitalStatsToString()

Common::JString vitalStatsToString ( bool  all) const
virtual

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.

Parameters
allIf true, Incoming and Outgoing low-level stats are included in the string.
Returns
stats as a string.

§ opSubscribe()

bool opSubscribe ( const Common::JVector< Common::JString > &  channels,
int  messagesFromHistory = 0 
)
virtual

Sends a request to subscribe the client to the specified channels, optionally fetching messages newer than a specific ID.

Parameters
channelslist of channels to subscribe to.
messagesFromHistory0: no history. 1 and higher: number of messages in history. -1: all history.
Returns
true if request sent

§ opUnsubscribe()

bool opUnsubscribe ( const Common::JVector< Common::JString > &  channels)
virtual

Unsubscribes the client from a list of channels.

The client will remove these channels from the PublicChannels dictionary immediately, if it could send the operation.

Parameters
channelslist of channels to unsubscribe from.
Returns
true if request sent and channels removed

§ opPublishMessage() [1/3]

template< typename Ftype > bool opPublishMessage ( const Common::JString channelName,
const Ftype &  message 
)

Sends a message to the specified public channel.

Parameters
channelNamechannel name
messagemessage to send
Returns
false in case of an error, true otherwise

§ opPublishMessage() [2/3]

template< typename Ftype > bool opPublishMessage ( const Common::JString channelName,
const Ftype  pMessageArray,
typename Common::Helpers::ArrayLengthType< Ftype >::type  arrSize 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
channelNamechannel name
pMessageArraymessage to send
arrSizethe number of elements in pParameterArray

§ opPublishMessage() [3/3]

template< typename Ftype > bool opPublishMessage ( const Common::JString channelName,
const Ftype  pMessageArray,
const short *  pArrSizes 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
channelNamechannel name
pMessageArraymessage to send
pArrSizesan array holding the number of elements for each dimension of pParameterArray

§ opSendPrivateMessage() [1/2]

template< typename Ftype > bool opSendPrivateMessage ( const Common::JString userName,
const Ftype  pMessageArray,
typename Common::Helpers::ArrayLengthType< Ftype >::type  arrSize,
bool  encrypt = false 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
userNameuser name
pMessageArraymessage to send
arrSizethe number of elements in pParameterArray
encrypttrue to send the message encrypted, false (default) to send it unencrypted

§ opSendPrivateMessage() [2/2]

template< typename Ftype > bool opSendPrivateMessage ( const Common::JString userName,
const Ftype  pMessageArray,
const short *  pArrSizes,
bool  encrypt = false 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
userNameuser name
pMessageArraymessage to send
pArrSizesan array holding the number of elements for each dimension of pParameterArray
encrypttrue to send the message encrypted, false (default) to send it unencrypted

§ opSetOnlineStatus() [1/3]

bool opSetOnlineStatus ( int  status)
virtual

Sets the user's status (pre-defined or custom) and a status message.

The predefined status values can be found in namespace UserStatus. States UserStatus::INVISIBLE and UserStatus::OFFLINE will make you offline for everyone and send no message.

Parameters
statuspredefined states are in namespace UserStatus. Other values can be used at will
Returns
false in case of an error, true otherwise

§ opSetOnlineStatus() [2/3]

template< typename Ftype > bool opSetOnlineStatus ( int  status,
const Ftype  pMessageArray,
typename Common::Helpers::ArrayLengthType< Ftype >::type  arrSize 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
statuspredefined states are in namespace UserStatus. Other values can be used at will
pMessageArrayoptional status message
arrSizethe number of elements in pParameterArray

§ opSetOnlineStatus() [3/3]

template< typename Ftype > bool opSetOnlineStatus ( int  status,
const Ftype  pMessageArray,
const short *  pArrSizes 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
statuspredefined states are in namespace UserStatus. Other values can be used at will
pMessageArrayoptional status message
pArrSizesan array holding the number of elements for each dimension of pParameterArray

§ opAddFriends()

bool opAddFriends ( const Common::JVector< Common::JString > &  userIDs)
virtual

Adds users to the list on the Chat Server which will send you status updates for those.

Parameters
userIDslist of friend user names
Returns
true if the command has been sent

§ opRemoveFriends()

bool opRemoveFriends ( const Common::JVector< Common::JString > &  userIDs)
virtual

Removes users from the list on the Chat Server which will send you status updates for those.

Parameters
userIDslist of friend user names
Returns
true if the command has been sent

§ getServerTimeOffset()

int getServerTimeOffset ( void  ) const

Returns
the difference between the local uptime and the Photon Server's system time in ms.

In real-time games it's often useful to relate game events to a global common timeline, that's valid for all players and independent from derivations throughout the clients' system times. The Photon Server's System Time can serve as this reference time. The serverTimeOffset represents the difference between the client's local system time and the Photon server's system time.

ServerTime = serverTimeOffset + GETTIMEMS()

The serverTimeOffset is fetched shortly after connect by Photon. Use GETTIMEMS() to get your local time in ms. You can let Photon refetch the offset by calling fetchServerTimestamp(). The ServerTimeOffset will be 0 until shortly after initial connect.

§ getServerTime()

int getServerTime ( void  ) const

Returns
the Photon Server's system time ins ms.

see getServerTimeOffset()

§ getBytesOut()

int getBytesOut ( void  ) const

Returns
the total number of outgoing bytes transmitted by this PhotonPeer object.
See also
getBytesIn()

§ getBytesIn()

int getBytesIn ( void  ) const

Returns
the total number of incoming bytes received by this PhotonPeer object.
See also
getBytesOut()

§ getByteCountCurrentDispatch()

int getByteCountCurrentDispatch ( void  ) const

Returns
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().

§ getByteCountLastOperation()

int getByteCountLastOperation ( void  ) const

Returns
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.

§ getSentCountAllowance()

int getSentCountAllowance ( void  ) const

Returns
the number of resend retries before a peer is considered lost/disconnected.

This is udp specific and will always return 0 for other protocols.

See also
setSentCountAllowance() getDisconnectTimeout() setDisconnectTimeout()

§ setSentCountAllowance()

void setSentCountAllowance ( int  sentCountAllowance)

Sets the number of re-send retries before a peer is considered lost/disconnected.

This is udp specific and will do nothing at all for other protocols.

Parameters
sentCountAllowancethe new number of re/-send retries before a peer is considered lost/disconnected.
See also
getSentCountAllowance() getDisconnectTimeout() setDisconnectTimeout()

§ getTimePingInterval()

int getTimePingInterval ( void  ) const

Returns
the time threshold in milliseconds since the last reliable command, before a ping will be sent.
See also
setTimePingInterval()

§ setTimePingInterval()

void setTimePingInterval ( int  timePingInterval)

Sets the time threshold in milliseconds since the last reliable command, before a ping will be sent.

Parameters
timePingIntervaltime threshold in milliseconds since the last reliable command, before a ping will be sent.
See also
getTimePingInterval()

§ getRoundTripTime()

int getRoundTripTime ( void  ) const

Returns
the time in milliseconds until a reliable command is acknowledged by the server.

This is, what is commonly called a ping time or just a ping.

See also
getRoundTripTimeVariance()

§ getRoundTripTimeVariance()

int getRoundTripTimeVariance ( void  ) const

Returns
the variance of the roundtrip time in milliseconds. Gives a hint about how much the net latency is varying.
See also
getRoundTripTime()

§ getTimestampOfLastSocketReceive()

int getTimestampOfLastSocketReceive ( void  ) const

Returns
timestamp of the last time anything (!) was received from the server (including low level Ping and ACKs but also events and operation-returns). This is not the time when something was dispatched.

§ getDebugOutputLevel()

int getDebugOutputLevel ( void  ) const

Returns the current level of debug information that's passed on to BaseListener::debugReturn().

Returns
one of the values in DebugLevel
See also
setDebugOutputLevel()

§ setDebugOutputLevel()

bool setDebugOutputLevel ( int  debugLevel)

Sets the current level of debug information that's passed on to BaseListener::debugReturn().

Parameters
debugLevelone of the values in DebugLevel
Returns
true if the new debug level has been set correctly, false otherwise.
See also
getDebugOutputLevel()

§ getLogFormatOptions()

const LogFormatOptions & getLogFormatOptions ( void  ) const

Returns
the LogFormatOptions that are used by this instance.
See also
setFormatOptions()

§ setLogFormatOptions()

void setLogFormatOptions ( const Common::LogFormatOptions formatOptions)

Sets the log format options to the supplied value.

Parameters
formatOptionsthe new value to which the log format options will be set
See also
getFormatOptions()

§ getIncomingReliableCommandsCount()

int getIncomingReliableCommandsCount ( void  ) const

Returns
the total number of reliable commands currently waiting in the incoming queues of all channels or -1 if not connected.

§ getPeerID()

short getPeerID ( void  ) const

Returns
this peer's ID as assigned by the server. Will be -1, if not connected.

§ getDisconnectTimeout()

int getDisconnectTimeout ( void  ) const

Returns
the maximum time interval in milliseconds for doing resend retries before a peer is considered lost/disconnected.
See also
setDisconnectTimeout() getSentCountAllowance() setSentCountAllowance()

§ setDisconnectTimeout()

void setDisconnectTimeout ( int  disconnectTimeout)

Sets the maximum time ins milliseconds for making re-send retries before a peer is considered lost/disconnected.

Parameters
disconnectTimeoutresend max time in ms before a peer is considered lost/disconnected
See also
getDisconnectTimeout() getSentCountAllowance() setSentCountAllowance()

§ getQueuedIncomingCommands()

int getQueuedIncomingCommands ( void  ) const

Returns
the number of queued incoming commands in all channels or -1 if not connected

§ getQueuedOutgoingCommands()

int getQueuedOutgoingCommands ( void  ) const

Returns
the number of queued outgoing commands in all channels or -1 if not connected

§ getIsPayloadEncryptionAvailable()

bool getIsPayloadEncryptionAvailable ( void  ) const

Returns
this peer's encryption availability status. True if either payload encryption is available or if the connection protocol is UDP and UDP encryption is available or if the connection protocol is already secure on its own, false otherwise.
See also
getIsPayloadEncryptionAvailable(), establishEncryption(), initUserDataEncryption(), initUDPEncryption()

§ getResentReliableCommands()

int getResentReliableCommands ( void  ) const

Returns
the count of commands that got repeated (due to local repeat-timing before an ACK was received).

§ getLimitOfUnreliableCommands()

int getLimitOfUnreliableCommands ( void  ) const

Returns
the limit for the queue of received unreliable commands.
See also
setLimitOfUnreliableCommands()

§ setLimitOfUnreliableCommands()

void setLimitOfUnreliableCommands ( int  value)

Sets the limit for the queue of received unreliable commands. This works only in UDP. This limit is applied when you call dispatchIncomingCommands. If this client (already) received more than this limit, it will throw away the older ones instead of dispatching them. This can produce bigger gaps for unreliable commands but your client catches up faster. This can be useful when the client couldn't dispatch anything for some time (cause it was in a room but loading a level). If set to 20, the incoming unreliable queues are truncated to 20. If 0, all received unreliable commands will be dispatched. This is a "per channel" value, so each channel can hold commands up to specified limit. This value interacts with dispatchIncomingCommands(): If that is called less often, more commands get skipped.

See also
getLimitOfUnreliableCommands()

§ getCRCEnabled()

bool getCRCEnabled ( void  ) const

Returns
true if CRC enabled
See also
setCRCEnabled

§ setCRCEnabled()

void setCRCEnabled ( bool  crcEnabled)

Enables or disables CRC. While not connected, this controls if the next connection(s) should use a per-package CRC checksum. If the client is in another state than 'connected', then this function has no effect except for logging an error.

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 checks are counted in PhotonPeer.PacketLossByCRC.

Note
This only has effect for UDP connections.
This does not have any effect for connections that use UDP datagram encryption (which always use a built-in checksum).
See also
getCRCEnabled

§ getPacketLossByCRC()

int getPacketLossByCRC ( void  ) const

Returns
the count of packages dropped due to failed CRC checks for this connection.
See also
setCRCEnabled

§ getTrafficStatsEnabled()

bool getTrafficStatsEnabled ( void  ) const

Returns
true if traffic statistics of a peer are enabled. Default trafficStatsEnabled: false (disabled).

§ setTrafficStatsEnabled()

void setTrafficStatsEnabled ( bool  trafficStatsEnabled)

Enables or disables the traffic statistics of a peer. Default trafficStatsEnabled: false (disabled).

§ getTrafficStatsElapsedMs()

int getTrafficStatsElapsedMs ( void  ) const

Returns
the count of milliseconds the stats are enabled for tracking.

§ getTrafficStatsIncoming()

const Photon::TrafficStats & getTrafficStatsIncoming ( void  ) const

Returns
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.

§ getTrafficStatsOutgoing()

const Photon::TrafficStats & getTrafficStatsOutgoing ( void  ) const

Returns
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.

§ getTrafficStatsGameLevel()

const Photon::TrafficStatsGameLevel & getTrafficStatsGameLevel ( void  ) const

Returns
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).

§ getQuickResendAttempts()

nByte getQuickResendAttempts ( void  ) const

Returns
the number of resend attempts for a reliable command that are done in quick succession (after RoundTripTime+4*RoundTripTimeVariance).

§ setQuickResendAttempts()

void setQuickResendAttempts ( nByte  quickResendAttempts)

Returns
the number of resend attempts for a reliable command that are done in quick succession (after RoundTripTime+4*RoundTripTimeVariance).

§ getChannelCountUserChannels()

nByte getChannelCountUserChannels ( void  ) const

The IDs from 0 to getChannelCountUserChannels()-1 can be passed as channelID to operations that offer this parameter.

Returns
the number of different channels that are available for sending operations on.

§ getPeerCount()

short getPeerCount ( void  )
static

Returns
the count of peers, which have been initialized since the start of the application. Interesting mainly for debugging purposes.

§ getUserID()

const JString & getUserID ( void  ) const

Returns the unique user id.

Returns
the user id

§ getState()

int getState ( void  ) const

Returns client state

§ getDisconnectedCause()

int getDisconnectedCause ( void  ) const

Returns cause of last disconnect event.

Returns
disconnect cause constant from Chat::DisconnectCause.
See also
Chat::DisconnectCause

§ getRegion()

const JString & getRegion ( void  ) const

Returns chat (Name Server) region.

§ setRegion()

void setRegion ( const Common::JString region)

Sets chat (Name Server) region. Set it before connect() call.

Parameters
regionregion

§ getPublicChannels()

const JVector< Channel * > & getPublicChannels ( void  ) const

Returns list of subscribed public channels.

Returns
list of subscribed channels

§ getPrivateChannels()

const JVector< Channel * > & getPrivateChannels ( void  ) const

Returns list of private chats that client currently has.

Returns
list of private chats

§ getPublicChannel()

const Channel * getPublicChannel ( const Common::JString channelName) const

Search subscribed public channels by channel name.

Parameters
channelNamechannel name to search
Returns
found channel or NULL otherwise

§ getPrivateChannel()

const Channel * getPrivateChannel ( const Common::JString userName) const

Search private chat by user name.

Parameters
userNameuser name to search
Returns
found chat or NULL otherwise