Cockatrice 2026-10-19-Development-3.1.2-beta.2
A virtual tabletop for multiplayer card games
Loading...
Searching...
No Matches
Server_Room Class Reference

#include <server_room.h>

Inheritance diagram for Server_Room:
[legend]
Collaboration diagram for Server_Room:
[legend]

Signals

void roomInfoChanged (const ServerInfo_Room &roomInfo)
void gameListChanged (const ServerInfo_Game &gameInfo)

Public Member Functions

 Server_Room (int _id, int _chatHistorySize, const QString &_name, const QString &_description, const QString &_permissionLevel, const QString &_privilegeLevel, bool _autoJoin, const QString &_joinMessage, const QStringList &_gameTypes, Server *parent, const QList< ServerInfo_RoomChannel > &_channels={})
 ~Server_Room () override
int getId () const
QString getName () const
QString getDescription () const
QString getRoomPermission () const
QString getRoomPrivilege () const
bool getAutoJoin () const
bool userMayJoin (const ServerInfo_User &userInfo)
QString getJoinMessage () const
const QStringList & getGameTypes () const
const QList< ServerInfo_RoomChannel > & getChannels () const
const ServerInfo_RoomChannel * findChannel (const QString &channelId) const
 Looks up a catalog channel by its stable id.
const QMap< int, Server_Game * > & getGames () const
const QMap< int, ServerInfo_Game > & getExternalGames () const
Server * getServer () const
const ServerInfo_Room & getInfo (ServerInfo_Room &result, bool complete, bool showGameTypes=false, bool includeExternalData=true, const ServerInfo_User *forUser=nullptr) const
int getGamesCreatedByUser (const QString &name) const
QList< ServerInfo_Game > getGamesOfUser (const QString &name) const
QList< ServerInfo_ChatMessage > getChatHistory (const QString &channelId) const
void addClient (Server_ProtocolHandler *client)
void removeClient (Server_ProtocolHandler *client)
void addExternalUser (const ServerInfo_User &userInfo)
void removeExternalUser (const QString &_name)
const QMap< QString, ServerInfo_User_Container > & getExternalUsers () const
void updateExternalGameList (const ServerInfo_Game &gameInfo)
Response::ResponseCode processJoinGameCommand (const Command_JoinGame &cmd, ResponseContainer &rc, Server_AbstractUserInterface *userInterface)
void say (const QString &userName, const QString &s, const QString &channelId=QString(), bool sendToIsl=true)
void removeSaidMessages (const QString &userName, int amount, bool sendToIsl=true)
void addGame (Server_Game *game)
void removeGame (Server_Game *game)
void sendRoomEvent (RoomEvent *event, bool sendToIsl=true, ServerInfo_RoomChannel::AccessLevel accessLevel=ServerInfo_RoomChannel::Public)
RoomEvent * prepareRoomEvent (const ::google::protobuf::Message &roomEvent)

Static Public Member Functions

static bool isMainChannel (const QString &channelId)
 True when channelId refers to the implicit Main channel.
static bool hasChannelPrivilege (const ServerInfo_User &userInfo, ServerInfo_RoomChannel::AccessLevel requiredLevel)
 True when the flags in userInfo satisfy requiredLevel.
static bool mayReadChannel (const ServerInfo_User &userInfo, const ServerInfo_RoomChannel &channel)
 True when userInfo may read channel.
static bool mayWriteChannel (const ServerInfo_User &userInfo, const ServerInfo_RoomChannel &channel)
 True when userInfo may write to channel.

Public Attributes

QReadWriteLock usersLock
QReadWriteLock gamesLock
QReadWriteLock historyLock

Static Public Attributes

static const QString MAIN_CHANNEL_KEY = QStringLiteral("__main__")

Private Slots

void broadcastGameListUpdate (const ServerInfo_Game &gameInfo, bool sendToIsl=true)

Private Attributes

int id
int chatHistorySize
QString name
QString description
QString permissionLevel
QString privilegeLevel
bool autoJoin
QString joinMessage
QStringList gameTypes
QList< ServerInfo_RoomChannel > channels
QMap< int, Server_Game * > games
QMap< int, ServerInfo_Game > externalGames
QMap< QString, Server_ProtocolHandler * > users
QMap< QString, ServerInfo_User_Container > externalUsers
QMap< QString, QList< ServerInfo_ChatMessage > > channelChatHistory

