mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-12 09:04:53 -07:00
renamed servernetwork to ISL (inter-server link), join/leave is working
This commit is contained in:
parent
dda78661ea
commit
5963c2239c
9 changed files with 155 additions and 78 deletions
|
|
@ -102,6 +102,7 @@ SET(PROTO_FILES
|
|||
game_event_context.proto
|
||||
game_event.proto
|
||||
game_replay.proto
|
||||
isl_message.proto
|
||||
moderator_commands.proto
|
||||
move_card_to_zone.proto
|
||||
response_deck_download.proto
|
||||
|
|
@ -133,7 +134,6 @@ SET(PROTO_FILES
|
|||
serverinfo_room.proto
|
||||
serverinfo_user.proto
|
||||
serverinfo_zone.proto
|
||||
servernetwork_message.proto
|
||||
server_message.proto
|
||||
session_commands.proto
|
||||
session_event.proto
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import "commands.proto";
|
|||
import "game_event_container.proto";
|
||||
import "room_event.proto";
|
||||
|
||||
message ServerNetworkMessage {
|
||||
message IslMessage {
|
||||
enum MessageType {
|
||||
RESPONSE = 0;
|
||||
SESSION_EVENT = 1;
|
||||
|
|
@ -25,6 +25,8 @@
|
|||
#include "pb/event_user_joined.pb.h"
|
||||
#include "pb/event_user_left.pb.h"
|
||||
#include "pb/event_list_rooms.pb.h"
|
||||
#include "pb/session_event.pb.h"
|
||||
#include "pb/isl_message.pb.h"
|
||||
#include <QCoreApplication>
|
||||
#include <QDebug>
|
||||
|
||||
|
|
@ -98,6 +100,9 @@ AuthenticationResult Server::loginUser(Server_ProtocolHandler *session, QString
|
|||
for (int i = 0; i < clients.size(); ++i)
|
||||
if (clients[i]->getAcceptsUserListChanges())
|
||||
clients[i]->sendProtocolItem(*se);
|
||||
serverMutex.unlock();
|
||||
|
||||
sendIslMessage(*se);
|
||||
delete se;
|
||||
|
||||
return authState;
|
||||
|
|
@ -121,6 +126,7 @@ void Server::removeClient(Server_ProtocolHandler *client)
|
|||
for (int i = 0; i < clients.size(); ++i)
|
||||
if (clients[i]->getAcceptsUserListChanges())
|
||||
clients[i]->sendProtocolItem(*se);
|
||||
sendIslMessage(*se);
|
||||
delete se;
|
||||
|
||||
users.remove(QString::fromStdString(data->name()));
|
||||
|
|
@ -177,3 +183,12 @@ int Server::getGamesCount() const
|
|||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void Server::sendIslMessage(const SessionEvent &item, int serverId)
|
||||
{
|
||||
IslMessage msg;
|
||||
msg.set_message_type(IslMessage::SESSION_EVENT);
|
||||
msg.mutable_session_event()->CopyFrom(item);
|
||||
|
||||
doSendIslMessage(msg, serverId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,8 @@ class Server_Game;
|
|||
class Server_Room;
|
||||
class Server_ProtocolHandler;
|
||||
class GameReplay;
|
||||
class IslMessage;
|
||||
class SessionEvent;
|
||||
|
||||
enum AuthenticationResult { NotLoggedIn = 0, PasswordRight = 1, UnknownUser = 2, WouldOverwriteOldSession = 3, UserIsBanned = 4 };
|
||||
|
||||
|
|
@ -50,6 +52,8 @@ public:
|
|||
virtual bool isInIgnoreList(const QString &whoseList, const QString &who) { return false; }
|
||||
|
||||
virtual void storeGameInformation(int secondsElapsed, const QSet<QString> &allPlayersEver, const QSet<QString> &allSpectatorsEver, const QList<GameReplay *> &replays) { }
|
||||
|
||||
void sendIslMessage(const SessionEvent &item, int serverId = -1);
|
||||
protected:
|
||||
void prepareDestroy();
|
||||
QList<Server_ProtocolHandler *> clients;
|
||||
|
|
@ -70,6 +74,8 @@ protected:
|
|||
virtual void lockSessionTables() { }
|
||||
virtual void unlockSessionTables() { }
|
||||
virtual bool userSessionExists(const QString &userName) { return false; }
|
||||
|
||||
virtual void doSendIslMessage(const IslMessage &msg, int serverId) { }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue