SmartFoxServer 3 C++ Client API 3.1.0-beta
Client API for SmartFoxServer 3
Loading...
Searching...
No Matches
sfs3::entities::SFSUser Class Reference

The standard implementation of User: a client logged in SmartFoxServer. More...

#include <SFSUser.h>

Inheritance diagram for sfs3::entities::SFSUser:
[legend]

Public Member Functions

int32_t getId () const override
std::string getName () const override
int32_t getPlayerId () const override
 Returns the id of this user as a player in a Game Room.
int32_t getPlayerId (const Room *room) const override
 Returns the player id of this user in the given Room.
bool isPlayer () const override
 Tells if this user is a player in the last joined Room, that is, his player id is greater than 0.
bool isSpectator () const override
 Tells if this user is a spectator in the last joined Room, that is, his player id is lower than 0.
bool isPlayerInRoom (const Room *room) const override
 Tells if this user is a player in the given Room.
bool isSpectatorInRoom (const Room *room) const override
 Tells if this user is a spectator in the given Room.
bool isJoinedInRoom (const Room *room) const override
 Tells if this user joined the given Room.
int32_t getPrivilegeId () const override
 Returns the id of the privilege level of this user.
core::UserManagergetUserManager () const override
bool isGuest () const override
 Tells if this user logged in as a guest or not.
bool isStandardUser () const override
 Tells if this user logged in as a standard user or not.
bool isModerator () const override
 Tells if this user logged in as a moderator or not.
bool isAdmin () const override
 Tells if this user logged in as an administrator or not.
bool isItMe () const override
 Tells if this User object represents the current client.
std::vector< std::shared_ptr< UserVariable > > getVariables () const override
std::shared_ptr< UserVariablegetVariable (const std::string &varName) const override
 Retrieves a User Variable from its name.
bool containsVariable (const std::string &name) const override
 Tells if this user has the given User Variable set or not.
std::optional< Vec3DgetAOIEntryPoint () const override
 Returns the point inside the current user's Area of Interest where this user "appeared" with the last proximity list update, in an MMORoom.

Detailed Description

The standard implementation of User: a client logged in SmartFoxServer.

The client API does not know every user connected to the server, but only the ones inside the Rooms the current client joined. This keeps the traffic between client and server much lower. To interact with other users, join more Rooms or use the Buddy List system to follow your friends.

See also
User
SmartFox::getUserManager
SmartFox::getBuddyManager
requests::JoinRoomRequest

Member Function Documentation

◆ getId()

int32_t sfs3::entities::SFSUser::getId ( ) const
inlineoverridevirtual
Returns
the id of this user, unique and generated by the server when the user is created

Implements sfs3::entities::User.

◆ getName()

std::string sfs3::entities::SFSUser::getName ( ) const
inlineoverridevirtual
Returns
the name of this user. Two users in the same Zone cannot have the same name. The comparison is case sensitive.

Implements sfs3::entities::User.

◆ getPlayerId() [1/2]

int32_t sfs3::entities::SFSUser::getPlayerId ( ) const
overridevirtual

Returns the id of this user as a player in a Game Room.

This is not the same as the id: it says which player number the user got inside a Game Room. For example, in a Game Room for 5 players the first client that joins gets player id 1, the second gets 2, and so on. When a user leaves the Room his slot is freed, and the next user who joins takes it.

The player id applies to Game Rooms only: in a standard Room it is always 0. In a Game Room a value lower than 0 means the user is a spectator.

A user inside more than one Game Room at the same time has a different player id in each of them. This method returns the value for the last joined Room; to read the value in a specific Room, use User::getPlayerId(const Room*) const.

Returns
the player id in the last joined Game Room

Implements sfs3::entities::User.

◆ getPlayerId() [2/2]

int32_t sfs3::entities::SFSUser::getPlayerId ( const Room * room) const
overridevirtual

Returns the player id of this user in the given Room.

Parameters
roomThe Room to read the player id from.
Returns
The player id of this user in that Room.
See also
User::getPlayerId() const

Implements sfs3::entities::User.

◆ isPlayer()

bool sfs3::entities::SFSUser::isPlayer ( ) const
overridevirtual

Tells if this user is a player in the last joined Room, that is, his player id is greater than 0.

A non-Game Room always gives false. For a user inside more than one Game Room at the same time, use User::isPlayerInRoom instead.

Returns
true if this user is a player
See also
User::getPlayerId() const
User::isSpectator

Implements sfs3::entities::User.

◆ isSpectator()

bool sfs3::entities::SFSUser::isSpectator ( ) const
overridevirtual

Tells if this user is a spectator in the last joined Room, that is, his player id is lower than 0.

A non-Game Room always gives false. For a user inside more than one Game Room at the same time, use User::isSpectatorInRoom instead.

Returns
true if this user is a spectator
See also
User::getPlayerId() const
User::isPlayer

Implements sfs3::entities::User.

◆ isPlayerInRoom()