Constructor & Destructor Documentation

◆ Server_Room()

Server_Room::Server_Room ( int _id,
int _chatHistorySize,
const QString & _name,
const QString & _description,
const QString & _permissionLevel,
const QString & _privilegeLevel,
bool _autoJoin,
const QString & _joinMessage,
const QStringList & _gameTypes,
Server * parent,
const QList< ServerInfo_RoomChannel > & _channels = {} )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ~Server_Room()

Server_Room::~Server_Room ( )
override

Member Function Documentation

◆ addClient()

void Server_Room::addClient ( Server_ProtocolHandler * client)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ addExternalUser()

void Server_Room::addExternalUser ( const ServerInfo_User & userInfo)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ addGame()

void Server_Room::addGame ( Server_Game * game)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ broadcastGameListUpdate

void Server_Room::broadcastGameListUpdate ( const ServerInfo_Game & gameInfo,
bool sendToIsl = true )
privateslot
Here is the call graph for this function:
Here is the caller graph for this function:

◆ findChannel()

const ServerInfo_RoomChannel * Server_Room::findChannel ( const QString & channelId) const

Looks up a catalog channel by its stable id.

Returns
The matching channel, or nullptr when the id is not in the catalog.
Here is the caller graph for this function:

◆ gameListChanged

void Server_Room::gameListChanged ( const ServerInfo_Game & gameInfo)
signal
Here is the caller graph for this function:

◆ getAutoJoin()

bool Server_Room::getAutoJoin ( ) const
inline

◆ getChannels()

const QList< ServerInfo_RoomChannel > & Server_Room::getChannels ( ) const
inline
Here is the caller graph for this function:

◆ getChatHistory()

QList< ServerInfo_ChatMessage > Server_Room::getChatHistory ( const QString & channelId) const
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getDescription()

QString Server_Room::getDescription ( ) const
inline

◆ getExternalGames()

const QMap< int, ServerInfo_Game > & Server_Room::getExternalGames ( ) const
inline
Here is the caller graph for this function:

◆ getExternalUsers()

const QMap< QString, ServerInfo_User_Container > & Server_Room::getExternalUsers ( ) const
inline
Here is the caller graph for this function:

◆ getGames()

const QMap< int, Server_Game * > & Server_Room::getGames ( ) const
inline
Here is the caller graph for this function:

◆ getGamesCreatedByUser()

int Server_Room::getGamesCreatedByUser ( const QString & name) const
Here is the caller graph for this function:

◆ getGamesOfUser()

QList< ServerInfo_Game > Server_Room::getGamesOfUser ( const QString & name) const
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getGameTypes()

const QStringList & Server_Room::getGameTypes ( ) const
inline
Here is the caller graph for this function:

◆ getId()

int Server_Room::getId ( ) const
inline
Here is the caller graph for this function:

◆ getInfo()

const ServerInfo_Room & Server_Room::getInfo ( ServerInfo_Room & result,
bool complete,
bool showGameTypes = false,
bool includeExternalData = true,
const ServerInfo_User * forUser = nullptr ) const
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getJoinMessage()

QString Server_Room::getJoinMessage ( ) const
inline
Here is the caller graph for this function:

◆ getName()

QString Server_Room::getName ( ) const
inline
Here is the caller graph for this function:

◆ getRoomPermission()

QString Server_Room::getRoomPermission ( ) const
inline

◆ getRoomPrivilege()

QString Server_Room::getRoomPrivilege ( ) const
inline

◆ getServer()

Server * Server_Room::getServer ( ) const
Here is the caller graph for this function:

◆ hasChannelPrivilege()

bool Server_Room::hasChannelPrivilege ( const ServerInfo_User & userInfo,
ServerInfo_RoomChannel::AccessLevel requiredLevel )
static

True when the flags in userInfo satisfy requiredLevel.

