Cockatrice 2025-11-30-Development-2.11.0-beta.38
A cross-platform virtual tabletop for multiplayer card games
Loading...
Searching...
No Matches
server_abstractuserinterface.h
Go to the documentation of this file.
1#ifndef SERVER_ABSTRACTUSERINTERFACE
2#define SERVER_ABSTRACTUSERINTERFACE
3
5
6#include <QMap>
7#include <QMutex>
8#include <libcockatrice/protocol/pb/response.pb.h>
9#include <libcockatrice/protocol/pb/server_message.pb.h>
10
11class SessionEvent;
12class GameEventContainer;
13class RoomEvent;
15
16class Server;
17class Server_Game;
18
20{
21private:
22 mutable QMutex gameListMutex;
23 QMap<int, QPair<int, int>> games; // gameId -> (roomId, playerId)
24protected:
26
27public:
28 explicit Server_AbstractUserInterface(Server *_server) : server(_server)
29 {
30 }
32 : ServerInfo_User_Container(other), server(_server)
33 {
34 }
36 {
37 }
38
39 virtual int getLastCommandTime() const = 0;
40 virtual bool addSaidMessageSize(int size) = 0;
41
43 void playerAddedToGame(int gameId, int roomId, int playerId);
45
46 QMap<int, QPair<int, int>> getGames() const
47 {
48 QMutexLocker locker(&gameListMutex);
49 return games;
50 }
51
52 virtual void sendProtocolItem(const Response &item) = 0;
53 virtual void sendProtocolItem(const SessionEvent &item) = 0;
54 virtual void sendProtocolItem(const GameEventContainer &item) = 0;
55 virtual void sendProtocolItem(const RoomEvent &item) = 0;
56 void sendProtocolItemByType(ServerMessage::MessageType type, const ::google::protobuf::Message &item);
57
58 static SessionEvent *prepareSessionEvent(const ::google::protobuf::Message &sessionEvent);
59 void sendResponseContainer(const ResponseContainer &responseContainer, Response::ResponseCode responseCode);
60};
61
62#endif
Definition server_response_containers.h:89
ServerInfo_User_Container(ServerInfo_User *_userInfo=nullptr)
Definition serverinfo_user_container.cpp:5
QMap< int, QPair< int, int > > getGames() const
Definition server_abstractuserinterface.h:46
QMap< int, QPair< int, int > > games
Definition server_abstractuserinterface.h:23
virtual void sendProtocolItem(const SessionEvent &item)=0
~Server_AbstractUserInterface() override
Definition server_abstractuserinterface.h:35
virtual bool addSaidMessageSize(int size)=0
void joinPersistentGames(ResponseContainer &rc)
Definition server_abstractuserinterface.cpp:85
static SessionEvent * prepareSessionEvent(const ::google::protobuf::Message &sessionEvent)
Definition server_abstractuserinterface.cpp:34
virtual int getLastCommandTime() const =0
virtual void sendProtocolItem(const RoomEvent &item)=0
virtual void sendProtocolItem(const GameEventContainer &item)=0
Server_AbstractUserInterface(Server *_server)
Definition server_abstractuserinterface.h:28
void sendProtocolItemByType(ServerMessage::MessageType type, const ::google::protobuf::Message &item)
Definition server_abstractuserinterface.cpp:15
void playerRemovedFromGame(Server_Game *game)
Definition server_abstractuserinterface.cpp:69
void playerAddedToGame(int gameId, int roomId, int playerId)
Definition server_abstractuserinterface.cpp:77
QMutex gameListMutex
Definition server_abstractuserinterface.h:22
Server * server
Definition server_abstractuserinterface.h:25
virtual void sendProtocolItem(const Response &item)=0
Server_AbstractUserInterface(Server *_server, const ServerInfo_User_Container &other)
Definition server_abstractuserinterface.h:31
void sendResponseContainer(const ResponseContainer &responseContainer, Response::ResponseCode responseCode)
Definition server_abstractuserinterface.cpp:43
Definition server_game.h:47
Definition server.h:45