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

The standard implementation of Room: a SmartFoxServer Room on the client. More...

#include <SFSRoom.h>

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

Public Member Functions

int32_t getId () const override
std::string getName () const override
 Returns the unique name of this Room.
RoomType getType () const override
std::optional< std::string > getGroupId () const override
 Returns the name of the Group this Room belongs to.
int32_t getUserCount () const override
 Returns the current number of users in this Room.
int32_t getSpectatorCount () const override
int32_t getMaxUsers () const override
 Returns the maximum number of users allowed in this Room.
int32_t getMaxSpectators () const override
 Returns the maximum number of spectators allowed in this Room.
std::vector< std::shared_ptr< User > > getPlayerList () const override
std::vector< std::shared_ptr< User > > getSpectatorList () const override
bool isGame () const override
 Tells if this is a Game Room or not.
bool isHidden () const override
 Tells if this Room is hidden or not.
bool isJoined () const override
 Tells if the client joined this Room or not.
bool isPasswordProtected () const override
 Tells if this Room needs a password to be joined or not.
bool containsUser (std::shared_ptr< entities::User > user) const override
 Tells if the given user is currently inside this Room or not.
std::shared_ptr< UsergetUserById (int32_t id) const override
 Retrieves a user inside this Room from his id.
std::shared_ptr< UsergetUserByName (const std::string &name) const override
 Retrieves a user inside this Room from his name.
std::vector< std::shared_ptr< User > > getUserList () const override
core::RoomManagerroomManager () const override
std::shared_ptr< RoomVariablegetVariable (const std::string &name) const override
 Retrieves a Room Variable from its name.
std::vector< std::shared_ptr< RoomVariable > > getVariables () const override
bool containsVariable (const std::string &name) const override
 Tells if this Room has the given Room Variable set or not.
std::string toString () const override

Detailed Description

The standard implementation of Room: a SmartFoxServer Room on the client.

The client API does not know all the Rooms that exist on the server, but only the ones the user joined and the ones in the Room Groups he subscribed. A subscription to a Group lets the client listen to the events of every Room in that Group.

The list of available Rooms is built after a successful login, and the server keeps it up to date.

See also
Room
SmartFox::getRoomManager
requests::CreateRoomRequest
requests::JoinRoomRequest
requests::SubscribeRoomGroupRequest
requests::UnsubscribeRoomGroupRequest

Member Function Documentation

◆ getId()

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

Implements sfs3::entities::Room.

◆ getName()

std::string sfs3::entities::SFSRoom::getName ( ) const
inlineoverridevirtual

Returns the unique name of this Room.

Two Rooms in the same Zone cannot have the same name. The comparison is case sensitive.

To rename a Room, send a requests::ChangeRoomNameRequest.

Returns
the name of this Room
See also
requests::ChangeRoomNameRequest

Implements sfs3::entities::Room.

◆ getType()

RoomType sfs3::entities::SFSRoom::getType ( ) const
inlineoverridevirtual
Returns
the kind of this Room: a plain Room, a Game Room or an MMORoom
See also
RoomType

Implements sfs3::entities::Room.

◆ getGroupId()

std::optional< std::string > sfs3::entities::SFSRoom::getGroupId ( ) const
inlineoverridevirtual

Returns the name of the Group this Room belongs to.

Each Group is identified by a unique string, its name, and it is a different "container" for Rooms. Groups let you sort the Rooms by type or category, and let a client select only the Groups it needs, to receive the events of those Rooms only. A client subscribes and unsubscribes a Group with a requests::SubscribeRoomGroupRequest and a requests::UnsubscribeRoomGroupRequest.

The default value is DEFAULT_ROOM_GROUP_ID.

Returns
the name of the Group
See also
requests::SubscribeRoomGroupRequest
requests::UnsubscribeRoomGroupRequest

Implements sfs3::entities::Room.

◆ getUserCount()

int32_t sfs3::entities::SFSRoom::getUserCount ( ) const
overridevirtual

Returns the current number of users in this Room.

In a Game Room this is the number of players.

Returns
the current number of users

Implements sfs3::entities::Room.

◆ getSpectatorCount()

int32_t sfs3::entities::SFSRoom::getSpectatorCount ( ) const
overridevirtual
Returns
the current number of spectators in this Room. Game Rooms only.

Implements sfs3::entities::Room.

◆ getMaxUsers()

int32_t sfs3::entities::SFSRoom::getMaxUsers ( ) const
inlineoverridevirtual

Returns the maximum number of users allowed in this Room.

In a Game Room this is the maximum number of players. The value is set when the Room is created.

Returns
the maximum number of users

Implements sfs3::entities::Room.

◆ getMaxSpectators()

