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

A Room in a Zone. More...

#include <Room.h>

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

Public Member Functions

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

Detailed Description

A Room in a Zone.

SFSRoom is the standard implementation of this interface.

The setters are for the API itself: a value set by hand has no effect on the server and can disrupt the working of the API. Use the matching request to change a Room instead.

See also
SFSRoom

Member Function Documentation

◆ getId()

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

Implemented in sfs3::entities::SFSRoom.

◆ getName()

virtual std::string sfs3::entities::Room::getName ( ) const
pure virtual

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

Implemented in sfs3::entities::SFSRoom.

◆ getType()

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

Implemented in sfs3::entities::SFSRoom.

◆ getGroupId()

virtual std::optional< std::string > sfs3::entities::Room::getGroupId ( ) const
pure virtual

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

Implemented in sfs3::entities::SFSRoom.

◆ getMaxUsers()

virtual int32_t sfs3::entities::Room::getMaxUsers ( ) const
pure virtual

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

Implemented in sfs3::entities::SFSRoom.

◆ getMaxSpectators()

virtual int32_t sfs3::entities::Room::getMaxSpectators ( ) const
pure virtual

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

Implemented in sfs3::entities::SFSRoom.

◆ getUserCount()

virtual int32_t sfs3::entities::Room::getUserCount ( ) const
pure virtual

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

Implemented in sfs3::entities::SFSRoom.

◆ getSpectatorCount()

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

Implemented in sfs3::entities::SFSRoom.

◆ getPlayerList()

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

Implemented in sfs3::entities::SFSRoom.

◆ getSpectatorList()

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

Implemented in sfs3::entities::SFSRoom.

◆ isGame()

virtual bool sfs3::entities::Room::isGame ( ) const
pure virtual

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

Implemented in sfs3::entities::SFSRoom.

◆ isHidden()

virtual bool sfs3::entities::Room::isHidden ( ) const
pure virtual

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

Implemented in sfs3::entities::SFSRoom.

◆ isJoined()

virtual bool sfs3::entities::Room::isJoined ( ) const
pure virtual

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

Implemented in sfs3::entities::SFSRoom.

◆ isPasswordProtected()

virtual bool sfs3::entities::Room::isPasswordProtected ( ) const
pure virtual

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

Implemented in sfs3::entities::SFSRoom.

◆ containsUser()

virtual bool sfs3::entities::Room::containsUser ( std::shared_ptr< entities::User > user) const
pure virtual

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

Implemented in sfs3::entities::SFSRoom.

◆ getUserById()

virtual std::shared_ptr< User > sfs3::entities::Room::getUserById ( int32_t id) const
pure virtual

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

Implemented in sfs3::entities::SFSRoom.

◆ getUserByName()

virtual std::shared_ptr< User > sfs3::entities::Room::getUserByName ( const std::string & name) const
pure virtual

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

Implemented in sfs3::entities::SFSRoom.

◆ getUserList()

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

Implemented in sfs3::entities::SFSRoom.

◆ roomManager()

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

Implemented in sfs3::entities::SFSRoom.

◆ getVariable()

virtual std::shared_ptr< RoomVariable > sfs3::entities::Room::getVariable ( const std::string & name) const
pure virtual

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

Implemented in sfs3::entities::SFSRoom.

◆ getVariables()

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

Implemented in sfs3::entities::SFSRoom.

◆ containsVariable()

virtual bool sfs3::entities::Room::containsVariable ( const std::string & name) const
pure virtual

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

Implemented in sfs3::entities::SFSRoom.

◆ toString()

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

Implemented in sfs3::entities::MMORoom, and sfs3::entities::SFSRoom.


The documentation for this class was generated from the following file: