multiplayer: check nickname regex server side

This commit is contained in:
zhupengfei
2018-12-15 10:40:27 +08:00
parent e040bc9355
commit 3c589f473f
4 changed files with 13 additions and 6 deletions
+2 -2
View File
@@ -12,8 +12,8 @@ const ConnectionError USERNAME_NOT_VALID(
QT_TR_NOOP("Username is not valid. Must be 4 to 20 alphanumeric characters."));
const ConnectionError ROOMNAME_NOT_VALID(
QT_TR_NOOP("Room name is not valid. Must be 4 to 20 alphanumeric characters."));
const ConnectionError USERNAME_IN_USE(
QT_TR_NOOP("Username is already in use. Please choose another."));
const ConnectionError USERNAME_NOT_VALID_SERVER(
QT_TR_NOOP("Username is already in use or not valid. Please choose another."));
const ConnectionError IP_ADDRESS_NOT_VALID(QT_TR_NOOP("IP is not a valid IPv4 address."));
const ConnectionError PORT_NOT_VALID(QT_TR_NOOP("Port must be a number between 0 to 65535."));
const ConnectionError NO_INTERNET(
+3 -1
View File
@@ -20,9 +20,11 @@ private:
std::string err;
};
/// When the nickname is considered invalid by the client
extern const ConnectionError USERNAME_NOT_VALID;
extern const ConnectionError ROOMNAME_NOT_VALID;
extern const ConnectionError USERNAME_IN_USE;
/// When the nickname is considered invalid by the room server
extern const ConnectionError USERNAME_NOT_VALID_SERVER;
extern const ConnectionError IP_ADDRESS_NOT_VALID;
extern const ConnectionError PORT_NOT_VALID;
extern const ConnectionError NO_INTERNET;
+1 -1
View File
@@ -97,7 +97,7 @@ void MultiplayerState::OnNetworkStateChanged(const Network::RoomMember::State& s
NetworkMessage::ShowError(NetworkMessage::UNABLE_TO_CONNECT);
break;
case Network::RoomMember::State::NameCollision:
NetworkMessage::ShowError(NetworkMessage::USERNAME_IN_USE);
NetworkMessage::ShowError(NetworkMessage::USERNAME_NOT_VALID_SERVER);
break;
case Network::RoomMember::State::MacCollision:
NetworkMessage::ShowError(NetworkMessage::MAC_COLLISION);