doHandshake(client, m);
}
private void doHandshake(ClientState client, Message m) {
if (m instanceof GameVersionMessage) {
GameVersionMessage msg = (GameVersionMessage) m;
if (!systemManager.validateGameVersion(msg.getGameVersion())) {
client.setUpToDate(false);
client.conn.send(new GameVersionMessage(systemManager.getGameVersion()));
} else {
client.setUpToDate(true);
client.conn.send(new GameInformationMessage(systemManager.getActualGameInformation()));
}
} else if (m instanceof AuthorizeMessage) {
if (!client.isUpToDate()) {
clientMap.remove(client.conn.getId());
client.conn.close("You MUST update your Client!");
}
if (client.isAuthorized())
return;
AuthorizeMessage msg = (AuthorizeMessage) m;
UserAuthorizedToken token = securityManager.authorize(msg.getUsername(), msg.getPassword());
if (token == null) {
clientMap.remove(client.conn.getId());
client.conn.close("Username/password not known or incorrect!");
} else {
client.setAuthenticationToken(token);