String name = getName();
String ip = getIp();
// estatablish connection with server
MessageReceiver mr2 = null;
Message message;
try {
mr2 = new MessageReceiver(ip, initialConnectionPort);
message = mr2.receive();
Message response = new Message(MessageType.GET_NAME);
response.addMsgParam(new MessageParam(MessageParamConstants.PLAYER_NAME, name));
mr2.sendMessage(response);
mr2.close();
} catch (UnknownHostException e2) {
e2.printStackTrace();
return;
} catch (IOException e2) {
e2.printStackTrace();
return;
} finally {
if(mr2 != null) {
mr2.close();
}
}
int playerId = getPlayerId(message);
int commandPort = getCommandPort(message);
int eventPort = getEventPort(message);
int messengerPort = getMessengerPort(message);
int totalNumberOfPlayers = getTotalNumberOfPlayers(message);
_logger.info("commandPort = " + commandPort);
_logger.info("eventPort = " + eventPort);
HumanPlayerSwing player = new HumanPlayerSwing(totalNumberOfPlayers, up);
player.setUserPreferences(up);
player.setName(name);
player.setId(playerId);
player.setVisible(true);
ClientCommandNotifier mr = new ClientCommandNotifier(player, ip, commandPort);
Thread mrt = new Thread(mr);
mrt.setName("ClientCommandNotifier" + commandPort);
mrt.start();
MessageReceiver emr;
try {
emr = new MessageReceiver(ip, eventPort);
} catch (UnknownHostException e) {
e.printStackTrace();
return;
} catch (IOException e) {
e.printStackTrace();