int32_t sfs3::entities::SFSRoom::getMaxSpectators ( ) const
inlineoverridevirtual

Returns the maximum number of spectators allowed in this Room.

Game Rooms only.

The value is set when the Room is created.

Returns
the maximum number of spectators

Implements sfs3::entities::Room.

◆ getPlayerList()

std::vector< std::shared_ptr< User > > sfs3::entities::SFSRoom::getPlayerList ( ) const
overridevirtual
Returns
the players currently inside this Room. Game Rooms only.

Implements sfs3::entities::Room.

◆ getSpectatorList()

std::vector< std::shared_ptr< User > > sfs3::entities::SFSRoom::getSpectatorList ( ) const
overridevirtual
Returns
the spectators currently inside this Room. Game Rooms only.

Implements sfs3::entities::Room.

◆ isGame()

bool sfs3::entities::SFSRoom::isGame ( ) const
overridevirtual

Tells if this is a Game Room or not.

The flag is set when the Room is created.

Returns
true if this is a Game Room

Implements sfs3::entities::Room.

◆ isHidden()

bool sfs3::entities::SFSRoom::isHidden ( ) const
overridevirtual

Tells if this Room is hidden or not.

This flag is a convenience for developers, to keep certain Rooms out of the interface of their application. It is set when the Room is created.

Returns
true if this Room is hidden

Implements sfs3::entities::Room.

◆ isJoined()

bool sfs3::entities::SFSRoom::isJoined ( ) const
overridevirtual

Tells if the client joined this Room or not.

To join a Room, send a requests::JoinRoomRequest.

Returns
true if the client is inside this Room
See also
requests::JoinRoomRequest

Implements sfs3::entities::Room.

◆ isPasswordProtected()

bool sfs3::entities::SFSRoom::isPasswordProtected ( ) const
overridevirtual

Tells if this Room needs a password to be joined or not.

The flag depends on the password set when the Room is created, or later with a requests::ChangeRoomPasswordStateRequest.

Returns
true if this Room is protected by a password
See also
requests::ChangeRoomPasswordStateRequest

Implements sfs3::entities::Room.

◆ containsUser()

bool sfs3::entities::SFSRoom::containsUser ( std::shared_ptr< entities::User > user) const
overridevirtual

Tells if the given user is currently inside this Room or not.

Parameters
userthe user to look for
Returns
true if the user is inside this Room, false otherwise

Implements sfs3::entities::Room.

◆ getUserById()

std::shared_ptr< User > sfs3::entities::SFSRoom::getUserById ( int32_t id) const
overridevirtual

Retrieves a user inside this Room from his id.

Parameters
idThe id of the user to find.
Returns
The user, or nullptr if no user with that id is in this Room.
See also
Room::getUserByName

Implements sfs3::entities::Room.

◆ getUserByName()

std::shared_ptr< User > sfs3::entities::SFSRoom::getUserByName ( const std::string & name) const
overridevirtual

Retrieves a user inside this Room from his name.

Parameters
nameThe name of the user to find.
Returns
The user, or nullptr if no user with that name is in this Room.
See also
Room::getUserById

Implements sfs3::entities::Room.

◆ getUserList()

std::vector< std::shared_ptr< User > > sfs3::entities::SFSRoom::getUserList ( ) const
overridevirtual
Returns
all the users currently inside this Room

Implements sfs3::entities::Room.

◆ roomManager()

core::RoomManager * sfs3::entities::SFSRoom::roomManager ( ) const
overridevirtual
Returns
the Room Manager that manages this Room

Implements sfs3::entities::Room.

◆ getVariable()

std::shared_ptr< RoomVariable > sfs3::entities::SFSRoom::getVariable ( const std::string & name) const
overridevirtual

Retrieves a Room Variable from its name.

Parameters
nameThe name of the Room Variable to find.
Returns
The Room Variable, or nullptr if this Room has no variable with that name.
See also
Room::getVariables
requests::SetRoomVariablesRequest

Implements sfs3::entities::Room.

◆ getVariables()

std::vector< std::shared_ptr< RoomVariable > > sfs3::entities::SFSRoom::getVariables ( ) const
overridevirtual
Returns
all the Room Variables of this Room
See also
Room::getVariable
RoomVariable

Implements sfs3::entities::Room.

◆ containsVariable()

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

Tells if this Room has the given Room Variable set or not.

Parameters
nameThe name of the Room Variable to look for.
Returns
true if a Room Variable with that name exists in this Room

Implements sfs3::entities::Room.

◆ toString()

std::string sfs3::entities::SFSRoom::toString ( ) const
overridevirtual
Returns
the details of this Room as text, for logging and debugging

Implements sfs3::entities::Room.


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