* resources but doing nothing useful at all.
*/
if (playerContainer.size() >= maxNumberOfPlayers) {
logger.info("Server is full, making room now");
/* Let's try to make some room for more players. */
PlayerEntry candidate = playerContainer.getIdleEntry();
if (candidate != null) {
/*
* Cool!, we got a candidate, so we remove and disconnect
* it.
*/
netMan.disconnectClient(candidate.channel);
/*
* HACK: Remove the entry now so we can continue.
*/
playerContainer.remove(candidate.clientid);
}
}
/*
* We give a new try to see if we can create a entry for this
* player.
*/
if (playerContainer.size() >= maxNumberOfPlayers) {
/* Error: Too many clients logged on the server. */
logger.warn("Server is full, Client(" + msg.getAddress().toString()
+ ") can't login. You may want to increase max_number_of_players in your server.init. Current value is: " + maxNumberOfPlayers);
/* Notify player of the event. */
MessageS2CLoginNACK msgLoginNACK = new MessageS2CLoginNACK(msg.getSocketChannel(),
MessageS2CLoginNACK.Reasons.SERVER_IS_FULL);
msgLoginNACK.setProtocolVersion(msg.getProtocolVersion());
netMan.sendMessage(msgLoginNACK);
return;
}
MessageC2SLoginSendPromise msgLoginSendPromise = (MessageC2SLoginSendPromise) msg;
PlayerEntry entry = playerContainer.add(msgLoginSendPromise.getSocketChannel());
entry.setProtocolVersion(msg.getProtocolVersion());
byte[] serverNonce = Hash.random(Hash.hashLength());
byte[] clientNonceHash = msgLoginSendPromise.getHash();
entry.loginInformations = new PlayerEntry.SecuredLoginInfo(key, clientNonceHash,