#ifndef SERVER_H #define SERVER_H #include #include #include class Server_Game; class Server_Room; class Server_ProtocolHandler; class ServerInfo_User; enum AuthenticationResult { PasswordWrong = 0, PasswordRight = 1, UnknownUser = 2 }; class Server : public QObject { Q_OBJECT signals: void pingClockTimeout(); private slots: void gameClosing(int gameId); void broadcastRoomUpdate(); public: Server(QObject *parent = 0); ~Server(); AuthenticationResult loginUser(Server_ProtocolHandler *session, QString &name, const QString &password); QList getGames() const { return games.values(); } Server_Game *getGame(int gameId) const; const QMap &getRooms() { return rooms; } int getNextGameId() { return nextGameId++; } const QMap &getUsers() const { return users; } void addClient(Server_ProtocolHandler *player); void removeClient(Server_ProtocolHandler *player); virtual QString getLoginMessage() const = 0; virtual bool getGameShouldPing() const = 0; virtual int getMaxGameInactivityTime() const = 0; virtual int getMaxPlayerInactivityTime() const = 0; protected: QMap games; QList clients; QMap users; QMap rooms; virtual AuthenticationResult checkUserPassword(const QString &user, const QString &password) = 0; virtual ServerInfo_User *getUserData(const QString &name) = 0; int nextGameId; void addRoom(Server_Room *newRoom); }; #endif