server code cleanup, changed in-game ping event to not use any bandwidth as long as nothing changes
This commit is contained in:
parent
a64df4a0f5
commit
4895f2b4fd
27 changed files with 232 additions and 268 deletions
|
@ -762,7 +762,6 @@ void MessageLogWidget::containerProcessingDone()
|
||||||
|
|
||||||
void MessageLogWidget::connectToPlayer(Player *player)
|
void MessageLogWidget::connectToPlayer(Player *player)
|
||||||
{
|
{
|
||||||
connect(player, SIGNAL(logConnectionStateChanged(Player *, bool)), this, SLOT(logConnectionStateChanged(Player *, bool)));
|
|
||||||
connect(player, SIGNAL(logSay(Player *, QString)), this, SLOT(logSay(Player *, QString)));
|
connect(player, SIGNAL(logSay(Player *, QString)), this, SLOT(logSay(Player *, QString)));
|
||||||
connect(player, SIGNAL(logShuffle(Player *, CardZone *)), this, SLOT(logShuffle(Player *, CardZone *)));
|
connect(player, SIGNAL(logShuffle(Player *, CardZone *)), this, SLOT(logShuffle(Player *, CardZone *)));
|
||||||
connect(player, SIGNAL(logRollDie(Player *, int, int)), this, SLOT(logRollDie(Player *, int, int)));
|
connect(player, SIGNAL(logRollDie(Player *, int, int)), this, SLOT(logRollDie(Player *, int, int)));
|
||||||
|
|
|
@ -41,7 +41,6 @@
|
||||||
#include "pb/serverinfo_zone.pb.h"
|
#include "pb/serverinfo_zone.pb.h"
|
||||||
#include "pb/context_move_card.pb.h"
|
#include "pb/context_move_card.pb.h"
|
||||||
#include "pb/context_undo_draw.pb.h"
|
#include "pb/context_undo_draw.pb.h"
|
||||||
#include "pb/event_connection_state_changed.pb.h"
|
|
||||||
#include "pb/event_game_say.pb.h"
|
#include "pb/event_game_say.pb.h"
|
||||||
#include "pb/event_shuffle.pb.h"
|
#include "pb/event_shuffle.pb.h"
|
||||||
#include "pb/event_roll_die.pb.h"
|
#include "pb/event_roll_die.pb.h"
|
||||||
|
@ -814,11 +813,6 @@ void Player::setCardAttrHelper(const GameEventContext &context, CardItem *card,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::eventConnectionStateChanged(const Event_ConnectionStateChanged &event)
|
|
||||||
{
|
|
||||||
emit logConnectionStateChanged(this, event.connected());
|
|
||||||
}
|
|
||||||
|
|
||||||
void Player::eventGameSay(const Event_GameSay &event)
|
void Player::eventGameSay(const Event_GameSay &event)
|
||||||
{
|
{
|
||||||
emit logSay(this, QString::fromStdString(event.message()));
|
emit logSay(this, QString::fromStdString(event.message()));
|
||||||
|
@ -1159,7 +1153,6 @@ void Player::eventRevealCards(const Event_RevealCards &event)
|
||||||
void Player::processGameEvent(GameEvent::GameEventType type, const GameEvent &event, const GameEventContext &context)
|
void Player::processGameEvent(GameEvent::GameEventType type, const GameEvent &event, const GameEventContext &context)
|
||||||
{
|
{
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case GameEvent::CONNECTION_STATE_CHANGED: eventConnectionStateChanged(event.GetExtension(Event_ConnectionStateChanged::ext)); break;
|
|
||||||
case GameEvent::GAME_SAY: eventGameSay(event.GetExtension(Event_GameSay::ext)); break;
|
case GameEvent::GAME_SAY: eventGameSay(event.GetExtension(Event_GameSay::ext)); break;
|
||||||
case GameEvent::SHUFFLE: eventShuffle(event.GetExtension(Event_Shuffle::ext)); break;
|
case GameEvent::SHUFFLE: eventShuffle(event.GetExtension(Event_Shuffle::ext)); break;
|
||||||
case GameEvent::ROLL_DIE: eventRollDie(event.GetExtension(Event_RollDie::ext)); break;
|
case GameEvent::ROLL_DIE: eventRollDie(event.GetExtension(Event_RollDie::ext)); break;
|
||||||
|
|
|
@ -77,7 +77,6 @@ class Player : public QObject, public QGraphicsItem {
|
||||||
signals:
|
signals:
|
||||||
void newCardAdded(AbstractCardItem *card);
|
void newCardAdded(AbstractCardItem *card);
|
||||||
// Log events
|
// Log events
|
||||||
void logConnectionStateChanged(Player *player, bool connectionState);
|
|
||||||
void logSay(Player *player, QString message);
|
void logSay(Player *player, QString message);
|
||||||
void logShuffle(Player *player, CardZone *zone);
|
void logShuffle(Player *player, CardZone *zone);
|
||||||
void logRollDie(Player *player, int sides, int roll);
|
void logRollDie(Player *player, int sides, int roll);
|
||||||
|
|
|
@ -81,26 +81,40 @@ void PlayerListWidget::addPlayer(const ServerInfo_PlayerProperties &player)
|
||||||
sortItems(1, Qt::AscendingOrder);
|
sortItems(1, Qt::AscendingOrder);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerListWidget::updatePlayerProperties(const ServerInfo_PlayerProperties &prop)
|
void PlayerListWidget::updatePlayerProperties(const ServerInfo_PlayerProperties &prop, int playerId)
|
||||||
{
|
{
|
||||||
QTreeWidgetItem *player = players.value(prop.player_id(), 0);
|
if (playerId == -1)
|
||||||
|
playerId = prop.player_id();
|
||||||
|
|
||||||
|
QTreeWidgetItem *player = players.value(playerId, 0);
|
||||||
if (!player)
|
if (!player)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
player->setIcon(1, prop.spectator() ? spectatorIcon : playerIcon);
|
if (prop.has_spectator()) {
|
||||||
player->setData(1, Qt::UserRole, !prop.spectator());
|
player->setIcon(1, prop.spectator() ? spectatorIcon : playerIcon);
|
||||||
player->setData(2, Qt::UserRole, prop.conceded());
|
player->setData(1, Qt::UserRole, !prop.spectator());
|
||||||
player->setData(2, Qt::UserRole + 1, prop.ready_start());
|
}
|
||||||
player->setIcon(2, gameStarted ? (prop.conceded() ? concededIcon : QIcon()) : (prop.ready_start() ? readyIcon : notReadyIcon));
|
if (prop.has_conceded())
|
||||||
player->setData(3, Qt::UserRole, prop.user_info().user_level());
|
player->setData(2, Qt::UserRole, prop.conceded());
|
||||||
player->setIcon(3, QIcon(UserLevelPixmapGenerator::generatePixmap(12, prop.user_info().user_level())));
|
if (prop.has_ready_start())
|
||||||
player->setText(4, QString::fromStdString(prop.user_info().name()));
|
player->setData(2, Qt::UserRole + 1, prop.ready_start());
|
||||||
const QString country = QString::fromStdString(prop.user_info().country());
|
if (prop.has_conceded() && prop.has_ready_start())
|
||||||
if (!country.isEmpty())
|
player->setIcon(2, gameStarted ? (prop.conceded() ? concededIcon : QIcon()) : (prop.ready_start() ? readyIcon : notReadyIcon));
|
||||||
player->setIcon(4, QIcon(CountryPixmapGenerator::generatePixmap(12, country)));
|
if (prop.has_user_info()) {
|
||||||
player->setData(4, Qt::UserRole, QString::fromStdString(prop.user_info().name()));
|
player->setData(3, Qt::UserRole, prop.user_info().user_level());
|
||||||
player->setData(4, Qt::UserRole + 1, prop.player_id());
|
player->setIcon(3, QIcon(UserLevelPixmapGenerator::generatePixmap(12, prop.user_info().user_level())));
|
||||||
player->setText(5, QString::fromStdString(prop.deck_hash()));
|
player->setText(4, QString::fromStdString(prop.user_info().name()));
|
||||||
|
const QString country = QString::fromStdString(prop.user_info().country());
|
||||||
|
if (!country.isEmpty())
|
||||||
|
player->setIcon(4, QIcon(CountryPixmapGenerator::generatePixmap(12, country)));
|
||||||
|
player->setData(4, Qt::UserRole, QString::fromStdString(prop.user_info().name()));
|
||||||
|
}
|
||||||
|
if (prop.has_player_id())
|
||||||
|
player->setData(4, Qt::UserRole + 1, prop.player_id());
|
||||||
|
if (prop.has_deck_hash())
|
||||||
|
player->setText(5, QString::fromStdString(prop.deck_hash()));
|
||||||
|
if (prop.has_ping_seconds())
|
||||||
|
player->setIcon(0, QIcon(PingPixmapGenerator::generatePixmap(12, prop.ping_seconds(), 10)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerListWidget::removePlayer(int playerId)
|
void PlayerListWidget::removePlayer(int playerId)
|
||||||
|
@ -123,14 +137,6 @@ void PlayerListWidget::setActivePlayer(int playerId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerListWidget::updatePing(int playerId, int pingTime)
|
|
||||||
{
|
|
||||||
QTreeWidgetItem *twi = players.value(playerId, 0);
|
|
||||||
if (!twi)
|
|
||||||
return;
|
|
||||||
twi->setIcon(0, QIcon(PingPixmapGenerator::generatePixmap(12, pingTime, 10)));
|
|
||||||
}
|
|
||||||
|
|
||||||
void PlayerListWidget::setGameStarted(bool _gameStarted, bool resuming)
|
void PlayerListWidget::setGameStarted(bool _gameStarted, bool resuming)
|
||||||
{
|
{
|
||||||
gameStarted = _gameStarted;
|
gameStarted = _gameStarted;
|
||||||
|
|
|
@ -41,8 +41,7 @@ public:
|
||||||
void addPlayer(const ServerInfo_PlayerProperties &player);
|
void addPlayer(const ServerInfo_PlayerProperties &player);
|
||||||
void removePlayer(int playerId);
|
void removePlayer(int playerId);
|
||||||
void setActivePlayer(int playerId);
|
void setActivePlayer(int playerId);
|
||||||
void updatePing(int playerId, int pingTime);
|
void updatePlayerProperties(const ServerInfo_PlayerProperties &prop, int playerId = -1);
|
||||||
void updatePlayerProperties(const ServerInfo_PlayerProperties &prop);
|
|
||||||
void setGameStarted(bool _gameStarted, bool resuming);
|
void setGameStarted(bool _gameStarted, bool resuming);
|
||||||
void showContextMenu(const QPoint &pos, const QModelIndex &index);
|
void showContextMenu(const QPoint &pos, const QModelIndex &index);
|
||||||
};
|
};
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
|
#include <QTimer>
|
||||||
#include "tab_game.h"
|
#include "tab_game.h"
|
||||||
#include "tab_supervisor.h"
|
#include "tab_supervisor.h"
|
||||||
#include "cardinfowidget.h"
|
#include "cardinfowidget.h"
|
||||||
|
@ -50,8 +51,9 @@
|
||||||
#include "pb/event_game_closed.pb.h"
|
#include "pb/event_game_closed.pb.h"
|
||||||
#include "pb/event_set_active_player.pb.h"
|
#include "pb/event_set_active_player.pb.h"
|
||||||
#include "pb/event_set_active_phase.pb.h"
|
#include "pb/event_set_active_phase.pb.h"
|
||||||
#include "pb/event_ping.pb.h"
|
|
||||||
#include "pb/context_deck_select.pb.h"
|
#include "pb/context_deck_select.pb.h"
|
||||||
|
#include "pb/context_connection_state_changed.pb.h"
|
||||||
|
#include "pb/context_ping_changed.pb.h"
|
||||||
#include "get_pb_extension.h"
|
#include "get_pb_extension.h"
|
||||||
|
|
||||||
ReadyStartButton::ReadyStartButton(QWidget *parent)
|
ReadyStartButton::ReadyStartButton(QWidget *parent)
|
||||||
|
@ -208,6 +210,11 @@ TabGame::TabGame(TabSupervisor *_tabSupervisor, QList<AbstractClient *> &_client
|
||||||
resuming(event.resuming()),
|
resuming(event.resuming()),
|
||||||
currentPhase(-1)
|
currentPhase(-1)
|
||||||
{
|
{
|
||||||
|
gameTimer = new QTimer(this);
|
||||||
|
gameTimer->setInterval(1000);
|
||||||
|
connect(gameTimer, SIGNAL(timeout()), this, SLOT(incrementGameTime()));
|
||||||
|
gameTimer->start();
|
||||||
|
|
||||||
phasesToolbar = new PhasesToolbar;
|
phasesToolbar = new PhasesToolbar;
|
||||||
phasesToolbar->hide();
|
phasesToolbar->hide();
|
||||||
connect(phasesToolbar, SIGNAL(sendGameCommand(const ::google::protobuf::Message &, int)), this, SLOT(sendGameCommand(const ::google::protobuf::Message &, int)));
|
connect(phasesToolbar, SIGNAL(sendGameCommand(const ::google::protobuf::Message &, int)), this, SLOT(sendGameCommand(const ::google::protobuf::Message &, int)));
|
||||||
|
@ -361,6 +368,17 @@ void TabGame::closeRequest()
|
||||||
actLeaveGame();
|
actLeaveGame();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TabGame::incrementGameTime()
|
||||||
|
{
|
||||||
|
int seconds = ++secondsElapsed;
|
||||||
|
int minutes = seconds / 60;
|
||||||
|
seconds -= minutes * 60;
|
||||||
|
int hours = minutes / 60;
|
||||||
|
minutes -= hours * 60;
|
||||||
|
|
||||||
|
timeElapsedLabel->setText(QString::number(hours).rightJustified(2, '0') + ":" + QString::number(minutes).rightJustified(2, '0') + ":" + QString::number(seconds).rightJustified(2, '0'));
|
||||||
|
}
|
||||||
|
|
||||||
void TabGame::adminLockChanged(bool lock)
|
void TabGame::adminLockChanged(bool lock)
|
||||||
{
|
{
|
||||||
bool v = !(spectator && !spectatorsCanTalk && lock);
|
bool v = !(spectator && !spectatorsCanTalk && lock);
|
||||||
|
@ -496,7 +514,6 @@ void TabGame::processGameEventContainer(const GameEventContainer &cont, Abstract
|
||||||
case GameEvent::GAME_CLOSED: eventGameClosed(event.GetExtension(Event_GameClosed::ext), playerId, context); break;
|
case GameEvent::GAME_CLOSED: eventGameClosed(event.GetExtension(Event_GameClosed::ext), playerId, context); break;
|
||||||
case GameEvent::SET_ACTIVE_PLAYER: eventSetActivePlayer(event.GetExtension(Event_SetActivePlayer::ext), playerId, context); break;
|
case GameEvent::SET_ACTIVE_PLAYER: eventSetActivePlayer(event.GetExtension(Event_SetActivePlayer::ext), playerId, context); break;
|
||||||
case GameEvent::SET_ACTIVE_PHASE: eventSetActivePhase(event.GetExtension(Event_SetActivePhase::ext), playerId, context); break;
|
case GameEvent::SET_ACTIVE_PHASE: eventSetActivePhase(event.GetExtension(Event_SetActivePhase::ext), playerId, context); break;
|
||||||
case GameEvent::PING: eventPing(event.GetExtension(Event_Ping::ext), playerId, context); break;
|
|
||||||
|
|
||||||
default: {
|
default: {
|
||||||
Player *player = players.value(playerId, 0);
|
Player *player = players.value(playerId, 0);
|
||||||
|
@ -650,6 +667,9 @@ void TabGame::eventGameStateChanged(const Event_GameStateChanged &event, int /*e
|
||||||
player->processCardAttachment(playerInfo);
|
player->processCardAttachment(playerInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
secondsElapsed = event.seconds_elapsed();
|
||||||
|
|
||||||
if (event.game_started() && !started) {
|
if (event.game_started() && !started) {
|
||||||
startGame(!gameStateKnown);
|
startGame(!gameStateKnown);
|
||||||
if (gameStateKnown)
|
if (gameStateKnown)
|
||||||
|
@ -669,7 +689,7 @@ void TabGame::eventPlayerPropertiesChanged(const Event_PlayerPropertiesChanged &
|
||||||
Player *player = players.value(eventPlayerId, 0);
|
Player *player = players.value(eventPlayerId, 0);
|
||||||
if (!player)
|
if (!player)
|
||||||
return;
|
return;
|
||||||
playerListWidget->updatePlayerProperties(event.player_properties());
|
playerListWidget->updatePlayerProperties(event.player_properties(), eventPlayerId);
|
||||||
|
|
||||||
const GameEventContext::ContextType contextType = static_cast<const GameEventContext::ContextType>(getPbExtension(context));
|
const GameEventContext::ContextType contextType = static_cast<const GameEventContext::ContextType>(getPbExtension(context));
|
||||||
switch (contextType) {
|
switch (contextType) {
|
||||||
|
@ -697,6 +717,10 @@ void TabGame::eventPlayerPropertiesChanged(const Event_PlayerPropertiesChanged &
|
||||||
messageLog->logDeckSelect(player, QString::fromStdString(context.GetExtension(Context_DeckSelect::ext).deck_hash()));
|
messageLog->logDeckSelect(player, QString::fromStdString(context.GetExtension(Context_DeckSelect::ext).deck_hash()));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case GameEventContext::CONNECTION_STATE_CHANGED: {
|
||||||
|
messageLog->logConnectionStateChanged(player, event.player_properties().ping_seconds() != -1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
default: ;
|
default: ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -809,20 +833,6 @@ void TabGame::eventSetActivePhase(const Event_SetActivePhase &event, int /*event
|
||||||
emit userEvent();
|
emit userEvent();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TabGame::eventPing(const Event_Ping &event, int /*eventPlayerId*/, const GameEventContext & /*context*/)
|
|
||||||
{
|
|
||||||
const int pingListSize = event.ping_list_size();
|
|
||||||
for (int i = 0; i < pingListSize; ++i)
|
|
||||||
playerListWidget->updatePing(event.ping_list(i).player_id(), event.ping_list(i).ping_time());
|
|
||||||
|
|
||||||
int seconds = event.seconds_elapsed();
|
|
||||||
int minutes = seconds / 60;
|
|
||||||
seconds -= minutes * 60;
|
|
||||||
int hours = minutes / 60;
|
|
||||||
minutes -= hours * 60;
|
|
||||||
timeElapsedLabel->setText(QString::number(hours).rightJustified(2, '0') + ":" + QString::number(minutes).rightJustified(2, '0') + ":" + QString::number(seconds).rightJustified(2, '0'));
|
|
||||||
}
|
|
||||||
|
|
||||||
void TabGame::newCardAdded(AbstractCardItem *card)
|
void TabGame::newCardAdded(AbstractCardItem *card)
|
||||||
{
|
{
|
||||||
connect(card, SIGNAL(hovered(AbstractCardItem *)), cardInfo, SLOT(setCard(AbstractCardItem *)));
|
connect(card, SIGNAL(hovered(AbstractCardItem *)), cardInfo, SLOT(setCard(AbstractCardItem *)));
|
||||||
|
|
|
@ -13,6 +13,7 @@ class DeckView;
|
||||||
class GameScene;
|
class GameScene;
|
||||||
class CardInfoWidget;
|
class CardInfoWidget;
|
||||||
class MessageLogWidget;
|
class MessageLogWidget;
|
||||||
|
class QTimer;
|
||||||
class QSplitter;
|
class QSplitter;
|
||||||
class QLabel;
|
class QLabel;
|
||||||
class QLineEdit;
|
class QLineEdit;
|
||||||
|
@ -89,6 +90,8 @@ public:
|
||||||
class TabGame : public Tab {
|
class TabGame : public Tab {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
private:
|
private:
|
||||||
|
QTimer *gameTimer;
|
||||||
|
int secondsElapsed;
|
||||||
QList<AbstractClient *> clients;
|
QList<AbstractClient *> clients;
|
||||||
int gameId;
|
int gameId;
|
||||||
QString gameDescription;
|
QString gameDescription;
|
||||||
|
@ -152,6 +155,7 @@ signals:
|
||||||
void containerProcessingDone();
|
void containerProcessingDone();
|
||||||
void openMessageDialog(const QString &userName, bool focus);
|
void openMessageDialog(const QString &userName, bool focus);
|
||||||
private slots:
|
private slots:
|
||||||
|
void incrementGameTime();
|
||||||
void adminLockChanged(bool lock);
|
void adminLockChanged(bool lock);
|
||||||
void newCardAdded(AbstractCardItem *card);
|
void newCardAdded(AbstractCardItem *card);
|
||||||
|
|
||||||
|
|
|
@ -41,15 +41,16 @@ SET(PROTO_FILES
|
||||||
command_stop_dump_zone.proto
|
command_stop_dump_zone.proto
|
||||||
command_undo_draw.proto
|
command_undo_draw.proto
|
||||||
context_concede.proto
|
context_concede.proto
|
||||||
|
context_connection_state_changed.proto
|
||||||
context_deck_select.proto
|
context_deck_select.proto
|
||||||
context_move_card.proto
|
context_move_card.proto
|
||||||
context_mulligan.proto
|
context_mulligan.proto
|
||||||
|
context_ping_changed.proto
|
||||||
context_ready_start.proto
|
context_ready_start.proto
|
||||||
context_undo_draw.proto
|
context_undo_draw.proto
|
||||||
event_add_to_list.proto
|
event_add_to_list.proto
|
||||||
event_attach_card.proto
|
event_attach_card.proto
|
||||||
event_connection_closed.proto
|
event_connection_closed.proto
|
||||||
event_connection_state_changed.proto
|
|
||||||
event_create_arrow.proto
|
event_create_arrow.proto
|
||||||
event_create_counter.proto
|
event_create_counter.proto
|
||||||
event_create_token.proto
|
event_create_token.proto
|
||||||
|
@ -72,7 +73,6 @@ SET(PROTO_FILES
|
||||||
event_list_games.proto
|
event_list_games.proto
|
||||||
event_list_rooms.proto
|
event_list_rooms.proto
|
||||||
event_move_card.proto
|
event_move_card.proto
|
||||||
event_ping.proto
|
|
||||||
event_player_properties_changed.proto
|
event_player_properties_changed.proto
|
||||||
event_remove_from_list.proto
|
event_remove_from_list.proto
|
||||||
event_reveal_cards.proto
|
event_reveal_cards.proto
|
||||||
|
|
7
common/pb/context_connection_state_changed.proto
Normal file
7
common/pb/context_connection_state_changed.proto
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
import "game_event_context.proto";
|
||||||
|
|
||||||
|
message Context_ConnectionStateChanged {
|
||||||
|
extend GameEventContext {
|
||||||
|
optional Context_ConnectionStateChanged ext = 1007;
|
||||||
|
}
|
||||||
|
}
|
7
common/pb/context_ping_changed.proto
Normal file
7
common/pb/context_ping_changed.proto
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
import "game_event_context.proto";
|
||||||
|
|
||||||
|
message Context_PingChanged {
|
||||||
|
extend GameEventContext {
|
||||||
|
optional Context_PingChanged ext = 1006;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,8 +0,0 @@
|
||||||
import "game_event.proto";
|
|
||||||
|
|
||||||
message Event_ConnectionStateChanged {
|
|
||||||
extend GameEvent {
|
|
||||||
optional Event_ConnectionStateChanged ext = 1006;
|
|
||||||
}
|
|
||||||
optional bool connected = 1;
|
|
||||||
}
|
|
|
@ -9,4 +9,5 @@ message Event_GameStateChanged {
|
||||||
optional bool game_started = 2;
|
optional bool game_started = 2;
|
||||||
optional sint32 active_player_id = 3;
|
optional sint32 active_player_id = 3;
|
||||||
optional sint32 active_phase = 4;
|
optional sint32 active_phase = 4;
|
||||||
|
optional uint32 seconds_elapsed = 5;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +0,0 @@
|
||||||
import "game_event.proto";
|
|
||||||
import "serverinfo_playerping.proto";
|
|
||||||
|
|
||||||
message Event_Ping {
|
|
||||||
extend GameEvent {
|
|
||||||
optional Event_Ping ext = 1008;
|
|
||||||
}
|
|
||||||
optional uint32 seconds_elapsed = 1;
|
|
||||||
repeated ServerInfo_PlayerPing ping_list = 2;
|
|
||||||
}
|
|
|
@ -6,9 +6,7 @@ message GameEvent {
|
||||||
GAME_HOST_CHANGED = 1003;
|
GAME_HOST_CHANGED = 1003;
|
||||||
KICKED = 1004;
|
KICKED = 1004;
|
||||||
GAME_STATE_CHANGED = 1005;
|
GAME_STATE_CHANGED = 1005;
|
||||||
CONNECTION_STATE_CHANGED = 1006;
|
|
||||||
PLAYER_PROPERTIES_CHANGED = 1007;
|
PLAYER_PROPERTIES_CHANGED = 1007;
|
||||||
PING = 1008;
|
|
||||||
GAME_SAY = 1009;
|
GAME_SAY = 1009;
|
||||||
CREATE_ARROW = 2000;
|
CREATE_ARROW = 2000;
|
||||||
DELETE_ARROW = 2001;
|
DELETE_ARROW = 2001;
|
||||||
|
|
|
@ -6,6 +6,8 @@ message GameEventContext {
|
||||||
UNDO_DRAW = 1003;
|
UNDO_DRAW = 1003;
|
||||||
MOVE_CARD = 1004;
|
MOVE_CARD = 1004;
|
||||||
MULLIGAN = 1005;
|
MULLIGAN = 1005;
|
||||||
|
PING_CHANGED = 1006;
|
||||||
|
CONNECTION_STATE_CHANGED = 1007;
|
||||||
}
|
}
|
||||||
extensions 100 to max;
|
extensions 100 to max;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,4 +7,5 @@ message ServerInfo_PlayerProperties {
|
||||||
optional bool conceded = 4;
|
optional bool conceded = 4;
|
||||||
optional bool ready_start = 5;
|
optional bool ready_start = 5;
|
||||||
optional string deck_hash = 6;
|
optional string deck_hash = 6;
|
||||||
|
optional sint32 ping_seconds = 7;
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,12 +26,13 @@
|
||||||
#include "server_cardzone.h"
|
#include "server_cardzone.h"
|
||||||
#include "server_counter.h"
|
#include "server_counter.h"
|
||||||
#include "decklist.h"
|
#include "decklist.h"
|
||||||
|
#include "pb/context_connection_state_changed.pb.h"
|
||||||
|
#include "pb/context_ping_changed.pb.h"
|
||||||
|
#include "pb/event_player_properties_changed.pb.h"
|
||||||
#include "pb/event_game_closed.pb.h"
|
#include "pb/event_game_closed.pb.h"
|
||||||
#include "pb/event_game_host_changed.pb.h"
|
#include "pb/event_game_host_changed.pb.h"
|
||||||
#include "pb/event_game_state_changed.pb.h"
|
#include "pb/event_game_state_changed.pb.h"
|
||||||
#include "pb/event_connection_state_changed.pb.h"
|
|
||||||
#include "pb/event_kicked.pb.h"
|
#include "pb/event_kicked.pb.h"
|
||||||
#include "pb/event_ping.pb.h"
|
|
||||||
#include "pb/event_join.pb.h"
|
#include "pb/event_join.pb.h"
|
||||||
#include "pb/event_leave.pb.h"
|
#include "pb/event_leave.pb.h"
|
||||||
#include "pb/event_delete_arrow.pb.h"
|
#include "pb/event_delete_arrow.pb.h"
|
||||||
|
@ -77,9 +78,10 @@ Server_Game::~Server_Game()
|
||||||
void Server_Game::pingClockTimeout()
|
void Server_Game::pingClockTimeout()
|
||||||
{
|
{
|
||||||
QMutexLocker locker(&gameMutex);
|
QMutexLocker locker(&gameMutex);
|
||||||
|
++secondsElapsed;
|
||||||
|
|
||||||
Event_Ping event;
|
GameEventStorage ges;
|
||||||
event.set_seconds_elapsed(++secondsElapsed);
|
ges.setGameEventContext(Context_PingChanged());
|
||||||
|
|
||||||
QList<ServerInfo_PlayerPing *> pingList;
|
QList<ServerInfo_PlayerPing *> pingList;
|
||||||
QMapIterator<int, Server_Player *> playerIterator(players);
|
QMapIterator<int, Server_Player *> playerIterator(players);
|
||||||
|
@ -89,19 +91,28 @@ void Server_Game::pingClockTimeout()
|
||||||
Server_Player *player = playerIterator.next().value();
|
Server_Player *player = playerIterator.next().value();
|
||||||
if (!player->getSpectator())
|
if (!player->getSpectator())
|
||||||
++playerCount;
|
++playerCount;
|
||||||
int pingTime;
|
|
||||||
if (player->getProtocolHandler()) {
|
|
||||||
pingTime = player->getProtocolHandler()->getLastCommandTime();
|
|
||||||
if (!player->getSpectator())
|
|
||||||
allPlayersInactive = false;
|
|
||||||
} else
|
|
||||||
pingTime = -1;
|
|
||||||
|
|
||||||
ServerInfo_PlayerPing *pingInfo = event.add_ping_list();
|
const int oldPingTime = player->getPingTime();
|
||||||
pingInfo->set_player_id(player->getPlayerId());
|
player->playerMutex.lock();
|
||||||
pingInfo->set_ping_time(pingTime);
|
int newPingTime;
|
||||||
|
if (player->getProtocolHandler())
|
||||||
|
newPingTime = player->getProtocolHandler()->getLastCommandTime();
|
||||||
|
else
|
||||||
|
newPingTime = -1;
|
||||||
|
player->playerMutex.unlock();
|
||||||
|
|
||||||
|
if ((newPingTime != -1) && !player->getSpectator())
|
||||||
|
allPlayersInactive = false;
|
||||||
|
|
||||||
|
if ((abs(oldPingTime - newPingTime) > 1) || ((newPingTime == -1) && (oldPingTime != -1)) || ((newPingTime != -1) && (oldPingTime == -1))) {
|
||||||
|
player->setPingTime(newPingTime);
|
||||||
|
|
||||||
|
Event_PlayerPropertiesChanged event;
|
||||||
|
event.mutable_player_properties()->set_ping_seconds(newPingTime);
|
||||||
|
ges.enqueueGameEvent(event, player->getPlayerId());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
sendGameEventContainer(prepareGameEvent(event, -1));
|
ges.sendToGame(this);
|
||||||
|
|
||||||
const int maxTime = room->getServer()->getMaxGameInactivityTime();
|
const int maxTime = room->getServer()->getMaxGameInactivityTime();
|
||||||
if (allPlayersInactive) {
|
if (allPlayersInactive) {
|
||||||
|
@ -165,6 +176,7 @@ void Server_Game::doStartGameIfReady()
|
||||||
while (playerIterator.hasNext()) {
|
while (playerIterator.hasNext()) {
|
||||||
Server_Player *player = playerIterator.next().value();
|
Server_Player *player = playerIterator.next().value();
|
||||||
Event_GameStateChanged event;
|
Event_GameStateChanged event;
|
||||||
|
event.set_seconds_elapsed(secondsElapsed);
|
||||||
event.set_game_started(true);
|
event.set_game_started(true);
|
||||||
event.set_active_player_id(0);
|
event.set_active_player_id(0);
|
||||||
event.set_active_phase(0);
|
event.set_active_phase(0);
|
||||||
|
@ -229,6 +241,7 @@ void Server_Game::stopGameIfFinished()
|
||||||
while (playerIterator.hasNext()) {
|
while (playerIterator.hasNext()) {
|
||||||
Server_Player *player = playerIterator.next().value();
|
Server_Player *player = playerIterator.next().value();
|
||||||
Event_GameStateChanged event;
|
Event_GameStateChanged event;
|
||||||
|
event.set_seconds_elapsed(secondsElapsed);
|
||||||
event.set_game_started(false);
|
event.set_game_started(false);
|
||||||
QListIterator<ServerInfo_Player> gameStateIterator(getGameState(player));
|
QListIterator<ServerInfo_Player> gameStateIterator(getGameState(player));
|
||||||
while (gameStateIterator.hasNext())
|
while (gameStateIterator.hasNext())
|
||||||
|
@ -438,15 +451,6 @@ void Server_Game::nextTurn()
|
||||||
setActivePlayer(keys[listPos]);
|
setActivePlayer(keys[listPos]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Server_Game::postConnectionStatusUpdate(Server_Player *player, bool connectionStatus)
|
|
||||||
{
|
|
||||||
QMutexLocker locker(&gameMutex);
|
|
||||||
|
|
||||||
Event_ConnectionStateChanged event;
|
|
||||||
event.set_connected(connectionStatus);
|
|
||||||
sendGameEventContainer(prepareGameEvent(event, player->getPlayerId()));
|
|
||||||
}
|
|
||||||
|
|
||||||
QList<ServerInfo_Player> Server_Game::getGameState(Server_Player *playerWhosAsking) const
|
QList<ServerInfo_Player> Server_Game::getGameState(Server_Player *playerWhosAsking) const
|
||||||
{
|
{
|
||||||
QMutexLocker locker(&gameMutex);
|
QMutexLocker locker(&gameMutex);
|
||||||
|
|
|
@ -95,7 +95,7 @@ public:
|
||||||
void setActivePlayer(int _activePlayer);
|
void setActivePlayer(int _activePlayer);
|
||||||
void setActivePhase(int _activePhase);
|
void setActivePhase(int _activePhase);
|
||||||
void nextTurn();
|
void nextTurn();
|
||||||
void postConnectionStatusUpdate(Server_Player *player, bool connectionStatus);
|
int getSecondsElapsed() const { return secondsElapsed; }
|
||||||
|
|
||||||
QList<ServerInfo_Player> getGameState(Server_Player *playerWhosAsking) const;
|
QList<ServerInfo_Player> getGameState(Server_Player *playerWhosAsking) const;
|
||||||
|
|
||||||
|
|
|
@ -14,13 +14,15 @@
|
||||||
#include "pb/event_draw_cards.pb.h"
|
#include "pb/event_draw_cards.pb.h"
|
||||||
#include "pb/event_destroy_card.pb.h"
|
#include "pb/event_destroy_card.pb.h"
|
||||||
#include "pb/event_move_card.pb.h"
|
#include "pb/event_move_card.pb.h"
|
||||||
|
#include "pb/event_player_properties_changed.pb.h"
|
||||||
#include "pb/event_set_card_attr.pb.h"
|
#include "pb/event_set_card_attr.pb.h"
|
||||||
|
#include "pb/context_connection_state_changed.pb.h"
|
||||||
#include "pb/context_move_card.pb.h"
|
#include "pb/context_move_card.pb.h"
|
||||||
#include "pb/context_undo_draw.pb.h"
|
#include "pb/context_undo_draw.pb.h"
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
Server_Player::Server_Player(Server_Game *_game, int _playerId, const ServerInfo_User &_userInfo, bool _spectator, Server_ProtocolHandler *_handler)
|
Server_Player::Server_Player(Server_Game *_game, int _playerId, const ServerInfo_User &_userInfo, bool _spectator, Server_ProtocolHandler *_handler)
|
||||||
: game(_game), handler(_handler), userInfo(new ServerInfo_User(_userInfo)), deck(0), playerId(_playerId), spectator(_spectator), nextCardId(0), readyStart(false), conceded(false)
|
: game(_game), handler(_handler), userInfo(new ServerInfo_User(_userInfo)), deck(0), pingTime(0), playerId(_playerId), spectator(_spectator), nextCardId(0), readyStart(false), conceded(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -201,6 +203,7 @@ ServerInfo_PlayerProperties Server_Player::getProperties()
|
||||||
result.set_ready_start(readyStart);
|
result.set_ready_start(readyStart);
|
||||||
if (deck)
|
if (deck)
|
||||||
result.set_deck_hash(deck->getDeckHash().toStdString());
|
result.set_deck_hash(deck->getDeckHash().toStdString());
|
||||||
|
result.set_ping_seconds(pingTime);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -585,3 +588,20 @@ void Server_Player::sendGameEvent(GameEventContainer *cont)
|
||||||
if (handler)
|
if (handler)
|
||||||
handler->sendProtocolItem(*cont);
|
handler->sendProtocolItem(*cont);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Server_Player::setProtocolHandler(Server_ProtocolHandler *_handler)
|
||||||
|
{
|
||||||
|
playerMutex.lock();
|
||||||
|
handler = _handler;
|
||||||
|
playerMutex.unlock();
|
||||||
|
|
||||||
|
pingTime = _handler ? 0 : -1;
|
||||||
|
|
||||||
|
Event_PlayerPropertiesChanged event;
|
||||||
|
event.mutable_player_properties()->set_ping_seconds(pingTime);
|
||||||
|
|
||||||
|
GameEventStorage ges;
|
||||||
|
ges.setGameEventContext(Context_ConnectionStateChanged());
|
||||||
|
ges.enqueueGameEvent(event, playerId);
|
||||||
|
ges.sendToGame(game);
|
||||||
|
}
|
||||||
|
|
|
@ -27,7 +27,6 @@ class GameEventStorage;
|
||||||
class Server_Player : public Server_ArrowTarget {
|
class Server_Player : public Server_ArrowTarget {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
private:
|
private:
|
||||||
mutable QMutex playerMutex;
|
|
||||||
class MoveCardCompareFunctor;
|
class MoveCardCompareFunctor;
|
||||||
Server_Game *game;
|
Server_Game *game;
|
||||||
Server_ProtocolHandler *handler;
|
Server_ProtocolHandler *handler;
|
||||||
|
@ -37,6 +36,7 @@ private:
|
||||||
QMap<int, Server_Counter *> counters;
|
QMap<int, Server_Counter *> counters;
|
||||||
QMap<int, Server_Arrow *> arrows;
|
QMap<int, Server_Arrow *> arrows;
|
||||||
QList<int> lastDrawList;
|
QList<int> lastDrawList;
|
||||||
|
int pingTime;
|
||||||
int playerId;
|
int playerId;
|
||||||
bool spectator;
|
bool spectator;
|
||||||
int initialCards;
|
int initialCards;
|
||||||
|
@ -44,11 +44,12 @@ private:
|
||||||
bool readyStart;
|
bool readyStart;
|
||||||
bool conceded;
|
bool conceded;
|
||||||
public:
|
public:
|
||||||
|
mutable QMutex playerMutex;
|
||||||
Server_Player(Server_Game *_game, int _playerId, const ServerInfo_User &_userInfo, bool _spectator, Server_ProtocolHandler *_handler);
|
Server_Player(Server_Game *_game, int _playerId, const ServerInfo_User &_userInfo, bool _spectator, Server_ProtocolHandler *_handler);
|
||||||
~Server_Player();
|
~Server_Player();
|
||||||
void prepareDestroy();
|
void prepareDestroy();
|
||||||
Server_ProtocolHandler *getProtocolHandler() const { return handler; }
|
Server_ProtocolHandler *getProtocolHandler() const { return handler; }
|
||||||
void setProtocolHandler(Server_ProtocolHandler *_handler) { playerMutex.lock(); handler = _handler; playerMutex.unlock(); }
|
void setProtocolHandler(Server_ProtocolHandler *_handler);
|
||||||
|
|
||||||
void setPlayerId(int _id) { playerId = _id; }
|
void setPlayerId(int _id) { playerId = _id; }
|
||||||
int getInitialCards() const { return initialCards; }
|
int getInitialCards() const { return initialCards; }
|
||||||
|
@ -66,7 +67,9 @@ public:
|
||||||
const QMap<QString, Server_CardZone *> &getZones() const { return zones; }
|
const QMap<QString, Server_CardZone *> &getZones() const { return zones; }
|
||||||
const QMap<int, Server_Counter *> &getCounters() const { return counters; }
|
const QMap<int, Server_Counter *> &getCounters() const { return counters; }
|
||||||
const QMap<int, Server_Arrow *> &getArrows() const { return arrows; }
|
const QMap<int, Server_Arrow *> &getArrows() const { return arrows; }
|
||||||
|
|
||||||
|
int getPingTime() const { return pingTime; }
|
||||||
|
void setPingTime(int _pingTime) { pingTime = _pingTime; }
|
||||||
ServerInfo_PlayerProperties getProperties();
|
ServerInfo_PlayerProperties getProperties();
|
||||||
|
|
||||||
int newCardId();
|
int newCardId();
|
||||||
|
|
|
@ -114,12 +114,12 @@ void Server_ProtocolHandler::prepareDestroy()
|
||||||
Server_Game *g = gameIterator.value().first;
|
Server_Game *g = gameIterator.value().first;
|
||||||
Server_Player *p = gameIterator.value().second;
|
Server_Player *p = gameIterator.value().second;
|
||||||
|
|
||||||
|
g->gameMutex.lock();
|
||||||
if ((authState == UnknownUser) || p->getSpectator())
|
if ((authState == UnknownUser) || p->getSpectator())
|
||||||
g->removePlayer(p);
|
g->removePlayer(p);
|
||||||
else {
|
else
|
||||||
p->setProtocolHandler(0);
|
p->setProtocolHandler(0);
|
||||||
g->postConnectionStatusUpdate(p, false);
|
g->gameMutex.unlock();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
gameListMutex.unlock();
|
gameListMutex.unlock();
|
||||||
|
|
||||||
|
@ -220,6 +220,8 @@ Response::ResponseCode Server_ProtocolHandler::processSessionCommandContainer(co
|
||||||
num = fieldList[j]->number();
|
num = fieldList[j]->number();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (num != SessionCommand::PING)
|
||||||
|
emit logDebugMessage(QString::fromStdString(sc.ShortDebugString()), this);
|
||||||
switch ((SessionCommand::SessionCommandType) num) {
|
switch ((SessionCommand::SessionCommandType) num) {
|
||||||
case SessionCommand::PING: resp = cmdPing(sc.GetExtension(Command_Ping::ext), rc); break;
|
case SessionCommand::PING: resp = cmdPing(sc.GetExtension(Command_Ping::ext), rc); break;
|
||||||
case SessionCommand::LOGIN: resp = cmdLogin(sc.GetExtension(Command_Login::ext), rc); break;
|
case SessionCommand::LOGIN: resp = cmdLogin(sc.GetExtension(Command_Login::ext), rc); break;
|
||||||
|
@ -267,6 +269,7 @@ Response::ResponseCode Server_ProtocolHandler::processRoomCommandContainer(const
|
||||||
num = fieldList[j]->number();
|
num = fieldList[j]->number();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
emit logDebugMessage(QString::fromStdString(sc.ShortDebugString()), this);
|
||||||
switch ((RoomCommand::RoomCommandType) num) {
|
switch ((RoomCommand::RoomCommandType) num) {
|
||||||
case RoomCommand::LEAVE_ROOM: resp = cmdLeaveRoom(sc.GetExtension(Command_LeaveRoom::ext), room, rc); break;
|
case RoomCommand::LEAVE_ROOM: resp = cmdLeaveRoom(sc.GetExtension(Command_LeaveRoom::ext), room, rc); break;
|
||||||
case RoomCommand::ROOM_SAY: resp = cmdRoomSay(sc.GetExtension(Command_RoomSay::ext), room, rc); break;
|
case RoomCommand::ROOM_SAY: resp = cmdRoomSay(sc.GetExtension(Command_RoomSay::ext), room, rc); break;
|
||||||
|
@ -309,6 +312,7 @@ Response::ResponseCode Server_ProtocolHandler::processGameCommandContainer(const
|
||||||
num = fieldList[j]->number();
|
num = fieldList[j]->number();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
emit logDebugMessage(QString::fromStdString(sc.ShortDebugString()), this);
|
||||||
switch ((GameCommand::GameCommandType) num) {
|
switch ((GameCommand::GameCommandType) num) {
|
||||||
case GameCommand::KICK_FROM_GAME: resp = cmdKickFromGame(sc.GetExtension(Command_KickFromGame::ext), game, player, rc, ges); break;
|
case GameCommand::KICK_FROM_GAME: resp = cmdKickFromGame(sc.GetExtension(Command_KickFromGame::ext), game, player, rc, ges); break;
|
||||||
case GameCommand::LEAVE_GAME: resp = cmdLeaveGame(sc.GetExtension(Command_LeaveGame::ext), game, player, rc, ges); break;
|
case GameCommand::LEAVE_GAME: resp = cmdLeaveGame(sc.GetExtension(Command_LeaveGame::ext), game, player, rc, ges); break;
|
||||||
|
@ -344,23 +348,7 @@ Response::ResponseCode Server_ProtocolHandler::processGameCommandContainer(const
|
||||||
if ((resp != Response::RespOk) && (resp != Response::RespNothing))
|
if ((resp != Response::RespOk) && (resp != Response::RespNothing))
|
||||||
finalResponseCode = resp;
|
finalResponseCode = resp;
|
||||||
}
|
}
|
||||||
GameEventContainer *contPrivate = new GameEventContainer;
|
ges.sendToGame(game);
|
||||||
GameEventContainer *contOthers = new GameEventContainer;
|
|
||||||
const QList<GameEventStorageItem *> &gameEventList = ges.getGameEventList();
|
|
||||||
for (int i = 0; i < gameEventList.size(); ++i) {
|
|
||||||
const GameEvent &event = gameEventList[i]->getGameEvent();
|
|
||||||
const GameEventStorageItem::EventRecipients recipients = gameEventList[i]->getRecipients();
|
|
||||||
if (recipients.testFlag(GameEventStorageItem::SendToPrivate))
|
|
||||||
contPrivate->add_event_list()->CopyFrom(event);
|
|
||||||
if (recipients.testFlag(GameEventStorageItem::SendToOthers))
|
|
||||||
contOthers->add_event_list()->CopyFrom(event);
|
|
||||||
}
|
|
||||||
if (ges.getGameEventContext()) {
|
|
||||||
contPrivate->mutable_context()->CopyFrom(*ges.getGameEventContext());
|
|
||||||
contOthers->mutable_context()->CopyFrom(*ges.getGameEventContext());
|
|
||||||
}
|
|
||||||
game->sendGameEventContainer(contPrivate, GameEventStorageItem::SendToPrivate, ges.getPrivatePlayerId());
|
|
||||||
game->sendGameEventContainer(contOthers, GameEventStorageItem::SendToOthers, ges.getPrivatePlayerId());
|
|
||||||
return finalResponseCode;
|
return finalResponseCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -383,6 +371,7 @@ Response::ResponseCode Server_ProtocolHandler::processModeratorCommandContainer(
|
||||||
num = fieldList[j]->number();
|
num = fieldList[j]->number();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
emit logDebugMessage(QString::fromStdString(sc.ShortDebugString()), this);
|
||||||
switch ((ModeratorCommand::ModeratorCommandType) num) {
|
switch ((ModeratorCommand::ModeratorCommandType) num) {
|
||||||
case ModeratorCommand::BAN_FROM_SERVER: resp = cmdBanFromServer(sc.GetExtension(Command_BanFromServer::ext), rc); break;
|
case ModeratorCommand::BAN_FROM_SERVER: resp = cmdBanFromServer(sc.GetExtension(Command_BanFromServer::ext), rc); break;
|
||||||
}
|
}
|
||||||
|
@ -411,6 +400,7 @@ Response::ResponseCode Server_ProtocolHandler::processAdminCommandContainer(cons
|
||||||
num = fieldList[j]->number();
|
num = fieldList[j]->number();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
emit logDebugMessage(QString::fromStdString(sc.ShortDebugString()), this);
|
||||||
switch ((AdminCommand::AdminCommandType) num) {
|
switch ((AdminCommand::AdminCommandType) num) {
|
||||||
case AdminCommand::SHUTDOWN_SERVER: resp = cmdShutdownServer(sc.GetExtension(Command_ShutdownServer::ext), rc); break;
|
case AdminCommand::SHUTDOWN_SERVER: resp = cmdShutdownServer(sc.GetExtension(Command_ShutdownServer::ext), rc); break;
|
||||||
case AdminCommand::UPDATE_SERVER_MESSAGE: resp = cmdUpdateServerMessage(sc.GetExtension(Command_UpdateServerMessage::ext), rc); break;
|
case AdminCommand::UPDATE_SERVER_MESSAGE: resp = cmdUpdateServerMessage(sc.GetExtension(Command_UpdateServerMessage::ext), rc); break;
|
||||||
|
@ -539,7 +529,6 @@ Response::ResponseCode Server_ProtocolHandler::cmdLogin(const Command_Login &cmd
|
||||||
for (int j = 0; j < gamePlayers.size(); ++j)
|
for (int j = 0; j < gamePlayers.size(); ++j)
|
||||||
if (gamePlayers[j]->getUserInfo()->name() == userInfo->name()) {
|
if (gamePlayers[j]->getUserInfo()->name() == userInfo->name()) {
|
||||||
gamePlayers[j]->setProtocolHandler(this);
|
gamePlayers[j]->setProtocolHandler(this);
|
||||||
game->postConnectionStatusUpdate(gamePlayers[j], true);
|
|
||||||
games.insert(game->getGameId(), QPair<Server_Game *, Server_Player *>(game, gamePlayers[j]));
|
games.insert(game->getGameId(), QPair<Server_Game *, Server_Player *>(game, gamePlayers[j]));
|
||||||
|
|
||||||
Event_GameJoined event1;
|
Event_GameJoined event1;
|
||||||
|
@ -557,6 +546,7 @@ Response::ResponseCode Server_ProtocolHandler::cmdLogin(const Command_Login &cmd
|
||||||
QListIterator<ServerInfo_Player> gameStateIterator(game->getGameState(gamePlayers[j]));
|
QListIterator<ServerInfo_Player> gameStateIterator(game->getGameState(gamePlayers[j]));
|
||||||
while (gameStateIterator.hasNext())
|
while (gameStateIterator.hasNext())
|
||||||
event2.add_player_list()->CopyFrom(gameStateIterator.next());
|
event2.add_player_list()->CopyFrom(gameStateIterator.next());
|
||||||
|
event2.set_seconds_elapsed(game->getSecondsElapsed());
|
||||||
event2.set_game_started(game->getGameStarted());
|
event2.set_game_started(game->getGameStarted());
|
||||||
event2.set_active_player_id(game->getActivePlayer());
|
event2.set_active_player_id(game->getActivePlayer());
|
||||||
event2.set_active_phase(game->getActivePhase());
|
event2.set_active_phase(game->getActivePhase());
|
||||||
|
@ -773,6 +763,7 @@ Response::ResponseCode Server_ProtocolHandler::cmdCreateGame(const Command_Creat
|
||||||
QListIterator<ServerInfo_Player> gameStateIterator(game->getGameState(creator));
|
QListIterator<ServerInfo_Player> gameStateIterator(game->getGameState(creator));
|
||||||
while (gameStateIterator.hasNext())
|
while (gameStateIterator.hasNext())
|
||||||
event2.add_player_list()->CopyFrom(gameStateIterator.next());
|
event2.add_player_list()->CopyFrom(gameStateIterator.next());
|
||||||
|
event2.set_seconds_elapsed(0);
|
||||||
event2.set_game_started(game->getGameStarted());
|
event2.set_game_started(game->getGameStarted());
|
||||||
event2.set_active_player_id(game->getActivePlayer());
|
event2.set_active_player_id(game->getActivePlayer());
|
||||||
event2.set_active_phase(game->getActivePhase());
|
event2.set_active_phase(game->getActivePhase());
|
||||||
|
@ -819,6 +810,7 @@ Response::ResponseCode Server_ProtocolHandler::cmdJoinGame(const Command_JoinGam
|
||||||
QListIterator<ServerInfo_Player> gameStateIterator(g->getGameState(player));
|
QListIterator<ServerInfo_Player> gameStateIterator(g->getGameState(player));
|
||||||
while (gameStateIterator.hasNext())
|
while (gameStateIterator.hasNext())
|
||||||
event2.add_player_list()->CopyFrom(gameStateIterator.next());
|
event2.add_player_list()->CopyFrom(gameStateIterator.next());
|
||||||
|
event2.set_seconds_elapsed(g->getSecondsElapsed());
|
||||||
event2.set_game_started(g->getGameStarted());
|
event2.set_game_started(g->getGameStarted());
|
||||||
event2.set_active_player_id(g->getActivePlayer());
|
event2.set_active_player_id(g->getActivePlayer());
|
||||||
event2.set_active_phase(g->getActivePhase());
|
event2.set_active_phase(g->getActivePhase());
|
||||||
|
|
|
@ -169,6 +169,8 @@ private:
|
||||||
Response::ResponseCode processAdminCommandContainer(const CommandContainer &cont, ResponseContainer &rc);
|
Response::ResponseCode processAdminCommandContainer(const CommandContainer &cont, ResponseContainer &rc);
|
||||||
private slots:
|
private slots:
|
||||||
void pingClockTimeout();
|
void pingClockTimeout();
|
||||||
|
signals:
|
||||||
|
void logDebugMessage(const QString &message, Server_ProtocolHandler *session);
|
||||||
public:
|
public:
|
||||||
QMutex gameListMutex;
|
QMutex gameListMutex;
|
||||||
|
|
||||||
|
|
|
@ -1,74 +1,78 @@
|
||||||
/*
|
#include "server_response_containers.h"
|
||||||
Response_DeckDownload::Response_DeckDownload(int _cmdId, ResponseCode _responseCode, DeckList *_deck)
|
#include <google/protobuf/descriptor.h>
|
||||||
: ProtocolResponse(_cmdId, _responseCode, "deck_download")
|
#include "server_game.h"
|
||||||
|
|
||||||
|
GameEventStorageItem::GameEventStorageItem(const ::google::protobuf::Message &_event, int _playerId, EventRecipients _recipients)
|
||||||
|
: event(new GameEvent), recipients(_recipients)
|
||||||
{
|
{
|
||||||
if (!_deck)
|
event->GetReflection()->MutableMessage(event, _event.GetDescriptor()->FindExtensionByName("ext"))->CopyFrom(_event);
|
||||||
_deck = new DeckList;
|
event->set_player_id(_playerId);
|
||||||
insertItem(_deck);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DeckList *Response_DeckDownload::getDeck() const
|
GameEventStorageItem::~GameEventStorageItem()
|
||||||
{
|
{
|
||||||
return static_cast<DeckList *>(itemMap.value("cockatrice_deck"));
|
delete event;
|
||||||
}
|
}
|
||||||
|
|
||||||
Response_DeckUpload::Response_DeckUpload(int _cmdId, ResponseCode _responseCode, DeckList_File *_file)
|
GameEventStorage::GameEventStorage()
|
||||||
: ProtocolResponse(_cmdId, _responseCode, "deck_upload")
|
: gameEventContext(0)
|
||||||
{
|
{
|
||||||
if (!_file)
|
|
||||||
_file = new DeckList_File;
|
|
||||||
insertItem(_file);
|
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
/*
|
GameEventStorage::~GameEventStorage()
|
||||||
GameEventContainer::GameEventContainer(const QList<GameEvent *> &_eventList, int _gameId, GameEventContext *_context)
|
|
||||||
: ProtocolItem("container", "game_event")
|
|
||||||
{
|
{
|
||||||
insertItem(new SerializableItem_Int("game_id", _gameId));
|
delete gameEventContext;
|
||||||
|
for (int i = 0; i < gameEventList.size(); ++i)
|
||||||
|
delete gameEventList[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
void GameEventStorage::setGameEventContext(const ::google::protobuf::Message &_gameEventContext)
|
||||||
|
{
|
||||||
|
delete gameEventContext;
|
||||||
|
gameEventContext = new GameEventContext;
|
||||||
|
gameEventContext->GetReflection()->MutableMessage(gameEventContext, _gameEventContext.GetDescriptor()->FindExtensionByName("ext"))->CopyFrom(_gameEventContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GameEventStorage::enqueueGameEvent(const ::google::protobuf::Message &event, int playerId, GameEventStorageItem::EventRecipients recipients, int _privatePlayerId)
|
||||||
|
{
|
||||||
|
gameEventList.append(new GameEventStorageItem(event, playerId, recipients));
|
||||||
|
if (_privatePlayerId != -1)
|
||||||
|
privatePlayerId = _privatePlayerId;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GameEventStorage::sendToGame(Server_Game *game)
|
||||||
|
{
|
||||||
|
if (gameEventList.isEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
context = _context;
|
GameEventContainer *contPrivate = new GameEventContainer;
|
||||||
if (_context)
|
GameEventContainer *contOthers = new GameEventContainer;
|
||||||
itemList.append(_context);
|
for (int i = 0; i < gameEventList.size(); ++i) {
|
||||||
|
const GameEvent &event = gameEventList[i]->getGameEvent();
|
||||||
eventList = _eventList;
|
const GameEventStorageItem::EventRecipients recipients = gameEventList[i]->getRecipients();
|
||||||
for (int i = 0; i < _eventList.size(); ++i)
|
if (recipients.testFlag(GameEventStorageItem::SendToPrivate))
|
||||||
itemList.append(_eventList[i]);
|
contPrivate->add_event_list()->CopyFrom(event);
|
||||||
}
|
if (recipients.testFlag(GameEventStorageItem::SendToOthers))
|
||||||
|
contOthers->add_event_list()->CopyFrom(event);
|
||||||
void GameEventContainer::extractData()
|
|
||||||
{
|
|
||||||
for (int i = 0; i < itemList.size(); ++i) {
|
|
||||||
GameEvent *_event = dynamic_cast<GameEvent *>(itemList[i]);
|
|
||||||
GameEventContext *_context = dynamic_cast<GameEventContext *>(itemList[i]);
|
|
||||||
if (_event)
|
|
||||||
eventList.append(_event);
|
|
||||||
else if (_context)
|
|
||||||
context = _context;
|
|
||||||
}
|
}
|
||||||
}
|
if (gameEventContext) {
|
||||||
|
contPrivate->mutable_context()->CopyFrom(*gameEventContext);
|
||||||
void GameEventContainer::setContext(GameEventContext *_context)
|
contOthers->mutable_context()->CopyFrom(*gameEventContext);
|
||||||
{
|
|
||||||
for (int i = 0; i < itemList.size(); ++i) {
|
|
||||||
GameEventContext *temp = qobject_cast<GameEventContext *>(itemList[i]);
|
|
||||||
if (temp) {
|
|
||||||
delete temp;
|
|
||||||
itemList.removeAt(i);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
itemList.append(_context);
|
game->sendGameEventContainer(contPrivate, GameEventStorageItem::SendToPrivate, privatePlayerId);
|
||||||
context = _context;
|
game->sendGameEventContainer(contOthers, GameEventStorageItem::SendToOthers, privatePlayerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameEventContainer::addGameEvent(GameEvent *event)
|
ResponseContainer::ResponseContainer()
|
||||||
|
: responseExtension(0)
|
||||||
{
|
{
|
||||||
appendItem(event);
|
|
||||||
eventList.append(event);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GameEventContainer *GameEventContainer::makeNew(GameEvent *event, int _gameId)
|
ResponseContainer::~ResponseContainer()
|
||||||
{
|
{
|
||||||
return new GameEventContainer(QList<GameEvent *>() << event, _gameId);
|
delete responseExtension;
|
||||||
|
for (int i = 0; i < preResponseQueue.size(); ++i)
|
||||||
|
delete preResponseQueue[i].second;
|
||||||
|
for (int i = 0; i < postResponseQueue.size(); ++i)
|
||||||
|
delete postResponseQueue[i].second;
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
|
@ -1,21 +1,11 @@
|
||||||
#ifndef PROTOCOL_H
|
#ifndef SERVER_RESPONSE_CONTAINERS_H
|
||||||
#define PROTOCOL_H
|
#define SERVER_RESPONSE_CONTAINERS_H
|
||||||
|
|
||||||
#include <QString>
|
|
||||||
#include <QMap>
|
|
||||||
#include <QHash>
|
|
||||||
#include <QObject>
|
|
||||||
#include <QVariant>
|
|
||||||
#include <QPair>
|
#include <QPair>
|
||||||
|
|
||||||
#include <google/protobuf/message.h>
|
|
||||||
#include <google/protobuf/descriptor.h>
|
|
||||||
#include "pb/server_message.pb.h"
|
#include "pb/server_message.pb.h"
|
||||||
|
|
||||||
class DeckList;
|
namespace google { namespace protobuf { class Message; } }
|
||||||
class GameEvent;
|
class Server_Game;
|
||||||
class GameEventContainer;
|
|
||||||
class GameEventContext;
|
|
||||||
|
|
||||||
class GameEventStorageItem {
|
class GameEventStorageItem {
|
||||||
public:
|
public:
|
||||||
|
@ -25,16 +15,9 @@ private:
|
||||||
GameEvent *event;
|
GameEvent *event;
|
||||||
EventRecipients recipients;
|
EventRecipients recipients;
|
||||||
public:
|
public:
|
||||||
GameEventStorageItem(const ::google::protobuf::Message &_event, int _playerId, EventRecipients _recipients)
|
GameEventStorageItem(const ::google::protobuf::Message &_event, int _playerId, EventRecipients _recipients);
|
||||||
: event(new GameEvent), recipients(_recipients)
|
~GameEventStorageItem();
|
||||||
{
|
|
||||||
event->GetReflection()->MutableMessage(event, _event.GetDescriptor()->FindExtensionByName("ext"))->CopyFrom(_event);
|
|
||||||
event->set_player_id(_playerId);
|
|
||||||
}
|
|
||||||
~GameEventStorageItem()
|
|
||||||
{
|
|
||||||
delete event;
|
|
||||||
}
|
|
||||||
const GameEvent &getGameEvent() const { return *event; }
|
const GameEvent &getGameEvent() const { return *event; }
|
||||||
EventRecipients getRecipients() const { return recipients; }
|
EventRecipients getRecipients() const { return recipients; }
|
||||||
};
|
};
|
||||||
|
@ -46,32 +29,16 @@ private:
|
||||||
QList<GameEventStorageItem *> gameEventList;
|
QList<GameEventStorageItem *> gameEventList;
|
||||||
int privatePlayerId;
|
int privatePlayerId;
|
||||||
public:
|
public:
|
||||||
GameEventStorage()
|
GameEventStorage();
|
||||||
: gameEventContext(0)
|
~GameEventStorage();
|
||||||
{
|
|
||||||
}
|
|
||||||
~GameEventStorage()
|
|
||||||
{
|
|
||||||
delete gameEventContext;
|
|
||||||
for (int i = 0; i < gameEventList.size(); ++i)
|
|
||||||
delete gameEventList[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
void setGameEventContext(const ::google::protobuf::Message &_gameEventContext) {
|
void setGameEventContext(const ::google::protobuf::Message &_gameEventContext);
|
||||||
delete gameEventContext;
|
|
||||||
gameEventContext = new GameEventContext;
|
|
||||||
gameEventContext->GetReflection()->MutableMessage(gameEventContext, _gameEventContext.GetDescriptor()->FindExtensionByName("ext"))->CopyFrom(_gameEventContext);
|
|
||||||
}
|
|
||||||
::google::protobuf::Message *getGameEventContext() const { return gameEventContext; }
|
::google::protobuf::Message *getGameEventContext() const { return gameEventContext; }
|
||||||
const QList<GameEventStorageItem *> &getGameEventList() const { return gameEventList; }
|
const QList<GameEventStorageItem *> &getGameEventList() const { return gameEventList; }
|
||||||
int getPrivatePlayerId() const { return privatePlayerId; }
|
int getPrivatePlayerId() const { return privatePlayerId; }
|
||||||
|
|
||||||
void enqueueGameEvent(const ::google::protobuf::Message &event, int playerId, GameEventStorageItem::EventRecipients recipients = GameEventStorageItem::SendToPrivate | GameEventStorageItem::SendToOthers, int _privatePlayerId = -1)
|
void enqueueGameEvent(const ::google::protobuf::Message &event, int playerId, GameEventStorageItem::EventRecipients recipients = GameEventStorageItem::SendToPrivate | GameEventStorageItem::SendToOthers, int _privatePlayerId = -1);
|
||||||
{
|
void sendToGame(Server_Game *game);
|
||||||
gameEventList.append(new GameEventStorageItem(event, playerId, recipients));
|
|
||||||
if (_privatePlayerId != -1)
|
|
||||||
privatePlayerId = _privatePlayerId;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class ResponseContainer {
|
class ResponseContainer {
|
||||||
|
@ -79,15 +46,9 @@ private:
|
||||||
::google::protobuf::Message *responseExtension;
|
::google::protobuf::Message *responseExtension;
|
||||||
QList<QPair<ServerMessage::MessageType, ::google::protobuf::Message *> > preResponseQueue, postResponseQueue;
|
QList<QPair<ServerMessage::MessageType, ::google::protobuf::Message *> > preResponseQueue, postResponseQueue;
|
||||||
public:
|
public:
|
||||||
ResponseContainer() : responseExtension(0) { }
|
ResponseContainer();
|
||||||
~ResponseContainer()
|
~ResponseContainer();
|
||||||
{
|
|
||||||
delete responseExtension;
|
|
||||||
for (int i = 0; i < preResponseQueue.size(); ++i)
|
|
||||||
delete preResponseQueue[i].second;
|
|
||||||
for (int i = 0; i < postResponseQueue.size(); ++i)
|
|
||||||
delete postResponseQueue[i].second;
|
|
||||||
}
|
|
||||||
void setResponseExtension(::google::protobuf::Message *_responseExtension) { responseExtension = _responseExtension; }
|
void setResponseExtension(::google::protobuf::Message *_responseExtension) { responseExtension = _responseExtension; }
|
||||||
::google::protobuf::Message *getResponseExtension() const { return responseExtension; }
|
::google::protobuf::Message *getResponseExtension() const { return responseExtension; }
|
||||||
void enqueuePreResponseItem(ServerMessage::MessageType type, ::google::protobuf::Message *item) { preResponseQueue.append(qMakePair(type, item)); }
|
void enqueuePreResponseItem(ServerMessage::MessageType type, ::google::protobuf::Message *item) { preResponseQueue.append(qMakePair(type, item)); }
|
||||||
|
@ -96,34 +57,4 @@ public:
|
||||||
const QList<QPair<ServerMessage::MessageType, ::google::protobuf::Message *> > &getPostResponseQueue() const { return postResponseQueue; }
|
const QList<QPair<ServerMessage::MessageType, ::google::protobuf::Message *> > &getPostResponseQueue() const { return postResponseQueue; }
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
|
||||||
* XXX
|
|
||||||
*
|
|
||||||
class Response_DeckList : public ProtocolResponse {
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
Response_DeckList(int _cmdId = -1, ResponseCode _responseCode = RespOk, DeckList_Directory *_root = 0);
|
|
||||||
int getItemId() const { return ItemId_Response_DeckList; }
|
|
||||||
static SerializableItem *newItem() { return new Response_DeckList; }
|
|
||||||
DeckList_Directory *getRoot() const { return static_cast<DeckList_Directory *>(itemMap.value("directory")); }
|
|
||||||
};
|
|
||||||
|
|
||||||
class Response_DeckDownload : public ProtocolResponse {
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
Response_DeckDownload(int _cmdId = -1, ResponseCode _responseCode = RespOk, DeckList *_deck = 0);
|
|
||||||
int getItemId() const { return ItemId_Response_DeckDownload; }
|
|
||||||
static SerializableItem *newItem() { return new Response_DeckDownload; }
|
|
||||||
DeckList *getDeck() const;
|
|
||||||
};
|
|
||||||
|
|
||||||
class Response_DeckUpload : public ProtocolResponse {
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
Response_DeckUpload(int _cmdId = -1, ResponseCode _responseCode = RespOk, DeckList_File *_file = 0);
|
|
||||||
int getItemId() const { return ItemId_Response_DeckUpload; }
|
|
||||||
static SerializableItem *newItem() { return new Response_DeckUpload; }
|
|
||||||
DeckList_File *getFile() const { return static_cast<DeckList_File *>(itemMap.value("file")); }
|
|
||||||
};
|
|
||||||
*/
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -31,7 +31,7 @@ ServerLogger::~ServerLogger()
|
||||||
flushBuffer();
|
flushBuffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerLogger::logMessage(QString message, ServerSocketInterface *ssi)
|
void ServerLogger::logMessage(QString message, Server_ProtocolHandler *ssi)
|
||||||
{
|
{
|
||||||
if (!logFile)
|
if (!logFile)
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
class QSocketNotifier;
|
class QSocketNotifier;
|
||||||
class QFile;
|
class QFile;
|
||||||
class ServerSocketInterface;
|
class Server_ProtocolHandler;
|
||||||
|
|
||||||
class ServerLogger : public QObject {
|
class ServerLogger : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -18,7 +18,7 @@ public:
|
||||||
~ServerLogger();
|
~ServerLogger();
|
||||||
static void hupSignalHandler(int unused);
|
static void hupSignalHandler(int unused);
|
||||||
public slots:
|
public slots:
|
||||||
void logMessage(QString message, ServerSocketInterface *ssi = 0);
|
void logMessage(QString message, Server_ProtocolHandler *ssi = 0);
|
||||||
private slots:
|
private slots:
|
||||||
void handleSigHup();
|
void handleSigHup();
|
||||||
void flushBuffer();
|
void flushBuffer();
|
||||||
|
|
|
@ -57,6 +57,7 @@ ServerSocketInterface::ServerSocketInterface(Servatrice *_server, QTcpSocket *_s
|
||||||
connect(socket, SIGNAL(disconnected()), this, SLOT(deleteLater()));
|
connect(socket, SIGNAL(disconnected()), this, SLOT(deleteLater()));
|
||||||
connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(catchSocketError(QAbstractSocket::SocketError)));
|
connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(catchSocketError(QAbstractSocket::SocketError)));
|
||||||
connect(this, SIGNAL(outputBufferChanged()), this, SLOT(flushOutputBuffer()), Qt::QueuedConnection);
|
connect(this, SIGNAL(outputBufferChanged()), this, SLOT(flushOutputBuffer()), Qt::QueuedConnection);
|
||||||
|
connect(this, SIGNAL(logDebugMessage(const QString &, Server_ProtocolHandler *)), logger, SLOT(logMessage(QString, Server_ProtocolHandler *)));
|
||||||
|
|
||||||
Event_ServerIdentification identEvent;
|
Event_ServerIdentification identEvent;
|
||||||
identEvent.set_server_name(servatrice->getServerName().toStdString());
|
identEvent.set_server_name(servatrice->getServerName().toStdString());
|
||||||
|
@ -125,7 +126,6 @@ void ServerSocketInterface::readClient()
|
||||||
|
|
||||||
CommandContainer newCommandContainer;
|
CommandContainer newCommandContainer;
|
||||||
newCommandContainer.ParseFromArray(inputBuffer.data(), messageLength);
|
newCommandContainer.ParseFromArray(inputBuffer.data(), messageLength);
|
||||||
logger->logMessage(QString::fromStdString(newCommandContainer.ShortDebugString()), this);
|
|
||||||
inputBuffer.remove(0, messageLength);
|
inputBuffer.remove(0, messageLength);
|
||||||
messageInProgress = false;
|
messageInProgress = false;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue