diff --git a/cockatrice/src/client.cpp b/cockatrice/src/client.cpp index d8eab108..03af1524 100644 --- a/cockatrice/src/client.cpp +++ b/cockatrice/src/client.cpp @@ -34,6 +34,7 @@ void Client::checkTimeout() return; } } + ping(); } void Client::slotSocketError(QAbstractSocket::SocketError error) @@ -205,6 +206,11 @@ void Client::disconnectFromServer() socket->close(); } +int Client::ping() +{ + return cmd("ping"); +} + int Client::listGames() { return cmd("list_games"); diff --git a/cockatrice/src/client.h b/cockatrice/src/client.h index 0e89ef77..4fe426f0 100644 --- a/cockatrice/src/client.h +++ b/cockatrice/src/client.h @@ -62,6 +62,7 @@ public: void connectToServer(const QString &hostname, unsigned int port, const QString &playername, const QString &password); void disconnectFromServer(); + int ping(); int listGames(); int listPlayers(); int createGame(const QString &description, const QString &password, unsigned int maxPlayers); diff --git a/cockatrice/src/dlg_connect.cpp b/cockatrice/src/dlg_connect.cpp index 52dccaaa..0c3d7621 100644 --- a/cockatrice/src/dlg_connect.cpp +++ b/cockatrice/src/dlg_connect.cpp @@ -5,7 +5,7 @@ DlgConnect::DlgConnect(QWidget *parent) : QDialog(parent) { hostLabel = new QLabel(tr("&Host:")); - hostEdit = new QLineEdit("localhost"); + hostEdit = new QLineEdit("cockatrice.de"); hostLabel->setBuddy(hostEdit); portLabel = new QLabel(tr("&Port:")); diff --git a/servatrice/src/serversocket.cpp b/servatrice/src/serversocket.cpp index 8afb76e8..222c01a4 100644 --- a/servatrice/src/serversocket.cpp +++ b/servatrice/src/serversocket.cpp @@ -182,6 +182,7 @@ void ServerSocket::readClient() } const ServerSocket::CommandProperties ServerSocket::commandList[ServerSocket::numberCommands] = { + {"ping", false, false, false, QList(), &ServerSocket::cmdPing}, {"login", false, false, false, QList() << QVariant::String << QVariant::String, &ServerSocket::cmdLogin}, {"list_games", true, false, false, QList(), &ServerSocket::cmdListGames}, @@ -230,6 +231,11 @@ const ServerSocket::CommandProperties ServerSocket::commandList[ServerSocket::nu {"set_active_phase", true, true, true, QList() << QVariant::Int, &ServerSocket::cmdSetActivePhase} }; +ReturnMessage::ReturnCode ServerSocket::cmdPing(const QList ¶ms) +{ + return ReturnMessage::ReturnOk; +} + ReturnMessage::ReturnCode ServerSocket::cmdLogin(const QList ¶ms) { authState = server->checkUserPassword(params[0].toString(), params[1].toString()); diff --git a/servatrice/src/serversocket.h b/servatrice/src/serversocket.h index 052b7c4f..0fb3e0f6 100644 --- a/servatrice/src/serversocket.h +++ b/servatrice/src/serversocket.h @@ -55,9 +55,10 @@ private: QList paramTypes; CommandHandler handler; }; - static const int numberCommands = 24; + static const int numberCommands = 25; static const CommandProperties commandList[numberCommands]; + ReturnMessage::ReturnCode cmdPing(const QList ¶ms); ReturnMessage::ReturnCode cmdLogin(const QList ¶ms); ReturnMessage::ReturnCode cmdListGames(const QList ¶ms); ReturnMessage::ReturnCode cmdCreateGame(const QList ¶ms);