Cockatrice 2025-11-30-Development-2.11.0-beta.38
A cross-platform virtual tabletop for multiplayer card games
Loading...
Searching...
No Matches
Server Class Reference

#include <server.h>

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

Signals

void pingClockTimeout ()
void sigSendIslMessage (const IslMessage &message, int serverId)
void endSession (qint64 sessionId)

Public Member Functions

 Server (QObject *parent=nullptr)
 ~Server () override=default
AuthenticationResult loginUser (Server_ProtocolHandler *session, QString &name, const QString &password, bool passwordNeedsHash, QString &reason, int &secondsLeft, QString &clientid, QString &clientVersion, QString &connectionType)
const QMap< int, Server_Room * > & getRooms ()
Server_AbstractUserInterfacefindUser (const QString &userName) const
const QMap< QString, Server_ProtocolHandler * > & getUsers () const
const QMap< qint64, Server_ProtocolHandler * > & getUsersBySessionId () const
virtual QMap< QString, bool > getServerRequiredFeatureList () const
void addClient (Server_ProtocolHandler *player)
void removeClient (Server_ProtocolHandler *player)
QList< QString > getOnlineModeratorList () const
virtual QString getLoginMessage () const
virtual QString getRequiredFeatures () const
virtual bool permitUnregisteredUsers () const
virtual bool getGameShouldPing () const
virtual bool getClientIDRequiredEnabled () const
virtual bool getRegOnlyServerEnabled () const
virtual bool getMaxUserLimitEnabled () const
virtual bool getEnableLogQuery () const
virtual bool getStoreReplaysEnabled () const
virtual int getIdleClientTimeout () const
virtual int getClientKeepAlive () const
virtual int getMaxGameInactivityTime () const
virtual int getMaxPlayerInactivityTime () const
virtual int getMessageCountingInterval () const
virtual int getMaxMessageCountPerInterval () const
virtual int getMaxMessageSizePerInterval () const
virtual int getMaxGamesPerUser () const
virtual int getCommandCountingInterval () const
virtual int getMaxCommandCountPerInterval () const
virtual int getMaxUserTotal () const
virtual int getServerID () const
virtual bool permitCreateGameAsJudge () const
Server_DatabaseInterfacegetDatabaseInterface () const
int getNextLocalGameId ()
void sendIsl_Response (const Response &item, int serverId=-1, qint64 sessionId=-1)
void sendIsl_SessionEvent (const SessionEvent &item, int serverId=-1, qint64 sessionId=-1)
void sendIsl_GameEventContainer (const GameEventContainer &item, int serverId=-1, qint64 sessionId=-1)
void sendIsl_RoomEvent (const RoomEvent &item, int serverId=-1, qint64 sessionId=-1)
void sendIsl_GameCommand (const CommandContainer &item, int serverId, qint64 sessionId, int roomId, int playerId)
void sendIsl_RoomCommand (const CommandContainer &item, int serverId, qint64 sessionId, int roomId)
const QMap< QString, Server_AbstractUserInterface * > & getExternalUsers () const
void addPersistentPlayer (const QString &userName, int roomId, int gameId, int playerId)
void removePersistentPlayer (const QString &userName, int roomId, int gameId, int playerId)
QList< PlayerReferencegetPersistentPlayerReferences (const QString &userName) const
int getUsersCount () const
int getGamesCount () const
int getTCPUserCount () const
int getWebSocketUserCount () const

Public Attributes

QReadWriteLock clientsLock
QReadWriteLock roomsLock

Protected Slots

void externalUserJoined (const ServerInfo_User &userInfo)
void externalUserLeft (const QString &userName)
void externalRoomUserJoined (int roomId, const ServerInfo_User &userInfo)
void externalRoomUserLeft (int roomId, const QString &userName)
void externalRoomSay (int roomId, const QString &userName, const QString &message)
void externalRoomRemoveMessages (int roomId, const QString &userName, int amount)
void externalRoomGameListChanged (int roomId, const ServerInfo_Game &gameInfo)
void externalJoinGameCommandReceived (const Command_JoinGame &cmd, int cmdId, int roomId, int serverId, qint64 sessionId)
void externalGameCommandContainerReceived (const CommandContainer &cont, int playerId, int serverId, qint64 sessionId)
void externalGameEventContainerReceived (const GameEventContainer &cont, qint64 sessionId)
void externalResponseReceived (const Response &resp, qint64 sessionId)
virtual void doSendIslMessage (const IslMessage &, int)

Protected Member Functions

void prepareDestroy ()
void setDatabaseInterface (Server_DatabaseInterface *_databaseInterface)
void addRoom (Server_Room *newRoom)

Protected Attributes

QList< Server_ProtocolHandler * > clients
QMap< qint64, Server_ProtocolHandler * > usersBySessionId
QMap< QString, Server_ProtocolHandler * > users
QMap< qint64, Server_AbstractUserInterface * > externalUsersBySessionId
QMap< QString, Server_AbstractUserInterface * > externalUsers
QMap< int, Server_Room * > rooms
QMap< QThread *, Server_DatabaseInterface * > databaseInterfaces

Private Slots

void broadcastRoomUpdate (const ServerInfo_Room &roomInfo, bool sendToIsl=false)

Private Attributes

QMultiMap< QString, PlayerReferencepersistentPlayers
QReadWriteLock persistentPlayersLock
int nextLocalGameId
int tcpUserCount
int webSocketUserCount
QMutex nextLocalGameIdMutex

Constructor & Destructor Documentation

◆ Server()

Server::Server ( QObject * parent = nullptr)
explicit
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ~Server()

Server::~Server ( )
overridedefault

Member Function Documentation

◆ addClient()

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

◆ addPersistentPlayer()

void Server::addPersistentPlayer ( const QString & userName,
int roomId,
int gameId,
int playerId )

◆ addRoom()

void Server::addRoom ( Server_Room * newRoom)
protected
Here is the call graph for this function:
Here is the caller graph for this function:

◆ broadcastRoomUpdate

void Server::broadcastRoomUpdate ( const ServerInfo_Room & roomInfo,
bool sendToIsl = false )
privateslot
Here is the call graph for this function:
Here is the caller graph for this function:

◆ doSendIslMessage

virtual void Server::doSendIslMessage ( const IslMessage & ,
int  )
inlineprotectedvirtualslot

Reimplemented in Servatrice.

Here is the caller graph for this function:

◆ endSession

void Server::endSession ( qint64 sessionId)
signal
Here is the caller graph for this function:

◆ externalGameCommandContainerReceived

void Server::externalGameCommandContainerReceived ( const CommandContainer & cont,
int playerId,
int serverId,
qint64 sessionId )
protectedslot
Here is the call graph for this function:
Here is the caller graph for this function:

◆ externalGameEventContainerReceived

void Server::externalGameEventContainerReceived ( const GameEventContainer & cont,
qint64 sessionId )
protectedslot
Here is the call graph for this function:
Here is the caller graph for this function:

◆ externalJoinGameCommandReceived

void Server::externalJoinGameCommandReceived ( const Command_JoinGame & cmd,
int cmdId,
int roomId,
int serverId,
qint64 sessionId )
protectedslot
Here is the call graph for this function:
Here is the caller graph for this function:

◆ externalResponseReceived

void Server::externalResponseReceived ( const Response & resp,
qint64 sessionId )
protectedslot
Here is the call graph for this function:
Here is the caller graph for this function:

◆ externalRoomGameListChanged

void Server::externalRoomGameListChanged ( int roomId,
const ServerInfo_Game & gameInfo )
protectedslot
Here is the call graph for this function:
Here is the caller graph for this function:

◆ externalRoomRemoveMessages

void Server::externalRoomRemoveMessages ( int roomId,
const QString & userName,
int amount )
protectedslot
Here is the call graph for this function:
Here is the caller graph for this function:

◆ externalRoomSay

void Server::externalRoomSay ( int roomId,
const QString & userName,
const QString & message )
protectedslot
Here is the call graph for this function:
Here is the caller graph for this function:

◆ externalRoomUserJoined

void Server::externalRoomUserJoined ( int roomId,
const ServerInfo_User & userInfo )
protectedslot
Here is the call graph for this function:
Here is the caller graph for this function:

◆ externalRoomUserLeft

void Server::externalRoomUserLeft ( int roomId,
const QString & userName )
protectedslot
Here is the call graph for this function:
Here is the caller graph for this function:

◆ externalUserJoined

void Server::externalUserJoined ( const ServerInfo_User & userInfo)
protectedslot
Here is the call graph for this function:
Here is the caller graph for this function:

◆ externalUserLeft

void Server::externalUserLeft ( const QString & userName)
protectedslot
Here is the call graph for this function:
Here is the caller graph for this function:

◆ findUser()

Server_AbstractUserInterface * Server::findUser ( const QString & userName) const
Here is the caller graph for this function:

◆ getClientIDRequiredEnabled()

virtual bool Server::getClientIDRequiredEnabled ( ) const
inlinevirtual

Reimplemented in Servatrice.

Here is the caller graph for this function:

◆ getClientKeepAlive()

virtual int Server::getClientKeepAlive ( ) const
inlinevirtual

Reimplemented in Servatrice.

◆ getCommandCountingInterval()

virtual int Server::getCommandCountingInterval ( ) const
inlinevirtual

Reimplemented in Servatrice.

◆ getDatabaseInterface()

Server_DatabaseInterface * Server::getDatabaseInterface ( ) const
Here is the caller graph for this function:

◆ getEnableLogQuery()

virtual bool Server::getEnableLogQuery ( ) const
inlinevirtual

Reimplemented in Servatrice.

◆ getExternalUsers()

const QMap< QString, Server_AbstractUserInterface * > & Server::getExternalUsers ( ) const
inline

◆ getGamesCount()

int Server::getGamesCount ( ) const
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getGameShouldPing()

virtual bool Server::getGameShouldPing ( ) const
inlinevirtual

Reimplemented in Servatrice.

◆ getIdleClientTimeout()

virtual int Server::getIdleClientTimeout ( ) const
inlinevirtual

Reimplemented in Servatrice.

◆ getLoginMessage()

virtual QString Server::getLoginMessage ( ) const
inlinevirtual

Reimplemented in Servatrice.

◆ getMaxCommandCountPerInterval()

virtual int Server::getMaxCommandCountPerInterval ( ) const
inlinevirtual

Reimplemented in Servatrice.

◆ getMaxGameInactivityTime()

virtual int Server::getMaxGameInactivityTime ( ) const
inlinevirtual

Reimplemented in Servatrice.

◆ getMaxGamesPerUser()

virtual int Server::getMaxGamesPerUser ( ) const
inlinevirtual

Reimplemented in Servatrice.

◆ getMaxMessageCountPerInterval()

virtual int Server::getMaxMessageCountPerInterval ( ) const
inlinevirtual

Reimplemented in Servatrice.

◆ getMaxMessageSizePerInterval()

virtual int Server::getMaxMessageSizePerInterval ( ) const
inlinevirtual

Reimplemented in Servatrice.

◆ getMaxPlayerInactivityTime()

virtual int Server::getMaxPlayerInactivityTime ( ) const
inlinevirtual

Reimplemented in Servatrice.

◆ getMaxUserLimitEnabled()

virtual bool Server::getMaxUserLimitEnabled ( ) const
inlinevirtual

Reimplemented in Servatrice.

◆ getMaxUserTotal()

virtual int Server::getMaxUserTotal ( ) const
inlinevirtual

Reimplemented in Servatrice.

◆ getMessageCountingInterval()

virtual int Server::getMessageCountingInterval ( ) const
inlinevirtual

Reimplemented in Servatrice.

◆ getNextLocalGameId()

int Server::getNextLocalGameId ( )
inline

◆ getOnlineModeratorList()

QList< QString > Server::getOnlineModeratorList ( ) const
Here is the caller graph for this function:

◆ getPersistentPlayerReferences()

QList< PlayerReference > Server::getPersistentPlayerReferences ( const QString & userName) const

◆ getRegOnlyServerEnabled()

virtual bool Server::getRegOnlyServerEnabled ( ) const
inlinevirtual

Reimplemented in Servatrice.

Here is the caller graph for this function:

◆ getRequiredFeatures()

virtual QString Server::getRequiredFeatures ( ) const
inlinevirtual

Reimplemented in Servatrice.

◆ getRooms()

const QMap< int, Server_Room * > & Server::getRooms ( )
inline

◆ getServerID()

virtual int Server::getServerID ( ) const
inlinevirtual

Reimplemented in Servatrice.

◆ getServerRequiredFeatureList()

virtual QMap< QString, bool > Server::getServerRequiredFeatureList ( ) const
inlinevirtual

Reimplemented in Servatrice.

◆ getStoreReplaysEnabled()

virtual bool Server::getStoreReplaysEnabled ( ) const
inlinevirtual

Reimplemented in Servatrice.

Here is the caller graph for this function:

◆ getTCPUserCount()

int Server::getTCPUserCount ( ) const
inline

◆ getUsers()

const QMap< QString, Server_ProtocolHandler * > & Server::getUsers ( ) const
inline

◆ getUsersBySessionId()

const QMap< qint64, Server_ProtocolHandler * > & Server::getUsersBySessionId ( ) const
inline

◆ getUsersCount()

int Server::getUsersCount ( ) const
Here is the caller graph for this function:

◆ getWebSocketUserCount()

int Server::getWebSocketUserCount ( ) const
inline

◆ loginUser()

AuthenticationResult Server::loginUser ( Server_ProtocolHandler * session,
QString & name,
const QString & password,
bool passwordNeedsHash,
QString & reason,
int & secondsLeft,
QString & clientid,
QString & clientVersion,
QString & connectionType )
Here is the call graph for this function:

◆ permitCreateGameAsJudge()

virtual bool Server::permitCreateGameAsJudge ( ) const
inlinevirtual

Reimplemented in Servatrice.

◆ permitUnregisteredUsers()

virtual bool Server::permitUnregisteredUsers ( ) const
inlinevirtual

Reimplemented in Servatrice.

◆ pingClockTimeout

void Server::pingClockTimeout ( )
signal
Here is the caller graph for this function:

◆ prepareDestroy()

void Server::prepareDestroy ( )
protected
Here is the caller graph for this function:

◆ removeClient()

void Server::removeClient ( Server_ProtocolHandler * player)
Here is the call graph for this function:

◆ removePersistentPlayer()

void Server::removePersistentPlayer ( const QString & userName,
int roomId,
int gameId,
int playerId )

◆ sendIsl_GameCommand()

void Server::sendIsl_GameCommand ( const CommandContainer & item,
int serverId,
qint64 sessionId,
int roomId,
int playerId )
Here is the call graph for this function:

◆ sendIsl_GameEventContainer()

void Server::sendIsl_GameEventContainer ( const GameEventContainer & item,
int serverId = -1,
qint64 sessionId = -1 )
Here is the call graph for this function:

◆ sendIsl_Response()

void Server::sendIsl_Response ( const Response & item,
int serverId = -1,
qint64 sessionId = -1 )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ sendIsl_RoomCommand()

void Server::sendIsl_RoomCommand ( const CommandContainer & item,
int serverId,
qint64 sessionId,
int roomId )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ sendIsl_RoomEvent()

void Server::sendIsl_RoomEvent ( const RoomEvent & item,
int serverId = -1,
qint64 sessionId = -1 )
Here is the call graph for this function:

◆ sendIsl_SessionEvent()

void Server::sendIsl_SessionEvent ( const SessionEvent & item,
int serverId = -1,
qint64 sessionId = -1 )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setDatabaseInterface()

void Server::setDatabaseInterface ( Server_DatabaseInterface * _databaseInterface)
protected
Here is the call graph for this function:
Here is the caller graph for this function:

◆ sigSendIslMessage

void Server::sigSendIslMessage ( const IslMessage & message,
int serverId )
signal
Here is the caller graph for this function:

Member Data Documentation

◆ clients

QList<Server_ProtocolHandler *> Server::clients
protected

◆ clientsLock

QReadWriteLock Server::clientsLock
mutable

◆ databaseInterfaces

QMap<QThread *, Server_DatabaseInterface *> Server::databaseInterfaces
protected

◆ externalUsers

QMap<QString, Server_AbstractUserInterface *> Server::externalUsers
protected

◆ externalUsersBySessionId

QMap<qint64, Server_AbstractUserInterface *> Server::externalUsersBySessionId
protected

◆ nextLocalGameId

int Server::nextLocalGameId
private

◆ nextLocalGameIdMutex

QMutex Server::nextLocalGameIdMutex
private

◆ persistentPlayers

QMultiMap<QString, PlayerReference> Server::persistentPlayers
private

◆ persistentPlayersLock

QReadWriteLock Server::persistentPlayersLock
mutableprivate

◆ rooms

QMap<int, Server_Room *> Server::rooms
protected

◆ roomsLock

QReadWriteLock Server::roomsLock

◆ tcpUserCount

int Server::tcpUserCount
private

◆ users

QMap<QString, Server_ProtocolHandler *> Server::users
protected

◆ usersBySessionId

QMap<qint64, Server_ProtocolHandler *> Server::usersBySessionId
protected

◆ webSocketUserCount

int Server::webSocketUserCount
private

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