bool sfs3::entities::SFSUser::isPlayerInRoom ( const Room * room) const
overridevirtual

Tells if this user is a player in the given Room.

A non-Game Room always gives false.

Parameters
roomThe Room where to check if this user is a player.
Returns
true if this user is a player in that Room.
See also
User::isPlayer
User::isSpectatorInRoom

Implements sfs3::entities::User.

◆ isSpectatorInRoom()

bool sfs3::entities::SFSUser::isSpectatorInRoom ( const Room * room) const
overridevirtual

Tells if this user is a spectator in the given Room.

A non-Game Room always gives false.

Parameters
roomThe Room where to check if this user is a spectator.
Returns
true if this user is a spectator in that Room.
See also
User::isSpectator
User::isPlayerInRoom

Implements sfs3::entities::User.

◆ isJoinedInRoom()

bool sfs3::entities::SFSUser::isJoinedInRoom ( const Room * room) const
overridevirtual

Tells if this user joined the given Room.

Parameters
roomThe Room where to check the presence of the user.
Returns
true if this user is inside that Room.

Implements sfs3::entities::User.

◆ getPrivilegeId()

int32_t sfs3::entities::SFSUser::getPrivilegeId ( ) const
inlineoverridevirtual

Returns the id of the privilege level of this user.

The server assigns the privileges to the user when he logs in.

Returns
the privilege id
See also
entities::UserPrivileges

Implements sfs3::entities::User.

◆ getUserManager()

core::UserManager * sfs3::entities::SFSUser::getUserManager ( ) const
inlineoverridevirtual
Returns
the User Manager that manages this user

Implements sfs3::entities::User.

◆ isGuest()

bool sfs3::entities::SFSUser::isGuest ( ) const
overridevirtual

Tells if this user logged in as a guest or not.

A guest user has his privilege id set to UserPrivileges::GUEST.

Returns
true if this user is a guest
See also
User::getPrivilegeId
UserPrivileges

Implements sfs3::entities::User.

◆ isStandardUser()

bool sfs3::entities::SFSUser::isStandardUser ( ) const
overridevirtual

Tells if this user logged in as a standard user or not.

A standard user has his privilege id set to UserPrivileges::STANDARD.

Returns
true if this user is a standard user
See also
User::getPrivilegeId
UserPrivileges

Implements sfs3::entities::User.

◆ isModerator()

bool sfs3::entities::SFSUser::isModerator ( ) const
overridevirtual

Tells if this user logged in as a moderator or not.

A moderator has his privilege id set to UserPrivileges::MODERATOR.

Returns
true if this user is a moderator
See also
User::getPrivilegeId
UserPrivileges

Implements sfs3::entities::User.

◆ isAdmin()

bool sfs3::entities::SFSUser::isAdmin ( ) const
overridevirtual

Tells if this user logged in as an administrator or not.

An administrator has his privilege id set to UserPrivileges::ADMINISTRATOR.

Returns
true if this user is an administrator
See also
User::getPrivilegeId
UserPrivileges

Implements sfs3::entities::User.

◆ isItMe()

bool sfs3::entities::SFSUser::isItMe ( ) const
inlineoverridevirtual

Tells if this User object represents the current client.

Returns
true if this is the current client
See also
SmartFox::getMySelf

Implements sfs3::entities::User.

◆ getVariables()

std::vector< std::shared_ptr< UserVariable > > sfs3::entities::SFSUser::getVariables ( ) const
overridevirtual
Returns
all the User Variables of this user
See also
UserVariable
User::getVariable

Implements sfs3::entities::User.

◆ getVariable()

std::shared_ptr< UserVariable > sfs3::entities::SFSUser::getVariable ( const std::string & varName) const
overridevirtual

Retrieves a User Variable from its name.

Parameters
varNameThe name of the User Variable to find.
Returns
The User Variable, or nullptr if this user has no variable with that name.
See also
User::getVariables
requests::SetUserVariablesRequest

Implements sfs3::entities::User.

◆ containsVariable()

bool sfs3::entities::SFSUser::containsVariable ( const std::string & name) const
overridevirtual

Tells if this user has the given User Variable set or not.

Parameters
nameThe name of the User Variable to look for.
Returns
true if a User Variable with that name is set for this user.

Implements sfs3::entities::User.

◆ getAOIEntryPoint()

std::optional< Vec3D > sfs3::entities::SFSUser::getAOIEntryPoint ( ) const
inlineoverridevirtual

Returns the point inside the current user's Area of Interest where this user "appeared" with the last proximity list update, in an MMORoom.

It is set only when the MMORoom is configured to send the entry points; otherwise the optional stays empty.

Returns
the entry point, or an empty optional
See also
requests::MMOSettings::sendAOIEntryPoint
SFSEvent::PROXIMITY_LIST_UPDATE

Implements sfs3::entities::User.


The documentation for this class was generated from the following files:
  • entities/SFSUser.h
  • entities/SFSUser.cpp