Photon C++ Client API
5.0.7.3
|
Public Member Functions | |
Client (LoadBalancing::Listener &listener, const Common::JString &applicationID, const Common::JString &appVersion, const ClientConstructOptions &clientConstructOptions=ClientConstructOptions()) | |
virtual | ~Client (void) |
virtual bool | connect (const ConnectOptions &connectOptions=ConnectOptions()) |
virtual void | disconnect (void) |
virtual void | service (bool dispatchIncomingCommands=true) |
virtual void | serviceBasic (void) |
virtual bool | opCustom (const Photon::OperationRequest &operationRequest, bool sendReliable, nByte channelID=0, bool encrypt=false) |
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 | opJoinLobby (const Common::JString &lobbyName=Common::JString(), nByte lobbyType=LobbyType::DEFAULT) |
virtual bool | opLeaveLobby (void) |
virtual bool | opCreateRoom (const Common::JString &gameID=Common::JString(), const RoomOptions &options=RoomOptions(), const Common::JVector< Common::JString > &expectedUsers=Common::JVector< Common::JString >()) |
virtual bool | opJoinOrCreateRoom (const Common::JString &gameID, const RoomOptions &options=RoomOptions(), int cacheSliceIndex=0, const Common::JVector< Common::JString > &expectedUsers=Common::JVector< Common::JString >()) |
virtual bool | opJoinRandomOrCreateRoom (const Common::JString &gameID=Common::JString(), const RoomOptions &options=RoomOptions(), const Common::Hashtable &customRoomProperties=Common::Hashtable(), nByte maxPlayers=0, nByte matchmakingMode=MatchmakingMode::FILL_ROOM, const Common::JString &lobbyName=Common::JString(), nByte lobbyType=LobbyType::DEFAULT, const Common::JString &sqlLobbyFilter=Common::JString(), const Common::JVector< Common::JString > &expectedUsers=Common::JVector< Common::JString >()) |
virtual bool | opJoinRoom (const Common::JString &gameID, bool rejoin=false, int cacheSliceIndex=0, const Common::JVector< Common::JString > &expectedUsers=Common::JVector< Common::JString >()) |
virtual bool | opJoinRandomRoom (const Common::Hashtable &customRoomProperties=Common::Hashtable(), nByte maxPlayers=0, nByte matchmakingMode=MatchmakingMode::FILL_ROOM, const Common::JString &lobbyName=Common::JString(), nByte lobbyType=LobbyType::DEFAULT, const Common::JString &sqlLobbyFilter=Common::JString(), const Common::JVector< Common::JString > &expectedUsers=Common::JVector< Common::JString >()) |
virtual bool | opLeaveRoom (bool willComeBack=false, bool sendAuthCookie=false) |
template<typename Ftype > | |
bool | opRaiseEvent (bool reliable, const Ftype ¶meters, nByte eventCode, const RaiseEventOptions &options=RaiseEventOptions()) |
template<typename Ftype > | |
bool | opRaiseEvent (bool reliable, const Ftype pParameterArray, int arrSize, nByte eventCode, const RaiseEventOptions &options=RaiseEventOptions()) |
template<typename Ftype > | |
bool | opRaiseEvent (bool reliable, const Ftype pParameterArray, const int *pArrSizes, nByte eventCode, const RaiseEventOptions &options=RaiseEventOptions()) |
virtual bool | opFindFriends (const Common::JString *friendsToFind, short numFriendsToFind) |
virtual bool | opLobbyStats (const Common::JVector< LoadBalancing::LobbyStatsRequest > &lobbiesToQuery=Common::JVector< LoadBalancing::LobbyStatsRequest >()) |
virtual bool | opChangeGroups (const Common::JVector< nByte > *pGroupsToRemove, const Common::JVector< nByte > *pGroupsToAdd) |
virtual bool | opCustomAuthenticationSendNextStepData (const AuthenticationValues &authenticationValues) |
virtual bool | opWebRpc (const Common::JString &uriPath) |
template<typename Ftype > | |
bool | opWebRpc (const Common::JString &uriPath, const Ftype ¶meters, bool sendAuthCookie=false) |
template<typename Ftype > | |
bool | opWebRpc (const Common::JString &uriPath, const Ftype pParameterArray, int arrSize, bool sendAuthCookie=false) |
template<typename Ftype > | |
bool | opWebRpc (const Common::JString &uriPath, const Ftype pParameterArray, const int *pArrSizes, bool sendAuthCookie=false) |
virtual bool | opGetRoomList (const Common::JString &lobby, const Common::JString &sqlLobbyFilter) |
virtual bool | selectRegion (const Common::JString &selectedRegion) |
virtual bool | reconnectAndRejoin (void) |
template<typename Ftype > | |
int | sendDirect (const Ftype ¶meters, const SendDirectOptions &options=SendDirectOptions()) |
template<typename Ftype > | |
int | sendDirect (const Ftype pParameterArray, int arrSize, const SendDirectOptions &options=SendDirectOptions()) |
template<typename Ftype > | |
int | sendDirect (const Ftype pParameterArray, const int *pArrSizes, const SendDirectOptions &options=SendDirectOptions()) |
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::LogFormatOptions & | getLogFormatOptions (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 |
bool | getIsEncryptionAvailable (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::TrafficStats & | getTrafficStatsIncoming (void) const |
const Photon::TrafficStats & | getTrafficStatsOutgoing (void) const |
const Photon::TrafficStatsGameLevel & | getTrafficStatsGameLevel (void) const |
nByte | getQuickResendAttempts (void) const |
void | setQuickResendAttempts (nByte quickResendAttempts) |
nByte | getChannelCountUserChannels (void) const |
nByte | getSerializationProtocol (void) const |
int | getState (void) const |
const Common::JString & | getMasterserverAddress (void) const |
int | getCountPlayersIngame (void) const |
int | getCountGamesRunning (void) const |
int | getCountPlayersOnline (void) const |
MutableRoom & | getCurrentlyJoinedRoom (void) |
const Common::JVector< Room * > & | getRoomList (void) const |
const Common::JVector< Common::JString > & | getRoomNameList (void) const |
bool | getIsInRoom (void) const |
bool | getIsInGameRoom (void) const |
bool | getIsInLobby (void) const |
bool | getAutoJoinLobby (void) const |
void | setAutoJoinLobby (bool autoJoinLobby) |
MutablePlayer & | getLocalPlayer (void) |
const Common::JVector< FriendInfo > & | getFriendList (void) const |
int | getFriendListAge (void) const |
int | getDisconnectedCause (void) const |
const Common::JString & | getUserID (void) const |
const Common::JString & | getRegionWithBestPing (void) const |
bool | setMasterClient (const Player &masterClientPlayer) |
Static Public Member Functions | |
static short | getPeerCount (void) |
This class implements the Photon LoadBalancing work flow by using a Peer. It keeps a state and automatically executes transitions between the Master and Game Servers.
This class (and the Player, MutablePlayer, Room and MutableRoom classes) might be extended to implement your own logic.
However this is not necessary. You can also just put your game specific network logic into a class that uses this class as is, which is the recommended approach.
Override MutableRoom:createPlayer() when subclassing Player, getMutablePlayerFactory() + MutablePlayerFactory::create() + MutablePlayerFactory::destroy() when subclassing MutablePlayer, createRoom() when subclassing Room and getMutableRoomFactory() + MutableRoomFactory::create() + MutableRoomFactory::destroy() when subclassing MutableRoom.
We try to provide demos to each platform where this API can be used, so lookout for those.
Client | ( | LoadBalancing::Listener & | listener, |
const Common::JString & | applicationID, | ||
const Common::JString & | appVersion, | ||
const ClientConstructOptions & | clientConstructOptions = ClientConstructOptions() |
||
) |
Constructor.
listener | Reference to the application's implementation of the Listener callback interface. Has to be valid for at least the lifetime of the Client instance, which is created by this constructor. |
applicationID | A unique ID of your application. Must match one of the appIDs in your dashboard for Photon Cloud. This parameter gets ignored by Photon Server. |
appVersion | Only clients that use the exact same appVersion can see each other. You can use different values to separate clients with the same appID from each other that should not be able to be matched with each other or to even see each other, i.e. incompatible versions of your game or public, closed-beta, QA, staging and dev clients. This parameter gets ignored by Photon Server. |
clientConstructOptions | An instance of class ClientConstructOptions |
|
virtual |
Destructor.
|
virtual |
This function starts establishing a connection to a Photon server. The servers response will arrive in Listener::connectReturn().
The connection is successfully established when the Photon client received a valid response from the server. The connect-attempt fails when a network error occurs or when server is not responding. A call to this function starts an asynchronous operation. The result of this operation gets returned through the Listener::connectReturn() callback function. If this function returns false, then the connect-attempt has already failed locally. If it returns true, then either Listener::connectionErrorReturn() or Listener::connectReturn() will get called. The operation was successful, when Listener::connectReturn() got called with errorCode==0.
connectOptions | An instance of class ConnectOptions |
|
virtual |
This function generates a disconnection request that will be sent to the Photon server. The servers response will arrive in Listener::disconnectReturn().
If the disconnection is completed successfully, then the Listener::disconnectReturn() callback will be called.
|
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:
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 parameter dispatchIncomingCommands to skip the calls to dispatchIncomingCommands(). Incoming commands will be stored in the incoming queue until they are dispatched again.
dispatchIncomingCommands | true = dispatchIncomingCommands() will be called; false = dispatchIncomingCommands() won't be called, default is true |
|
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.
|
virtual |
Sends a custom operation to a custom Server, using reliable or unreliable Photon transmission.
Allows the client to send a custom operation to the Photon server (which has to be modified accordingly). The Server can be extended and modified for special purposes like server side collision detection or a consistent world.
You need to be connected (see connect()) prior to calling opCustom().
operationRequest | holds the payload of the operation |
sendReliable | = operation will be sent reliably; false = no resend in case of packet loss - will be ignored, when not using udp as protocol |
channelID | the logical channel, default is 0. See Fragmentation and Channels for more information. |
encrypt | true = encrypt message; false = no encryption |
|
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 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.
Usually you don't have to call sendOutgoingCommands() this explicitly, as this is done within service().
|
virtual |
Sends only ACKs (UDP) or Ping (TCP, WS and WSS) instead of queued outgoing commands. Useful to pause sending actual data.
|
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.
|
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.
|
virtual |
Creates new instances of TrafficStats and starts a new timer for those.
|
virtual |
Resets traffic stats values that can be maxed out.
|
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.
all | If true, Incoming and Outgoing low-level stats are included in the string. |
|
virtual |
Joins the specified lobby.
This function sends a request to the server to join the specified lobby. If it returns true, then Listener::joinLobbyReturn() gets called when the operation has successfully been finished. Please see Matchmaking Guide regarding the differences between the various lobby types.
lobbyName | the unique name of the lobby to join |
lobbyType | one of the values in LobbyType |
|
virtual |
Leaves the currently joined lobby.
This function sends a request to the server to leave the currently joined lobby. If it returns true, then Listener::leaveLobbyReturn() gets called when the operation has successfully been finished.
|
virtual |
Creates and enters a new game room.
This function sends a request to the server to create the specified game room. If it returns true, then Listener::createRoomReturn() gets called when the operation has been finished.
If you don't want to create a unique room name, pass L"" as name and the server will assign a roomName (a GUID as string). Room names are unique.
A room will be attached to the lobby that you have specified in the provided options. Leave the lobby name empty to attach the room to the lobby in which you reside at the time of room creation. If you are in no lobby, then the default lobby is used.
Multiple lobbies can help to separate players by map or skill or game type. Each room can only be found in one lobby (no matter if defined by name and type or as default).
gameID | The name to create a room with. Must be unique and not in use or the room can't be created. If this is an empty string, then the server will assign a GUID as name. |
options | An instance of RoomOptions, that can be used to specify various options for room creation. |
expectedUsers | Sets a list of user IDs for which the server should reserve slots. Those slots can't be taken by other players. |
|
virtual |
Joins the specified game room or creates and enters a new game room with the specified ID if such a room does not exist yet.
This function sends a request to the server to join the specified game room if exists and to create it otherwise. If it returns true, then Listener::joinOrCreateRoomReturn() gets called when the operation has been finished.
Unlike opJoinRoom(), this operation does not fail if the room does not exist. This can be useful when you send invitations to a room before actually creating it: Any invited player (whoever is first) can call this and on demand, the room gets created implicitly.
In the case that a new room gets created, that room will be attached to the lobby that you have specified in the provided options. Leave the lobby name empty to attach the room to the lobby in which you reside at the time of room creation. If you are in no lobby, then the default lobby is used.
This operation does not allow you to re-join a game. To return to a room, use opJoinRoom() with the playerNumber which was assigned previously.
gameID | A unique identifier for the game room to join or create. If this is an empty string, then the server will create a room and assign a GUID as name. |
options | An instance of RoomOptions, that can be used to specify various options for room creation. These options will be ignored when the room already exists. |
cacheSliceIndex | Allows to request a specific cache slice - all events in that cache slice and upward slices will be published to the client after joining the room - see Lite::EventCache for further information about cached events. |
expectedUsers | Sets a list of user IDs for which the server should reserve slots. Those slots can't be taken by other players. If the room already exists, then this list will be merged with any previously set list of expected users for this room. |
|
virtual |
Joins a random game room that matches the specified criteria or creates and enters a new game room with the specified ID if such a room does not exist yet.
This function sends a request to the server to join a random game room that matches the specified filters if such a room exists and to create it otherwise. If it returns true, then Listener::joinRandomOrCreateRoomReturn() gets called when the operation has been finished.
Unlike opJoinRandomRoom(), this operation does not fail if no room exists, that matches the specified criteria, but creates a new room.
In the case that a new room gets created, that room will be attached to the lobby that you have specified in the provided options. Leave the lobby name empty to attach the room to the lobby in which you reside at the time of room creation. If you are in no lobby, then the default lobby is used.
gameID | A unique identifier for the game room to create. This parameter only gets considered if no existing room matches the specified filters and a new room gets created. If this is an empty string, then the server will create a room and assign a GUID as name. |
options | An instance of RoomOptions, that can be used to specify various options for room creation. These options only get considered if no existing room matches the filters and a new room gets created. |
customRoomProperties | Used as a filter for matchmaking. The server only considers rooms for which all custom properties match the specified filters. Note that only those custom room properties that have been specified for listing in the lobby will be used for matchmaking, so a rooms custom property can only match a specified filter if it got specified in the list of properties to show in the lobby. All values must be exact matches. |
maxPlayers | Must match the value of a rooms maxPlayers property for that room to be considered for matchmaking. |
matchmakingMode | Needs to be one of the values in MatchMakingMode |
lobbyName | The name of the lobby in which matchmaking should take place. Only rooms that are listed in that lobby will be considered for matchmaking. |
lobbyType | The type of the lobby in which matchmaking should take place. Needs to be one of the values in LobbyType. Note that a lobby with the same name, but a different type can not be considered for matchmaking, as a lobby name only needs to be unique among lobbies of the same type. |
sqlLobbyFilter | Only used for LobbyType::SQL_LOBBY. This allows 'bigger', 'less', 'or' and 'and' combinations for filtering against certain room properties. Up to 3 ';'-separated filters can be specified. The second filter will only be considered if no rooms could be found that match the first filter and the third filter will only be considered if no rooms could be found that match either the first or the second filter. |
expectedUsers | Sets a list of user IDs for which the server should reserve slots. Those slots can't be taken by other players. This list will be merged with any previously set list of expected users for this room. |
|
virtual |
Joins the specified game room.
This function sends a request to the server to join the specified game room. If it returns true, then Listener::joinRoomReturn() gets called when the operation has been finished.
This function is useful when you are using a lobby to list rooms and know their names. A room's name has to be unique (per region and app version), so it does not matter which lobby the room is in.
It's usually better to use opJoinOrCreateRoom() for invitations. Then it does not matter if the room is already setup.
gameID | A unique identifier for the game room to join. |
rejoin | Needs to be false if this is the initial join of this room for this client and true if this is a rejoin. |
cacheSliceIndex | Allows to request a specific cache slice - all events in that cache slice and upward slices will be published to the client after joining the room - see Lite::EventCache for further information about cached events. |
expectedUsers | Sets a list of user IDs for which the server should reserve slots. Those slots can't be taken by other players. This list will be merged with any previously set list of expected users for this room. |
|
virtual |
Joins a random game room.
This function sends a request to the server to join a random game room. If it returns true, then Listener::joinRandomRoomReturn() gets called when the operation has been finished.
customRoomProperties | Used as a filter for matchmaking. The server only considers rooms for which all custom properties match the specified filters. Note that only those custom room properties that have been specified for listing in the lobby will be used for matchmaking, so a rooms custom property can only match a specified filter if it got specified in the list of properties to show in the lobby. All values must be exact matches. |
maxPlayers | Must match the value of a rooms maxPlayers property for that room to be considered for matchmaking. |
matchmakingMode | Needs to be one of the values in MatchMakingMode |
lobbyName | The name of the lobby in which matchmaking should take place. Only rooms that are listed in that lobby will be considered for matchmaking. |
lobbyType | The type of the lobby in which matchmaking should take place. Needs to be one of the values in LobbyType. Note that a lobby with the same name, but a different type can not be considered for matchmaking, as a lobby name only needs to be unique among lobbies of the same type. |
sqlLobbyFilter | Only used for LobbyType::SQL_LOBBY. This allows 'bigger', 'less', 'or' and 'and' combinations for filtering against certain room properties. Up to 3 ';'-separated filters can be specified. The second filter will only be considered if no rooms could be found that match the first filter and the third filter will only be considered if no rooms could be found that match either the first or the second filter. |
expectedUsers | Sets a list of user IDs for which the server should reserve slots. Those slots can't be taken by other players. This list will be merged with any previously set list of expected users for this room. |
|
virtual |
Leaves the currently joined game room.
This function sends a request to the server to leave the currently joined game room. If it returns true, then Listener::leaveRoomReturn() gets called when the operation has successfully been finished.
willComeBack | If this is set to 'true', then the player becomes inactive and the client could later rejoin the room as the very same player. 'false' means the player leaves the room for good. Note that the player only stays inactive for at maximum as many milliseconds as you have set the playerTtl to during room creation (see RoomOptions::setPlayerTtl()). The default is 'false'. |
sendAuthCookie | Pass 'true' to set the sendAuthCookie web flag (please see Webhooks v1.2 for further information). The default is 'false'. |
template< typename Ftype > bool opRaiseEvent | ( | bool | reliable, |
const Ftype & | parameters, | ||
nByte | eventCode, | ||
const RaiseEventOptions & | options = RaiseEventOptions() |
||
) |
Sends in-game data to other players in the game, who will receive it in their Listener::customEventAction() callback.
The eventCode should be used to define the event's type and content respectively. The payload has to be one of the datatypes that are listed as supported for values at serializable datatypes.
This function provides the option to raise events reliably or unreliably. While both result in ordered events, the ones that got sent with the latter option might get lost, causing gaps in the resulting event sequence. On the other hand, they cause less overhead and are optimal for data that is replaced soon.
Note: the value of the reliability option only takes effect when the ConnectionProtocol passed to Client() equals ConnectionProtocol::UDP (which is the default for most platforms) and the message is small enough to not get fragmented into several UDP packets (rule of thumb: you can safely assume that the message fits into a single UDP packet, when its payload size is below 1kb), otherwise the message gets sent reliably, even when the reliability option asks for sending it unreliably.
Sending is not done immediately, but in intervals of service() calls.
It is recommended to keep the payload as compact as possible, especially for events that get raised multiple times per second. This easily adds up to a huge amount of data otherwise.
reliable | true = the operation will be sent reliably; false = no resend in case of packet loss - will be ignored, when not using ConnectionProtocol::UDP |
parameters | the payload of the event to raise - has to be provided in the form of one of the supported data types, specified at Table of Datatypes |
eventCode | number for arbitrary classification of the type of the event (like '1' for position updates, '2' for chat messages, and so on). |
options | see RaiseEventOptions |
template< typename Ftype > bool opRaiseEvent | ( | bool | reliable, |
const Ftype | pParameterArray, | ||
int | arrSize, | ||
nByte | eventCode, | ||
const RaiseEventOptions & | options = RaiseEventOptions() |
||
) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
reliable | true = operation will be sent reliably; false = no resend in case of packet loss - will be ignored, when not using UDP as protocol |
pParameterArray | the payload array of the event to raise - has to be provided in the form of a 1D array of one of the supported data types, specified at Table of Datatypes |
arrSize | the number of elements in pParameterArray |
eventCode | number for arbitrary classification of the type of event (like '1' for position updates, '2' for chat messages, and so on). |
options | see RaiseEventOptions |
template< typename Ftype > bool opRaiseEvent | ( | bool | reliable, |
const Ftype | pParameterArray, | ||
const int * | pArrSizes, | ||
nByte | eventCode, | ||
const RaiseEventOptions & | options = RaiseEventOptions() |
||
) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
reliable | true = operation will be sent reliably; false = no resend in case of packet loss - will be ignored, when not using UDP as protocol |
pParameterArray | the payload array of the event to raise - has to be provided in the form of an array of one of the supported data types, specified at Table of Datatypes |
pArrSizes | an array holding the number of elements for each dimension of pParameterArray |
eventCode | number for arbitrary classification of the type of event (like '1' for position updates, '2' for chat messages, and so on). |
options | see RaiseEventOptions |
|
virtual |
Requests the rooms and online states for the specified list of friends. All clients should set a unique UserID before connecting. The result can be accessed through getFriendList() after the corresponding call to Listener::onFindFriendsResponse() has been received.
This function can be called when the caller does not currently reside in a game room to find the rooms played by a selected list of users. The result can be accessed by a call to getFriendList() and is empty before the first response has arrived in Listener::onFindFriendsResponse(). getFriendListAge() can be used to retrieve the amount of milliseconds that have passed since the value that is returned by getFriendList() has been updated for the last time.
Users identify themselves by passing their UserIDs to AuthenticationValues::setUserID().
The list of userIDs must be fetched from some other source (not provided by Photon).
friendsToFind | An array of unique userIDs. |
numFriendsToFind | The element count of friendsToFind. |
|
virtual |
Sends the specified list of LobbyStatsRequest objects to the server. The corresponding list of LobbyStatsResponse objects arrives in Listener::onLobbyStatsResponse().
This function can be called when the caller does not currently reside in a game room to retrieve statistics for various lobbies.
lobbiesToQuery | A Common::JVector containing a LobbyStatsRequest instance for each lobby that should be queried. |
|
virtual |
Updates the clients interest groups (for events inside of game rooms).
This function can be called from inside of a game room to change the list of interest groups inside that room to which the local client is subscribed to. For each opRaiseEvent() call one can specify the interest groups to which that event should be sent in the RaiseEventOptions. When doing so, only clients that are subscribed to those interest groups will receive that event.
Note the difference between passing NULL and the address of an empty JVector instance:
First, removing groups is executed. This way, you could leave all groups and join only the ones provided.
Changes become active not immediately but when the server executes this operation (approximately getRoundTripTime()/2 milliseconds after the Client has sent it).
pGroupsToRemove | Groups to remove from interest. NULL will not remove any. An empty instance will remove all. |
pGroupsToAdd | Groups to add to interest. NULL will not add any. An empty instance will add all existing groups. |
|
virtual |
Used in conjunction with Listener::onCustomAuthenticationIntermediateStep() to implement multi-leg custom authentication.
While normally custom authentication is single-legged, occasionally a certain service may require multi-leg authentication. This means that the client sends some authentication data to the server that you pass when calling connect() and the server does not respond with a final result (successful connect or failed connect attempt due to an authentication error), but with some intermediate result data that gets passed to your Listener::onCustomAuthenticationIntermediateStep() implementation and that is needed by your application to acquire the authentication data for the next step of the authentication process. You can then pass that next step data to this function to continue the authentication process that you have started with the connect() call.
authenticationValues | An instance of class AuthenticationValues |
|
virtual |
Makes Photon call your custom web-service by path/name with the given parameters (converted into JSON).
A WebRPC calls a custom, http-based function on a server that you provide. The uriPath is relative to a "base path" which is configured on the server side. The sent parameters get converted to Json. Vice versa, the response of the web-service will be converted back, when it gets sent back to the Client, where it arrives in Listener::webRpcReturn().
To use this feature, you have to setup your server:
For a Photon Cloud application visit the Dashboard and setup "WebHooks". The BaseUrl is used for WebRPCs as well.
uriPath | the URL path to call, relative to the baseUrl configured on Photon's server-side |
template< typename Ftype > bool opWebRpc | ( | const Common::JString & | uriPath, |
const Ftype & | parameters, | ||
bool | sendAuthCookie = false |
||
) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
uriPath | the URL path to call, relative to the baseUrl configured on Photon's server-side |
parameters | the parameters to send to the web-service method - has to be provided in the form of one of the supported data types, specified at Table of Datatypes |
sendAuthCookie | defines if the authentication cookie gets sent to a WebHook (if set up) |
template< typename Ftype > bool opWebRpc | ( | const Common::JString & | uriPath, |
const Ftype | pParameterArray, | ||
int | arrSize, | ||
bool | sendAuthCookie = false |
||
) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
uriPath | the URL path to call, relative to the baseUrl configured on Photon's server-side |
pParameterArray | the parameter array to send to the web-service method - has to be provided in the form of a 1D array of one of the supported data types, specified at Table of Datatypes |
arrSize | the number of elements in pParameterArray |
sendAuthCookie | defines if the authentication cookie gets sent to a WebHook (if set up) |
template< typename Ftype > bool opWebRpc | ( | const Common::JString & | uriPath, |
const Ftype | pParameterArray, | ||
const int * | pArrSizes, | ||
bool | sendAuthCookie = false |
||
) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
uriPath | the URL path to call, relative to the baseUrl configured on Photon's server-side |
pParameterArray | the parameter array to send to the web-service method - has to be provided in the form of an array of one of the supported data types, specified at Table of Datatypes |
pArrSizes | an array holding the number of elements for each dimension of pParameterArray |
sendAuthCookie | defines if the authentication cookie gets sent to a WebHook (if set up) |
|
virtual |
Gets a list of games matching a SQL-like where clause.
lobby | The lobby to query. Has to be of type LobbyType::SQL_LOBBY. |
sqlLobbyFilter | The sql query statement. |
|
virtual |
Used in conjunction with Listener::onAvailableRegions() and RegionSelectionMode::SELECT to select a certain server region to connect to.
If you pass RegionSelectionMode::SELECT for parameter 'regionSelectionMode' to Client(), then the Client does not automatically choose a server region to connect to on its own during the connection flow, but upon retrieving the list of available regions and the list of server addresses that can be used to ping those regions it passes those lists to your implementation of Listener::onAvailableRegions() and pauses the connection flow. You then need to choose one of the available regions and select it by passing its name to this function to continue the connection flow.
The list of available regions for Photon Public Cloud is available at Regions. However more regions might be added over time after you have released your application and the list of available regions might differ when your appID is associated with a dedicated Cloud or when you connect to a non-default name server address. Also a certain region might be temporarily unavailable for maintenance. Furthermore some regions might consist out of multiple different clusters, while others don't. Therefor you should always assure that the region name that you pass to this function actually matches one of the entries in the list of available regions. Also be prepared to select a fall back option in case that your preferred region is not available.
A typical list of available regions might look like this (more or less regions might be available and the order of the entries is undefined and might change without notice): "eu", "us", "usw", "cae", "asia", "jp", "au", "sa", "in", "kr"
When multiple clusters per region are set up for your appID for some regions, then the list might look like this: "eu/Default", "eu/Cluster2", "us/Default", "us/Cluster2", "usw", "cae", "asia", "jp", "au", "sa", "in", "kr"
Examples for valid strings to pass for the 'eu' region for parameter 'selectedRegion' with the above example lists (adapt accordingly for other regions):
In case of the server randomly selecting a cluster, parameter 'cluster' of Listener::connectReturn() contains the name of the cluster to which the client has connected. Otherwise that parameter is an empty string.
selectedRegion | Must be a valid region name that matches one of the entries in the list of available regions that got passed to Listener::onAvailableRegions() |
|
virtual |
Reconnects to the server and rejoins the last previously joined room.
This function reconnects directly to the game server to which it has previously been connected to and sends a request to the server to join the last previously joined game room. If it returns true, then Listener::joinRoomReturn() gets called when the operation has been finished.
The usual requirements for a rejoin apply, meaning the room must still exist, the local player must have entered it before, but it must not have left it for good, but only have become inactive and the playerTTL for the local player in that room must not have run out yet, otherwise this operation will fail and Listener::joinRoomReturn() will get called with an error code.
int getServerTimeOffset | ( | void | ) | const |
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.
int getServerTime | ( | void | ) | const |
int getBytesOut | ( | void | ) | const |
int getBytesIn | ( | void | ) | const |
int getByteCountCurrentDispatch | ( | void | ) | const |
int getByteCountLastOperation | ( | void | ) | const |
int getSentCountAllowance | ( | void | ) | const |
This is udp specific and will always return 0 for other protocols.
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.
sentCountAllowance | the new number of re/-send retries before a peer is considered lost/disconnected. |
int getTimePingInterval | ( | void | ) | const |
void setTimePingInterval | ( | int | timePingInterval | ) |
Sets the time threshold in milliseconds since the last reliable command, before a ping will be sent.
timePingInterval | time threshold in milliseconds since the last reliable command, before a ping will be sent. |
int getRoundTripTime | ( | void | ) | const |
This is, what is commonly called a ping time or just a ping.
int getRoundTripTimeVariance | ( | void | ) | const |
int getTimestampOfLastSocketReceive | ( | void | ) | const |
int getDebugOutputLevel | ( | void | ) | const |
Returns the current level of debug information that's passed on to BaseListener::debugReturn().
bool setDebugOutputLevel | ( | int | debugLevel | ) |
Sets the current level of debug information that's passed on to BaseListener::debugReturn().
debugLevel | one of the values in DebugLevel |
const LogFormatOptions & getLogFormatOptions | ( | void | ) | const |
void setLogFormatOptions | ( | const Common::LogFormatOptions & | formatOptions | ) |
Sets the log format options to the supplied value.
formatOptions | the new value to which the log format options will be set |
int getIncomingReliableCommandsCount | ( | void | ) | const |
short getPeerID | ( | void | ) | const |
int getDisconnectTimeout | ( | void | ) | const |
void setDisconnectTimeout | ( | int | disconnectTimeout | ) |
Sets the maximum time ins milliseconds for making re-send retries before a peer is considered lost/disconnected.
disconnectTimeout | resend max time in ms before a peer is considered lost/disconnected |
int getQueuedIncomingCommands | ( | void | ) | const |
int getQueuedOutgoingCommands | ( | void | ) | const |
bool getIsPayloadEncryptionAvailable | ( | void | ) | const |
bool getIsEncryptionAvailable | ( | void | ) | const |
int getResentReliableCommands | ( | void | ) | const |
int getLimitOfUnreliableCommands | ( | void | ) | const |
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.
bool getCRCEnabled | ( | void | ) | const |
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.
int getPacketLossByCRC | ( | void | ) | const |
bool getTrafficStatsEnabled | ( | void | ) | const |
void setTrafficStatsEnabled | ( | bool | trafficStatsEnabled | ) |
Enables or disables the traffic statistics of a peer. Default trafficStatsEnabled: false (disabled).
int getTrafficStatsElapsedMs | ( | void | ) | const |
const Photon::TrafficStats & getTrafficStatsIncoming | ( | void | ) | const |
const Photon::TrafficStats & getTrafficStatsOutgoing | ( | void | ) | const |
const Photon::TrafficStatsGameLevel & getTrafficStatsGameLevel | ( | void | ) | const |
nByte getQuickResendAttempts | ( | void | ) | const |
void setQuickResendAttempts | ( | nByte | quickResendAttempts | ) |
Sets the number of resend attempts for a reliable command can be done in quick succession (after RoundTripTime+4*RoundTripTimeVariance).
nByte getChannelCountUserChannels | ( | void | ) | const |
The IDs from 0 to getChannelCountUserChannels()-1 can be passed as channelID to operations that offer this parameter.
nByte getSerializationProtocol | ( | void | ) | const |
|
static |
int getState | ( | void | ) | const |
The Current state this Client instance is in. Be Careful: several states are "transitions" that lead to other states.
const JString & getMasterserverAddress | ( | void | ) | const |
int getCountPlayersIngame | ( | void | ) | const |
int getCountGamesRunning | ( | void | ) | const |
int getCountPlayersOnline | ( | void | ) | const |
MutableRoom & getCurrentlyJoinedRoom | ( | void | ) |
The entries in the returned JVector instance are guarenteed to be in the same order like the entries in the JVector instance that is returned by getRoomList(). The same remarks apply to this function as are mentioned for getRoomList().
bool getIsInRoom | ( | void | ) | const |
bool getIsInGameRoom | ( | void | ) | const |
bool getIsInLobby | ( | void | ) | const |
bool getAutoJoinLobby | ( | void | ) | const |
void setAutoJoinLobby | ( | bool | autoJoinLobby | ) |
Sets the value of the autJoinLobby flag.
autoJoinLobby | the new value to which the flag will be set |
MutablePlayer & getLocalPlayer | ( | void | ) |
const JVector< FriendInfo > & getFriendList | ( | void | ) | const |
int getFriendListAge | ( | void | ) | const |
int getDisconnectedCause | ( | void | ) | const |
Summarizes (aggregates) the different causes for disconnects of a client. A disconnect can be caused by: errors in the network connection or some vital operation failing (which is considered "high level"). While operations always trigger a call to OnOperationResponse, connection related changes are treated in OnStatusChanged. The DisconnectCause is set in either case and summarizes the causes for any disconnect in a single state value which can be used to display (or debug) the cause for disconnection.
const JString & getUserID | ( | void | ) | const |
const JString & getRegionWithBestPing | ( | void | ) | const |