SmartFoxServer 2X C++ API
Sfs2X::Entities::SFSUser Class Reference

The User object represent a client logged in the Server. More...

#include <SFSUser.h>

Inheritance diagram for Sfs2X::Entities::SFSUser:
Sfs2X::Entities::User

Public Member Functions

long int Id ()
 Get the unique User Id More...
 
boost::shared_ptr< string > Name ()
 The user name More...
 
long int PlayerId ()
 Get the playerId of the User. More...
 
bool IsPlayer ()
 Return true if the User is a Player (playerId > 0) in the last joined Room More...
 
bool IsSpectator ()
 Return true if the User is a Spectator (playerId < 0) in the last joined Room More...
 
long int GetPlayerId (boost::shared_ptr< Room > room)
 Return the playerId for the specific Room. More...
 
long int PrivilegeId ()
 Get the privilegeId of the User More...
 
void PrivilegeId (long int value)
 Get the privilegeId of the User More...
 
boost::shared_ptr< IUserManagerUserManager ()
 Get the UserManager of this User More...
 
void UserManager (boost::shared_ptr< IUserManager > value)
 Get the UserManager of this User More...
 
boost::shared_ptr< Vec3DAOIEntryPoint ()
 Returns the entry point of this user in the current user's AoI.
 
void AOIEntryPoint (boost::shared_ptr< Vec3D > value)
 Returns the entry point of this user in the current user's AoI.
 
bool IsGuest ()
 Return true if the User is logged in as guest user More...
 
bool IsStandardUser ()
 Return true if the User is logged in as standard user More...
 
bool IsModerator ()
 Return true if the User is logged in as moderator user More...
 
bool IsAdmin ()
 Return true if the User is logged in as administrator user More...
 
bool IsPlayerInRoom (boost::shared_ptr< Room > room)
 Return true if the User is a Player in the specified Room More...
 
bool IsSpectatorInRoom (boost::shared_ptr< Room > room)
 Return true if the User is a Spectator in the specified Room More...
 
bool IsJoinedInRoom (boost::shared_ptr< Room > room)
 Return true if the User is joined in the specified Room More...
 
bool IsItMe ()
 Return true if the User object is the client's User object, also known as SmartFox.MySelf More...
 
boost::shared_ptr< vector< boost::shared_ptr< UserVariable > > > GetVariables ()
 Get all the User Variables More...
 
boost::shared_ptr< UserVariableGetVariable (string varName)
 Get a UserVariable More...
 
bool ContainsVariable (string name)
 Check if a UserVariable exists More...
 
boost::shared_ptr< map< string, boost::shared_ptr< void > > > Properties ()
 A generic object that can be used to store any User custom data needed at runtime. More...
 
void Properties (boost::shared_ptr< map< string, boost::shared_ptr< void > > > value)
 A generic object that can be used to store any User custom data needed at runtime. More...
 

Detailed Description

The User object represent a client logged in the Server.

The client API don't know about all Users connected to the server side but only about those that are in the same Rooms where the client is joined.

In order to interact with other Users the client can join different Rooms or use a BuddyList to keep track of and interact with his friends.

Member Function Documentation

◆ ContainsVariable()

bool Sfs2X::Entities::SFSUser::ContainsVariable ( string  name)
virtual

Check if a UserVariable exists

Parameters
namethe name of the variable
Returns
true if the UserVariable exists
See also
UserVariable

Implements Sfs2X::Entities::User.

◆ GetPlayerId()

long int Sfs2X::Entities::SFSUser::GetPlayerId ( boost::shared_ptr< Room >  room)
virtual

Return the playerId for the specific Room.

If you don't use multi-room you can use User.PlayerId

Parameters
roomPointer to a Room instance
Returns
A long integer
See also
PlayerId

Implements Sfs2X::Entities::User.

◆ GetVariable()

boost::shared_ptr< UserVariable > Sfs2X::Entities::SFSUser::GetVariable ( string  varName)
virtual

Get a UserVariable

Parameters
varNamethe name of the variable
Returns
the UserVariable or null if the variable doesn't exist
See also
UserVariable

Implements Sfs2X::Entities::User.

◆ GetVariables()

boost::shared_ptr< vector< boost::shared_ptr< UserVariable > > > Sfs2X::Entities::SFSUser::GetVariables ( )
virtual

Get all the User Variables

Returns
A vector of UserVariable pointers
See also
UserVariable

Implements Sfs2X::Entities::User.

◆ Id()

long int Sfs2X::Entities::SFSUser::Id ( )
virtual

Get the unique User Id

Implements Sfs2X::Entities::User.

◆ IsAdmin()

bool Sfs2X::Entities::SFSUser::IsAdmin ( )
virtual

Return true if the User is logged in as administrator user

Returns
A boolean

Implements Sfs2X::Entities::User.

◆ IsGuest()

bool Sfs2X::Entities::SFSUser::IsGuest ( )
virtual

