netMan.addMessage(msgCA);
int received = 0;
CharacterResult result = null;
while (received != 2) {
Message msg = getMessage(TIMEOUT_EXTENDED);
switch (msg.getType()) {
/* Account was created */
case S2C_CREATECHARACTER_ACK:
logger.debug("Create character ACK");
MessageS2CCreateCharacterACK msgack = (MessageS2CCreateCharacterACK) msg;
result = new CharacterResult(Result.OK_CREATED, msgack.getCharacter(), msgack
.getTemplate());
received++;
break;
/* Server send the character list */
case S2C_CHARACTERLIST:
logger.debug("Received Character list");
/*
* We notify client of characters by calling the callback
* method.
*/
String[] characters = ((MessageS2CCharacterList) msg).getCharacters();
onAvailableCharacters(characters);
Map<String, RPObject> characterDetails = ((MessageS2CCharacterList) msg).getCharacterDetails();
onAvailableCharacterDetails(characterDetails);
received++;
break;
/* Account was not created. Reason explained on event and return. */
case S2C_CREATECHARACTER_NACK:
logger.debug("Create character NACK");
MessageS2CCreateCharacterNACK reply = (MessageS2CCreateCharacterNACK) msg;
result = new CharacterResult(reply.getResolutionCode(), character, template);
return result;
}
}
return result;