return msg;
}
private String getName(int id, int eventPort, int commandPort, int messengerPort, GameOptions pGo) {
_logger.info("waiting on port " + initialConnectionPort);
MessageSender ms = null;
try {
while(true) {
try {
ms = new MessageSender(initialConnectionPort);
Message msg = createGetNameMessage(id, eventPort, commandPort, messengerPort, pGo);
Message response = ms.sendMessageAndGetResponse(msg);
for(MessageParam mp :response.getMsgParams()) {
if(mp.getName().equals(MessageParamConstants.PLAYER_NAME)) {
return mp.getValue();
}
}
} catch (BindException be) {
System.gc();
try {
Thread.sleep(500);
} catch (InterruptedException e) {
e.printStackTrace();
}
continue;
} catch (IOException e) {
e.printStackTrace();
return "ERROR " + eventPort;
}
}
} finally {
if(ms != null) {
ms.close();
}
}
}