mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-04-27 07:48:01 -07:00
* move common server files * update includes with move * create participant, move code * fix linker errors * fix regressions * mark function as override to make clang happy * split out spectator to new file * forgot to add to cmakelists * autocompleter picking wrong casing for var name * clean up forwards declarations in player * fix includes in game
This commit is contained in:
parent
17dcaf9afa
commit
f0c3860032
45 changed files with 1283 additions and 866 deletions
63
common/server/server_abstractuserinterface.h
Normal file
63
common/server/server_abstractuserinterface.h
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
#ifndef SERVER_ABSTRACTUSERINTERFACE
|
||||
#define SERVER_ABSTRACTUSERINTERFACE
|
||||
|
||||
#include "../serverinfo_user_container.h"
|
||||
#include "pb/response.pb.h"
|
||||
#include "pb/server_message.pb.h"
|
||||
|
||||
#include <QMap>
|
||||
#include <QMutex>
|
||||
#include <QPair>
|
||||
|
||||
class SessionEvent;
|
||||
class GameEventContainer;
|
||||
class RoomEvent;
|
||||
class ResponseContainer;
|
||||
|
||||
class Server;
|
||||
class Server_Game;
|
||||
|
||||
class Server_AbstractUserInterface : public ServerInfo_User_Container
|
||||
{
|
||||
private:
|
||||
mutable QMutex gameListMutex;
|
||||
QMap<int, QPair<int, int>> games; // gameId -> (roomId, playerId)
|
||||
protected:
|
||||
Server *server;
|
||||
|
||||
public:
|
||||
explicit Server_AbstractUserInterface(Server *_server) : server(_server)
|
||||
{
|
||||
}
|
||||
Server_AbstractUserInterface(Server *_server, const ServerInfo_User_Container &other)
|
||||
: ServerInfo_User_Container(other), server(_server)
|
||||
{
|
||||
}
|
||||
~Server_AbstractUserInterface() override
|
||||
{
|
||||
}
|
||||
|
||||
virtual int getLastCommandTime() const = 0;
|
||||
virtual bool addSaidMessageSize(int size) = 0;
|
||||
|
||||
void playerRemovedFromGame(Server_Game *game);
|
||||
void playerAddedToGame(int gameId, int roomId, int playerId);
|
||||
void joinPersistentGames(ResponseContainer &rc);
|
||||
|
||||
QMap<int, QPair<int, int>> getGames() const
|
||||
{
|
||||
QMutexLocker locker(&gameListMutex);
|
||||
return games;
|
||||
}
|
||||
|
||||
virtual void sendProtocolItem(const Response &item) = 0;
|
||||
virtual void sendProtocolItem(const SessionEvent &item) = 0;
|
||||
virtual void sendProtocolItem(const GameEventContainer &item) = 0;
|
||||
virtual void sendProtocolItem(const RoomEvent &item) = 0;
|
||||
void sendProtocolItemByType(ServerMessage::MessageType type, const ::google::protobuf::Message &item);
|
||||
|
||||
static SessionEvent *prepareSessionEvent(const ::google::protobuf::Message &sessionEvent);
|
||||
void sendResponseContainer(const ResponseContainer &responseContainer, Response::ResponseCode responseCode);
|
||||
};
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue