Package com.svanloon.game.wizard.network

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


    return this.hand.iterator().next();
  }

  public int bid(Card trump, int min, int max, int notAllowedToBid) {
    try {
      Message message = new Message(MessageType.BID);
      ms.addCard(message, trump);
      message.addMsgParam(new MessageParam(MessageParamConstants.MIN, String.valueOf(min)));
      message.addMsgParam(new MessageParam(MessageParamConstants.MAX, String.valueOf(max)));
      message.addMsgParam(new MessageParam(MessageParamConstants.BID_NOT_ALLOWED, String.valueOf(notAllowedToBid)));
      return ms.getInt(message);
    } catch (IOException e) {
      e.printStackTrace();
    }
    return 0;
View Full Code Here


  }

  private void send(WizardEvent we) {
    try {
      ServerGameEventMessageGenerator wmg = new ServerGameEventMessageGenerator();
      Message message = wmg.createMessage(we);
      while (ems == null) {
        Thread.sleep(35);
      }
      ems.sendMessageAndGetResponse(message);
    } catch (Exception e) {
View Full Code Here

    return np;
  }

  private Message createGetNameMessage(int id, int eventPort, int commandPort, int messengerPort, GameOptions pGo) {
    Message msg = new Message(MessageType.GET_NAME);
    msg.addMsgParam(new MessageParam(MessageParamConstants.PLAYER_ID, String.valueOf(id)));
    msg.addMsgParam(new MessageParam(MessageParamConstants.COMMAND_PORT, String.valueOf(commandPort)));
    msg.addMsgParam(new MessageParam(MessageParamConstants.EVENT_PORT, String.valueOf(eventPort)));
    msg.addMsgParam(new MessageParam(MessageParamConstants.MESSENGER_PORT, String.valueOf(messengerPort)));
    msg.addMsgParam(new MessageParam(MessageParamConstants.NUMBER_OF_PLAYERS, String.valueOf(pGo.getTotalNumberOfPlayers())));
    return msg;
  }
View Full Code Here

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

TOP

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

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.