User flags are independent bits, not a ladder: IsDeveloper does not imply IsModerator or IsAdmin, so developer-only users cannot read or post in moderator/admin channels. Admins hold the moderator bit alongside the admin bit and moderators are admitted to judge channels.

Here is the caller graph for this function:

◆ isMainChannel()

bool Server_Room::isMainChannel ( const QString & channelId)
static

True when channelId refers to the implicit Main channel.

Here is the caller graph for this function:

◆ mayReadChannel()

bool Server_Room::mayReadChannel ( const ServerInfo_User & userInfo,
const ServerInfo_RoomChannel & channel )
static

True when userInfo may read channel.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mayWriteChannel()

bool Server_Room::mayWriteChannel ( const ServerInfo_User & userInfo,
const ServerInfo_RoomChannel & channel )
static

True when userInfo may write to channel.

Writing requires the channel's write level, or — when no explicit write level is configured — the same level as reading.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ prepareRoomEvent()

RoomEvent * Server_Room::prepareRoomEvent ( const ::google::protobuf::Message & roomEvent)
Here is the caller graph for this function:

◆ processJoinGameCommand()

Response::ResponseCode Server_Room::processJoinGameCommand ( const Command_JoinGame & cmd,
ResponseContainer & rc,
Server_AbstractUserInterface * userInterface )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ removeClient()

void Server_Room::removeClient ( Server_ProtocolHandler * client)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ removeExternalUser()

void Server_Room::removeExternalUser ( const QString & _name)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ removeGame()

void Server_Room::removeGame ( Server_Game * game)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ removeSaidMessages()

void Server_Room::removeSaidMessages ( const QString & userName,
int amount,
bool sendToIsl = true )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ roomInfoChanged

void Server_Room::roomInfoChanged ( const ServerInfo_Room & roomInfo)
signal
Here is the caller graph for this function:

◆ say()

void Server_Room::say ( const QString & userName,
const QString & s,
const QString & channelId = QString(),
bool sendToIsl = true )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ sendRoomEvent()

void Server_Room::sendRoomEvent ( RoomEvent * event,
bool sendToIsl = true,
ServerInfo_RoomChannel::AccessLevel accessLevel = ServerInfo_RoomChannel::Public )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ updateExternalGameList()

void Server_Room::updateExternalGameList ( const ServerInfo_Game & gameInfo)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ userMayJoin()

bool Server_Room::userMayJoin ( const ServerInfo_User & userInfo)
Here is the caller graph for this function:

Member Data Documentation

◆ autoJoin

bool Server_Room::autoJoin
private

◆ channelChatHistory

QMap<QString, QList<ServerInfo_ChatMessage> > Server_Room::channelChatHistory
private

◆ channels

QList<ServerInfo_RoomChannel> Server_Room::channels
private

◆ chatHistorySize

int Server_Room::chatHistorySize
private

◆ description

QString Server_Room::description
private

◆ externalGames

QMap<int, ServerInfo_Game> Server_Room::externalGames
private

◆ externalUsers

QMap<QString, ServerInfo_User_Container> Server_Room::externalUsers
private

◆ games

QMap<int, Server_Game *> Server_Room::games
private

◆ gamesLock

QReadWriteLock Server_Room::gamesLock
mutable

◆ gameTypes

QStringList Server_Room::gameTypes
private

◆ historyLock

QReadWriteLock Server_Room::historyLock
mutable

◆ id

int Server_Room::id
private

◆ joinMessage

QString Server_Room::joinMessage
private

◆ MAIN_CHANNEL_KEY

const QString Server_Room::MAIN_CHANNEL_KEY = QStringLiteral("__main__")
static

◆ name

QString Server_Room::name
private

◆ permissionLevel

QString Server_Room::permissionLevel
private

◆ privilegeLevel

QString Server_Room::privilegeLevel
private

◆ users

QMap<QString, Server_ProtocolHandler *> Server_Room::users
private

◆ usersLock

QReadWriteLock Server_Room::usersLock
mutable

The documentation for this class was generated from the following files:
  • libcockatrice_network/libcockatrice/network/server/remote/server_room.h
  • libcockatrice_network/libcockatrice/network/server/remote/server_room.cpp