Return true if the User is logged in as guest user

Returns
A boolean

Implements Sfs2X::Entities::User.

◆ IsItMe()

bool Sfs2X::Entities::SFSUser::IsItMe ( )
virtual

Return true if the User object is the client's User object, also known as SmartFox.MySelf

Implements Sfs2X::Entities::User.

◆ IsJoinedInRoom()

bool Sfs2X::Entities::SFSUser::IsJoinedInRoom ( boost::shared_ptr< Room >  room)
virtual

Return true if the User is joined in the specified Room

Parameters
roomPointer to a Room instance
Returns
A boolean

Implements Sfs2X::Entities::User.

◆ IsModerator()

bool Sfs2X::Entities::SFSUser::IsModerator ( )
virtual

Return true if the User is logged in as moderator user

Returns
A boolean

Implements Sfs2X::Entities::User.

◆ IsPlayer()

bool Sfs2X::Entities::SFSUser::IsPlayer ( )
virtual

Return true if the User is a Player (playerId > 0) in the last joined Room

Non game Rooms will always return false

See also
SmartFox.LastJoinedRoom

Implements Sfs2X::Entities::User.

◆ IsPlayerInRoom()

bool Sfs2X::Entities::SFSUser::IsPlayerInRoom ( boost::shared_ptr< Room >  room)
virtual

Return true if the User is a Player in the specified Room

Parameters
roomPointer to a Room instance
Returns
A boolean

Implements Sfs2X::Entities::User.

◆ IsSpectator()

bool Sfs2X::Entities::SFSUser::IsSpectator ( )
virtual

Return true if the User is a Spectator (playerId < 0) in the last joined Room

Non game Rooms will always return false

See also
SmartFox.LastJoinedRoom

Implements Sfs2X::Entities::User.

◆ IsSpectatorInRoom()

bool Sfs2X::Entities::SFSUser::IsSpectatorInRoom ( boost::shared_ptr< Room >  room)
virtual

Return true if the User is a Spectator in the specified Room

Parameters
roomPointer to a Room instance
Returns
A boolean

Implements Sfs2X::Entities::User.

◆ IsStandardUser()

bool Sfs2X::Entities::SFSUser::IsStandardUser ( )
virtual

Return true if the User is logged in as standard user

Returns
A boolean

Implements Sfs2X::Entities::User.

◆ Name()

boost::shared_ptr< string > Sfs2X::Entities::SFSUser::Name ( )
virtual

The user name

Implements Sfs2X::Entities::User.

◆ PlayerId()

long int Sfs2X::Entities::SFSUser::PlayerId ( )
virtual

Get the playerId of the User.

The playerId is different from the User ID and it used to indicate which player number is the user inside a Game Room. Example: in a Game Room for 5 players the first client joining will have playerId = 1, the 2nd will have playerId = 2 and so forth. When a User leaves the Room its player slot is freed up and the next User joining the Room will take it.

The playerId is only applicable for Game Rooms, in the other Rooms it is always == 0 A playerId < 0 indicates that the User is a spectator.

If the User is joined in multiple game Rooms at the same time he will be assigned one playerId per Room. In order to obtain a specific playerId you can use the User.GetPlayerId(Room room) method.

Implements Sfs2X::Entities::User.

◆ PrivilegeId() [1/2]

long int Sfs2X::Entities::SFSUser::PrivilegeId ( )
virtual

Get the privilegeId of the User

See also
UserPrivileges

Implements Sfs2X::Entities::User.

◆ PrivilegeId() [2/2]

void Sfs2X::Entities::SFSUser::PrivilegeId ( long int  value)
virtual

Get the privilegeId of the User

See also
UserPrivileges

Implements Sfs2X::Entities::User.

◆ Properties() [1/2]

boost::shared_ptr< map< string, boost::shared_ptr< void > > > Sfs2X::Entities::SFSUser::Properties ( )
virtual

A generic object that can be used to store any User custom data needed at runtime.

The values added/removed in this object are for client side use only an are never transmitted to the Server.

Implements Sfs2X::Entities::User.

◆ Properties() [2/2]

void Sfs2X::Entities::SFSUser::Properties ( boost::shared_ptr< map< string, boost::shared_ptr< void > > >  value)
virtual

A generic object that can be used to store any User custom data needed at runtime.

The values added/removed in this object are for client side use only an are never transmitted to the Server.

Implements Sfs2X::Entities::User.

◆ UserManager() [1/2]

boost::shared_ptr< IUserManager > Sfs2X::Entities::SFSUser::UserManager ( )
virtual

Get the UserManager of this User

See also
SFSUserManager

Implements Sfs2X::Entities::User.

◆ UserManager() [2/2]

void Sfs2X::Entities::SFSUser::UserManager ( boost::shared_ptr< IUserManager value)
virtual

Get the UserManager of this User

See also
SFSUserManager

Implements Sfs2X::Entities::User.