Photon C++ Client API
4.1.12.2
|
Public Member Functions | |
virtual | ~Player (void) |
Player (const Player &toCopy) | |
virtual Player & | operator= (const Player &toCopy) |
int | getNumber (void) const |
const Common::JString & | getName () const |
const Common::JString & | getUserID () const |
const Common::Hashtable & | getCustomProperties () const |
bool | getIsInactive (void) const |
bool | getIsMasterClient (void) const |
bool | operator== (const Player &player) const |
virtual Common::JString & | toString (Common::JString &retStr, bool withTypes=false) const |
virtual Common::JString | toString (bool withTypes, bool withCustomProperties) const |
Public Member Functions inherited from Base | |
virtual | ~Base (void) |
Public Member Functions inherited from ToString | |
virtual | ~ToString (void) |
virtual JString | typeToString (void) const |
JString | toString (bool withTypes=false) const |
Additional Inherited Members | |
Static Public Member Functions inherited from Base | |
static void | setListener (const BaseListener *baseListener) |
static int | getDebugOutputLevel (void) |
static bool | setDebugOutputLevel (int debugLevel) |
static const LogFormatOptions & | getLogFormatOptions (void) |
static void | setLogFormatOptions (const LogFormatOptions &options) |
Detailed Description
Each client inside a MutableRoom is represented by an instance of this class.
Player instances are only valid in the context of the MutableRoom() instance from which they have been retrieved.
- See also
- MutablePlayer, MutableRoom, MutableRoom::getPlayers(), MutableRoom::getPlayerForNumber()
Constructor & Destructor Documentation
§ ~Player()
|
virtual |
Destructor.
§ Player()
Copy-Constructor: Creates a new instance that is a deep copy of the argument instance.
- Parameters
-
toCopy The instance to copy.
Member Function Documentation
§ operator=()
operator=.
Makes a deep copy of its right operand into its left operand.
This overwrites old data in the left operand.
Reimplemented in MutablePlayer.
§ getNumber()
int getNumber | ( | void | ) | const |
- Returns
- the player number
The player number serves as a the unique identifier of a player inside the current room.
It is assigned per room and only valid in the context of that room. A player number is never re-used for another player inside the same room.
If a player leaves a room entirely (either explicitly through a call to Client::opLeaveRoom() without passing 'true' for parameter 'willComeBack' or implicitly because his playerTtl runs out (see RoomOptions::setPlayerTtl())) and joins it again afterwards, then he is treated as an entirely new player and gets assigned a new player number.
If a player becomes inactive (either explicitly through a call to Client::opLeaveRoom() with passing 'true' for parameter 'willComeBack' or implicitly by by getting disconnected) and then rejoins the same room before his playerTtl runs out, then he is treated as the same player an keeps his previously assigned player number.
§ getName()
const JString & getName | ( | void | ) | const |
- Returns
- the non-unique nickname of this player
A player might change his own name.
Such a change is synced automatically with the server and other clients in the same room.
§ getUserID()
const JString & getUserID | ( | void | ) | const |
- Returns
- the unique user ID of this player
This value is only available when the room got created with RoomOptions::setPublishUserId(true). Otherwise it will be an empty string.
Useful for Client::opFindFriends() and and for blocking slots in a room for expected users (see MutableRoom::getExpectedUsers()).
- See also
- AuthenticationValues
§ getCustomProperties()
const Hashtable & getCustomProperties | ( | void | ) | const |
- Returns
- the custom properties of this player
Read-only cache for the custom properties of a player. A client can change the custom properties of his local player instance through class MutablePlayer. The Custom Properties of remote players are automatically updated when they change.
§ getIsInactive()
bool getIsInactive | ( | void | ) | const |
- Returns
- 'true' if a player is inactive, 'false' otherwise.
Inactive players keep their spot in a room but otherwise behave as if offline (no matter what their actual connection status is).
The room needs a PlayerTtl != 0 (see RoomOptions::setPlayerTtl()) for players to be able to become inactive. If a player is inactive for longer than the PlayerTtl, then the server will remove this player from the room.
§ getIsMasterClient()
bool getIsMasterClient | ( | void | ) | const |
- Returns
- 'true' if this player is the Master Client of the current room, 'false' otherwise.
There is always exactly one master client. The creator of a room gets assigned the role of master client on room creation.
When the current master client leaves the room or becomes inactive and there is at least one active player inside the room, then the role of master client gets reassigned by the server to an active client. As soon as one client becomes active again in a room with only inactive clients, the role of master client will be assigned to this active client.
Whenever the role of master client gets assigned to a different client, all active clients inside the same room get informed about it by a call to Listener::onMasterClientChanged().
You can use the master client when you want one client to be an authoritative instance.
- See also
- MutableRoom::getMasterClientID(), Listener::onMasterClientChanged(), DirectMode::MASTER_TO_ALL
§ operator==()
bool operator== | ( | const Player & | player | ) | const |
operator==.
- Returns
- true, if both operands are equal, false otherwise.
Two Player instances are considered equal, if getNumber() returns equal values for both of them.
§ toString() [1/2]
|
virtual |
- Remarks
- The cost of this function depends a lot on implementation details of the implementing subclasses, but for container classes this function can become quite expensive, if the instance contains huge amounts of data, as its cost for many container class implementations increases disproportionately high to the size of the payload.
- Parameters
-
retStr reference to a string, to store the return-value in; the information, which is generated by this function, will be attached at the end of any eventually existing previous content of the string withTypes set to true, to include type information in the generated string
- Returns
- a JString representation of the instance and its contents for debugging purposes.
Implements ToString.
§ toString() [2/2]
|
virtual |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
- Parameters
-
withTypes set to true, to include type information in the generated string withCustomProperties set to true, to include the custom properties in the generated string