Package com.svanloon.game.wizard.network

Examples of com.svanloon.game.wizard.network.MessageReceiver


    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();
      }
    }
   
    commandPort = getCommandPort(message);
    eventPort = getEventPort(message);
    _logger.info("commandPort = " + commandPort);
    _logger.info("eventPort = " + eventPort);

    Player player = scottPlayer;

    ClientCommandNotifier mr = new ClientCommandNotifier(player, ip, commandPort);
    Thread mrt = new Thread(mr);
    mrt.start();

    MessageReceiver emr;
    try {
      emr = new MessageReceiver(ip, eventPort);
    } catch (UnknownHostException e) {
      e.printStackTrace();
      return;
    } catch (IOException e) {
      e.printStackTrace();
View Full Code Here


    this.port = port;
  }
 
  public void run() {
    try {
      this.mr = new MessageReceiver(this.ip, this.port);
    } catch (UnknownHostException e1) {
      e1.printStackTrace();
    } catch (IOException e1) {
      e1.printStackTrace();
    }
View Full Code Here

    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();
View Full Code Here

TOP

Related Classes of com.svanloon.game.wizard.network.MessageReceiver

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.