--- a/qmlfrontend/net_session.cpp Fri May 24 14:55:48 2019 +0200
+++ b/qmlfrontend/net_session.cpp Fri May 24 16:01:30 2019 +0200
@@ -84,9 +84,44 @@
using Handler = std::function<void(NetSession *, const QStringList &)>;
static QMap<QString, Handler> commandsMap{
+ {"ADD_TEAM", &NetSession::handleAddTeam},
+ {"ASKPASSWORD", &NetSession::handleAskPassword},
+ {"BANLIST", &NetSession::handleBanList},
+ {"BYE", &NetSession::handleBye},
+ {"CFG", &NetSession::handleCfg},
+ {"CHAT", &NetSession::handleChat},
+ {"CLIENT_FLAGS", &NetSession::handleClientFlags},
{"CONNECTED", &NetSession::handleConnected},
+ {"EM", &NetSession::handleEm},
+ {"ERROR", &NetSession::handleError},
+ {"HH_NUM", &NetSession::handleHhNum},
+ {"INFO", &NetSession::handleInfo},
+ {"JOINED", &NetSession::handleJoined},
+ {"JOINING", &NetSession::handleJoining},
+ {"KICKED", &NetSession::handleKicked},
+ {"LEFT", &NetSession::handleLeft},
+ {"LOBBY:JOINED", &NetSession::handleLobbyJoined},
+ {"LOBBY:LEFT", &NetSession::handleLobbyLeft},
+ {"NICK", &NetSession::handleNick},
+ {"NOTICE", &NetSession::handleNotice},
{"PING", &NetSession::handlePing},
- {"BYE", &NetSession::handleBye}};
+ {"PONG", &NetSession::handlePong},
+ {"PROTO", &NetSession::handleProto},
+ {"REDIRECT", &NetSession::handleRedirect},
+ {"REMOVE_TEAM", &NetSession::handleRemoveTeam},
+ {"REPLAY_START", &NetSession::handleReplayStart},
+ {"ROOMABANDONED", &NetSession::handleRoomAbandoned},
+ {"ROOM", &NetSession::handleRoom},
+ {"ROOMS", &NetSession::handleRooms},
+ {"ROUND_FINISHED", &NetSession::handleRoundFinished},
+ {"RUN_GAME", &NetSession::handleRunGame},
+ {"SERVER_AUTH", &NetSession::handleServerAuth},
+ {"SERVER_MESSAGE", &NetSession::handleServerMessage},
+ {"SERVER_VARS", &NetSession::handleServerVars},
+ {"TEAM_ACCEPTED", &NetSession::handleTeamAccepted},
+ {"TEAM_COLOR", &NetSession::handleTeamColor},
+ {"WARNING", &NetSession::handleWarning},
+ };
auto handler =
commandsMap.value(message[0], &NetSession::handleUnknownCommand);
@@ -95,7 +130,16 @@
}
void NetSession::handleConnected(const QStringList ¶meters) {
- setSessionState(Login);
+ if (parameters.length() < 2 || parameters[1].toInt() < cMinServerVersion) {
+ send("QUIT", "Server too old");
+ emit error(tr("Server too old"));
+ close();
+ } else {
+ setSessionState(Login);
+
+ send("NICK", m_nickname);
+ send("PROTO", QString::number(cProtocolVersion));
+ }
}
void NetSession::handlePing(const QStringList ¶meters) {
@@ -110,6 +154,78 @@
qWarning() << "Command is not recognized";
}
+void NetSession::handleAddTeam(const QStringList ¶meters) {}
+
+void NetSession::handleAskPassword(const QStringList ¶meters) {}
+
+void NetSession::handleBanList(const QStringList ¶meters) {}
+
+void NetSession::handleCfg(const QStringList ¶meters) {}
+
+void NetSession::handleChat(const QStringList ¶meters) {}
+
+void NetSession::handleClientFlags(const QStringList ¶meters) {}
+
+void NetSession::handleEm(const QStringList ¶meters) {}
+
+void NetSession::handleError(const QStringList ¶meters) {}
+
+void NetSession::handleHhNum(const QStringList ¶meters) {}
+
+void NetSession::handleInfo(const QStringList ¶meters) {}
+
+void NetSession::handleJoined(const QStringList ¶meters) {}
+
+void NetSession::handleJoining(const QStringList ¶meters) {}
+
+void NetSession::handleKicked(const QStringList ¶meters) {}
+
+void NetSession::handleLeft(const QStringList ¶meters) {}
+
+void NetSession::handleLobbyJoined(const QStringList ¶meters) {}
+
+void NetSession::handleLobbyLeft(const QStringList ¶meters) {}
+
+void NetSession::handleNick(const QStringList ¶meters) {
+ if (parameters.length()) setNickname(parameters[0]);
+}
+
+void NetSession::handleNotice(const QStringList ¶meters) {}
+
+void NetSession::handlePong(const QStringList ¶meters) {
+ Q_UNUSED(parameters)
+}
+
+void NetSession::handleProto(const QStringList ¶meters) {}
+
+void NetSession::handleRedirect(const QStringList ¶meters) {}
+
+void NetSession::handleRemoveTeam(const QStringList ¶meters) {}
+
+void NetSession::handleReplayStart(const QStringList ¶meters) {}
+
+void NetSession::handleRoomAbandoned(const QStringList ¶meters) {}
+
+void NetSession::handleRoom(const QStringList ¶meters) {}
+
+void NetSession::handleRooms(const QStringList ¶meters) {}
+
+void NetSession::handleRoundFinished(const QStringList ¶meters) {}
+
+void NetSession::handleRunGame(const QStringList ¶meters) {}
+
+void NetSession::handleServerAuth(const QStringList ¶meters) {}
+
+void NetSession::handleServerMessage(const QStringList ¶meters) {}
+
+void NetSession::handleServerVars(const QStringList ¶meters) {}
+
+void NetSession::handleTeamAccepted(const QStringList ¶meters) {}
+
+void NetSession::handleTeamColor(const QStringList ¶meters) {}
+
+void NetSession::handleWarning(const QStringList ¶meters) {}
+
void NetSession::send(const QString &message) { send(QStringList(message)); }
void NetSession::send(const QString &message, const QString ¶m) {