Package de.pokerth.protocol.ProtoBuf

Examples of de.pokerth.protocol.ProtoBuf.PokerTHMessage


  }

  @Test
  public void testAnnounce() throws Exception {

    PokerTHMessage msg = receiveMessage();
    assertTrue(msg.hasAnnounceMessage() && msg.getMessageType() == PokerTHMessageType.Type_AnnounceMessage);
    TestAnnounceMsg(msg.getAnnounceMessage(), 0);

    // numPlayersOnServer should only be incremented after login.
    Socket s[] = new Socket[9];
    for (int i = 0; i < 9; i++) {
      s[i] = new Socket("localhost", 7234);
      msg = receiveMessage(s[i]);
      assertTrue(msg.hasAnnounceMessage() && msg.getMessageType() == PokerTHMessageType.Type_AnnounceMessage);
      // Without login: Counter stays at 0.
      TestAnnounceMsg(msg.getAnnounceMessage(), 0);
    }

    Socket t[] = new Socket[9];
    for (int i = 0; i < 9; i++) {
      t[i] = new Socket("localhost", 7234);
      String username = "test" + (i+1);
      String password = username;
      userInit(t[i], username, password);

      sock.close();
      sock = new Socket("localhost", 7234);
      msg = receiveMessage();
      assertTrue(msg.hasAnnounceMessage() && msg.getMessageType() == PokerTHMessageType.Type_AnnounceMessage);
      // After login: Counter is incremented.
      TestAnnounceMsg(msg.getAnnounceMessage(), i + 1);
    }

    for (int i = 0; i < 9; i++) {
      s[i].close();

      // Closing non-established sessions: counter stays the same.
      sock.close();
      sock = new Socket("localhost", 7234);
      msg = receiveMessage();
      assertTrue(msg.hasAnnounceMessage() && msg.getMessageType() == PokerTHMessageType.Type_AnnounceMessage);
      // After login: Counter is incremented.
      TestAnnounceMsg(msg.getAnnounceMessage(), 9);
    }

    for (int i = 0; i < 9; i++) {
      t[i].close();
      Thread.sleep(1000);

      // Closing established sessions: counter is decremented.
      sock.close();
      sock = new Socket("localhost", 7234);
      msg = receiveMessage();
      assertTrue(msg.hasAnnounceMessage() && msg.getMessageType() == PokerTHMessageType.Type_AnnounceMessage);
      // After login: Counter is incremented.
      TestAnnounceMsg(msg.getAnnounceMessage(), 8 - i);
    }
  }
View Full Code Here


  protected void sendPlayerInfoRequest(Socket s, Collection<Integer> playerIds) throws Exception {
    PlayerInfoRequestMessage request = PlayerInfoRequestMessage.newBuilder()
      .addAllPlayerId(playerIds)
      .build();
    PokerTHMessage msg = PokerTHMessage.newBuilder()
        .setMessageType(PokerTHMessageType.Type_PlayerInfoRequestMessage)
        .setPlayerInfoRequestMessage(request)
        .build();
    sendMessage(msg, s);
  }
View Full Code Here

      }
      if (playerId[i] > maxPlayerId) {
        maxPlayerId = playerId[i];
      }
    }
    PokerTHMessage msg;

    // Request player info, for guest first.
    for (int i = 0; i < 9; i++) {
      sendPlayerInfoRequest(s[i], firstPlayerId);
      do {
        msg = receiveMessage(s[i]);
      } while (msg.hasPlayerListMessage());
      assertTrue(msg.hasPlayerInfoReplyMessage() && msg.getMessageType() == PokerTHMessageType.Type_PlayerInfoReplyMessage);
      PlayerInfoReplyMessage reply = msg.getPlayerInfoReplyMessage();
      assertTrue(reply.getPlayerId() == firstPlayerId);
      assertTrue(reply.hasPlayerInfoData());
      PlayerInfoData info = reply.getPlayerInfoData();
      assertEquals(GuestUser, info.getPlayerName());
      assertFalse(info.hasCountryCode());
      assertTrue(info.getIsHuman());
      assertEquals(NetPlayerInfoRights.netPlayerRightsGuest, info.getPlayerRights());
      assertFalse(info.hasAvatarData());
    }
    // Request other players' info (one request containing 9 queries).
    Collection<Integer> tmpList = new ArrayList<Integer>();
    for (Integer id : playerId) { tmpList.add(id); }
    sendPlayerInfoRequest(sock, tmpList);

    for (int i = 0; i < 9; i++) {
      do {
        msg = receiveMessage();
      } while (msg.hasPlayerListMessage());
      assertTrue(msg.hasPlayerInfoReplyMessage() && msg.getMessageType() == PokerTHMessageType.Type_PlayerInfoReplyMessage);
      PlayerInfoReplyMessage reply = msg.getPlayerInfoReplyMessage();
      assertTrue(reply.getPlayerId() == playerId[i]);
      assertTrue(reply.hasPlayerInfoData());
      PlayerInfoData info = reply.getPlayerInfoData();
      assertEquals("test" + (i+1), info.getPlayerName());
      assertFalse(info.hasCountryCode());
      assertTrue(info.getIsHuman());
      assertEquals(NetPlayerInfoRights.netPlayerRightsNormal, info.getPlayerRights());
      // Every second player has an avatar, see above.
      if (i % 2 == 0) {
        assertFalse(info.hasAvatarData());
      } else {
        assertTrue(info.hasAvatarData());
        assertTrue(Arrays.equals(info.getAvatarData().getAvatarHash().toByteArray(), avatarHash));
        assertEquals(NetAvatarType.netAvatarImagePng, info.getAvatarData().getAvatarType());
      }
    }
    // Request invalid player info.
    sendPlayerInfoRequest(sock, maxPlayerId + 1);
    msg = receiveMessage();
    assertTrue(msg.hasPlayerInfoReplyMessage() && msg.getMessageType() == PokerTHMessageType.Type_PlayerInfoReplyMessage);
    PlayerInfoReplyMessage reply = msg.getPlayerInfoReplyMessage();
    assertTrue(reply.getPlayerId() == maxPlayerId + 1);
    assertFalse(reply.hasPlayerInfoData());

    for (int i = 0; i < 9; i++) {
      s[i].close();
View Full Code Here

  public void testSpectatorJoinGameBeforeStart() throws Exception {
    Guid firstPlayerSession = new Guid();
    int firstPlayerId = userInit(sock, AuthUser, AuthPassword, null, firstPlayerSession);

    // Waiting for player list update.
    PokerTHMessage msg;
    msg = receiveMessage();
    if (!msg.hasPlayerListMessage()) {
      failOnErrorMessage(msg);
      fail("Invalid message: " + msg.getMessageType());
    }

    Collection<Integer> l = new ArrayList<Integer>();
    String gameName = AuthUser + " rejoin game";
    NetGameInfo gameInfo = createGameInfo(NetGameType.normalGame, 5, 7, 5, EndRaiseMode.doubleBlinds, 0, 50, gameName, l, 10, 0, 11, 10000);
    sendMessage(createGameRequestMsg(
        gameInfo,
        "",
        false));

    // Game list update (new game)
    msg = receiveMessage();
    if (!msg.hasGameListNewMessage()) {
      failOnErrorMessage(msg);
      fail("Invalid message: " + msg.getMessageType());
    }

    // Join game ack.
    msg = receiveMessage();
    if (!msg.hasJoinGameAckMessage()) {
      failOnErrorMessage(msg);
      fail("Could not create game!");
    }
    int gameId = msg.getJoinGameAckMessage().getGameId();

    // Game list update (player joined).
    msg = receiveMessage();
    if (!msg.hasGameListPlayerJoinedMessage()) {
      failOnErrorMessage(msg);
      fail("Invalid message: " + msg.getMessageType());
    }

    // Let a spectator join.
    Socket spectatorSock = new Socket("localhost", 7234);
    int spectatorId = userInit(spectatorSock, "test20", "test20");

    msg = receiveMessage(spectatorSock);
    if (!msg.hasPlayerListMessage()) {
      failOnErrorMessage(msg);
      fail("Invalid message: " + msg.getMessageType());
    }
    msg = receiveMessage(spectatorSock);
    if (!msg.hasGameListNewMessage()) {
      failOnErrorMessage(msg);
      fail("Invalid message: " + msg.getMessageType());
    }
    msg = receiveMessage(spectatorSock);
    if (!msg.hasPlayerListMessage()) {
      failOnErrorMessage(msg);
      fail("Invalid message: " + msg.getMessageType());
    }
    // Player List should also be updated for first player.
    msg = receiveMessage();
    if (!msg.hasPlayerListMessage()) {
      failOnErrorMessage(msg);
      fail("Invalid message: " + msg.getMessageType());
    }

    sendMessage(joinGameRequestMsg(gameId, "", false, true), spectatorSock);
    msg = receiveMessage(spectatorSock);
    if (!msg.hasJoinGameAckMessage()) {
      failOnErrorMessage(msg);
      fail("Invalid message: " + msg.getMessageType());
    }
    assertTrue(msg.getJoinGameAckMessage().getSpectateOnly());

    msg = receiveMessage(spectatorSock);
    if (!msg.hasGamePlayerJoinedMessage()) {
      failOnErrorMessage(msg);
      fail("Invalid message: " + msg.getMessageType());
    }
    assertEquals(firstPlayerId, msg.getGamePlayerJoinedMessage().getPlayerId());
    // TODO Spectator joined message is missing here!

    msg = receiveMessage(spectatorSock);
    if (!msg.hasGameListSpectatorJoinedMessage()) {
      failOnErrorMessage(msg);
      fail("Invalid message: " + msg.getMessageType());
    }
    assertEquals(gameId, msg.getGameListSpectatorJoinedMessage().getGameId());
    assertEquals(spectatorId, msg.getGameListSpectatorJoinedMessage().getPlayerId());

    // Spectator should be visible for first player.
    msg = receiveMessage();
    if (!msg.hasGameSpectatorJoinedMessage()) {
      failOnErrorMessage(msg);
      fail("Invalid message: " + msg.getMessageType());
    }
    msg = receiveMessage();
    if (!msg.hasGameListSpectatorJoinedMessage()) {
      failOnErrorMessage(msg);
      fail("Invalid message: " + msg.getMessageType());
    }

    // Let 9 additional clients join.
    Socket s[] = new Socket[9];
    int playerId[] = new int[9];
    for (int i = 0; i < 9; i++) {
      s[i] = new Socket("localhost", 7234);
      String username = "test" + (i+1);
      String password = username;
      playerId[i] = userInit(s[i], username, password);
     
      // Waiting for player list update.
      do {
        msg = receiveMessage(s[i]);
      } while (msg.hasPlayerListMessage());

      if (!msg.hasGameListNewMessage()) {
        failOnErrorMessage(msg);
        fail("Invalid message: " + msg.getMessageType());
      }
      assertEquals(1, msg.getGameListNewMessage().getSpectatorIdsCount());
      assertEquals(spectatorId, msg.getGameListNewMessage().getSpectatorIds(0));
      do {
        msg = receiveMessage(s[i]);
      } while (msg.hasGameListPlayerJoinedMessage() || msg.hasGamePlayerJoinedMessage());
      sendMessage(joinGameRequestMsg(gameId, "", false), s[i]);
      do {
        msg = receiveMessage(s[i]);
        failOnErrorMessage(msg);
      } while (!msg.hasJoinGameAckMessage() && !msg.hasJoinGameFailedMessage());
      if (!msg.hasJoinGameAckMessage()) {
        fail("User " + username + " could not join ranking game.");
      }

      // The player should have joined the game.
      msg = receiveMessage();
      if (!msg.hasPlayerListMessage()) {
        failOnErrorMessage(msg);
        fail("Invalid message: " + msg.getMessageType());
      }
      msg = receiveMessage();
      if (!msg.hasGamePlayerJoinedMessage()) {
        failOnErrorMessage(msg);
        fail("Invalid message: " + msg.getMessageType());
      }
      msg = receiveMessage();
      if (!msg.hasGameListPlayerJoinedMessage()) {
        failOnErrorMessage(msg);
        fail("Invalid message: " + msg.getMessageType());
      }
      // The spectator should also receive the updates.
      msg = receiveMessage(spectatorSock);
      if (!msg.hasPlayerListMessage()) {
        failOnErrorMessage(msg);
        fail("Invalid message: " + msg.getMessageType());
      }
      msg = receiveMessage(spectatorSock);
      if (!msg.hasGamePlayerJoinedMessage()) {
        failOnErrorMessage(msg);
        fail("Invalid message: " + msg.getMessageType());
      }
      msg = receiveMessage(spectatorSock);
      if (!msg.hasGameListPlayerJoinedMessage()) {
        failOnErrorMessage(msg);
        fail("Invalid message: " + msg.getMessageType());
      }
    }

    // Server should automatically send start event.
    msg = receiveMessage();
    if (!msg.hasStartEventMessage()) {
      failOnErrorMessage(msg);
      fail("Invalid message: " + msg.getMessageType());
    }
    for (int i = 0; i < 9; i++) {
      do {
        msg = receiveMessage(s[i]);
        failOnErrorMessage(msg);
      } while (!msg.hasStartEventMessage());
    }
    // Acknowledge start event.
    StartEventAckMessage startAck = StartEventAckMessage.newBuilder()
      .setGameId(gameId)
      .build();
    msg = PokerTHMessage.newBuilder()
      .setMessageType(PokerTHMessageType.Type_StartEventAckMessage)
      .setStartEventAckMessage(startAck)
      .build();
    sendMessage(msg);
    for (int i = 0; i < 9; i++) {
      sendMessage(msg, s[i]);
    }

    // Game list update (game now running).
    msg = receiveMessage(spectatorSock);
    if (!msg.hasGameListUpdateMessage()) {
      failOnErrorMessage(msg);
      fail("Invalid message: " + msg.getMessageType());
    }

    msg = receiveMessage(spectatorSock);
    if (!msg.hasGameStartInitialMessage()) {
      failOnErrorMessage(msg);
      fail("Invalid message: " + msg.getMessageType());
    }

    // Spectator should receive a hand start message without cards.
    msg = receiveMessage(spectatorSock);
    if (!msg.hasHandStartMessage()) {
      failOnErrorMessage(msg);
      fail("Invalid message: " + msg.getMessageType());
    }
    assertFalse(msg.getHandStartMessage().hasEncryptedCards());
    assertFalse(msg.getHandStartMessage().hasPlainCards());
    assertEquals(gameId, msg.getHandStartMessage().getGameId());

    for (int i = 0; i < 9; i++) {
      s[i].close();
    }
    spectatorSock.close();
View Full Code Here

    return guestInit(sock);
  }

  public int guestInit(Socket s) throws Exception {
    int playerId = 0;
    PokerTHMessage msg = receiveMessage(s);
    assertTrue(msg.hasAnnounceMessage());

    AnnounceMessage.Version requestedVersion = AnnounceMessage.Version.newBuilder()
      .setMajorVersion(PROTOCOL_VERSION_MAJOR)
      .setMinorVersion(PROTOCOL_VERSION_MINOR)
      .build();
    InitMessage init = InitMessage.newBuilder()
      .setBuildId(0)
      .setLogin(InitMessage.LoginType.guestLogin)
      .setRequestedVersion(requestedVersion)
      .setNickName(GuestUser)
      .build();
    msg = PokerTHMessage.newBuilder()
      .setMessageType(PokerTHMessageType.Type_InitMessage)
      .setInitMessage(init)
      .build();
    sendMessage(msg, s);

    msg = receiveMessage(s);
    if (msg.hasInitAckMessage() && msg.getMessageType() == PokerTHMessageType.Type_InitAckMessage) {
      InitAckMessage initAck = msg.getInitAckMessage();
      assertTrue(initAck.getYourPlayerId() != 0L);
      assertTrue(!initAck.hasYourAvatarHash());
      playerId = initAck.getYourPlayerId();
    }
    else {
View Full Code Here

    public byte[] value;
  }

  public int userInit(Socket s, String user, String password, byte[] avatarData, Guid lastSessionId) throws Exception {
    int playerId = 0;
    PokerTHMessage msg = receiveMessage(s);
    AnnounceMessage announce = msg.getAnnounceMessage();
    assertTrue(announce.getServerType() == ServerType.serverTypeInternetAuth);

    ScramSha1 scramAuth = new ScramSha1();

    // Send challenge.
    AnnounceMessage.Version requestedVersion = AnnounceMessage.Version.newBuilder()
        .setMajorVersion(PROTOCOL_VERSION_MAJOR)
        .setMinorVersion(PROTOCOL_VERSION_MINOR)
        .build();
    InitMessage.Builder initBuilder = InitMessage.newBuilder();
    initBuilder
        .setBuildId(0)
        .setLogin(InitMessage.LoginType.authenticatedLogin)
        .setRequestedVersion(requestedVersion)
        .setClientUserData(ByteString.copyFromUtf8(scramAuth.executeStep1(user)));
    if (avatarData != null) {
      initBuilder.setAvatarHash(ByteString.copyFrom(avatarData));
    }
    if (lastSessionId != null && lastSessionId.value != null) {
      initBuilder.setMyLastSessionId(ByteString.copyFrom(lastSessionId.value));
    }
    InitMessage init = initBuilder.build();
    msg = PokerTHMessage.newBuilder()
        .setMessageType(PokerTHMessageType.Type_InitMessage)
        .setInitMessage(init)
        .build();
    sendMessage(msg, s);

    msg = receiveMessage(s);

    if (msg.hasAuthServerChallengeMessage() && msg.getMessageType() == PokerTHMessageType.Type_AuthServerChallengeMessage)
    {
      String serverFirstMessage = new String(msg.getAuthServerChallengeMessage().getServerChallenge().toStringUtf8());
      AuthClientResponseMessage authClient = AuthClientResponseMessage.newBuilder()
        .setClientResponse(ByteString.copyFromUtf8(scramAuth.executeStep2(password, serverFirstMessage)))
        .build();

      msg = PokerTHMessage.newBuilder()
          .setMessageType(PokerTHMessageType.Type_AuthClientResponseMessage)
          .setAuthClientResponseMessage(authClient)
          .build();
      sendMessage(msg, s);
    }
    failOnErrorMessage(msg);

    msg = receiveMessage(s);
    failOnErrorMessage(msg);

    msg = receiveMessage(s);
    if (msg.hasInitAckMessage() && msg.getMessageType() == PokerTHMessageType.Type_InitAckMessage) {
      InitAckMessage initAck = msg.getInitAckMessage();
      assertTrue(initAck.getYourPlayerId() != 0L);
      assertTrue(!initAck.hasYourAvatarHash());
      playerId = initAck.getYourPlayerId();
      if (lastSessionId != null) {
        lastSessionId.value = initAck.getYourSessionId().toByteArray();
View Full Code Here

    if (!password.isEmpty()) {
      joinBuilder.setPassword(password);
    }
    JoinNewGameMessage joinNew = joinBuilder.build();

    PokerTHMessage msg = PokerTHMessage.newBuilder()
      .setMessageType(PokerTHMessageType.Type_JoinNewGameMessage)
      .setJoinNewGameMessage(joinNew)
      .build();
    return msg;
  }
View Full Code Here

    if (!password.isEmpty()) {
      joinBuilder.setPassword(password);
    }
    JoinExistingGameMessage joinExisting = joinBuilder.build();

    PokerTHMessage msg = PokerTHMessage.newBuilder()
        .setMessageType(PokerTHMessageType.Type_JoinExistingGameMessage)
        .setJoinExistingGameMessage(joinExisting)
        .build();
    return msg;
  }
View Full Code Here

    RejoinExistingGameMessage rejoinRequest = RejoinExistingGameMessage.newBuilder()
      .setGameId(gameId)
      .setAutoLeave(autoLeave)
      .build();

    PokerTHMessage msg = PokerTHMessage.newBuilder()
        .setMessageType(PokerTHMessageType.Type_RejoinExistingGameMessage)
        .setRejoinExistingGameMessage(rejoinRequest)
        .build();
    return msg;
  }
View Full Code Here

    long countBefore = countBeforeResult.getLong(1);

    int firstPlayerId = userInit();

    // Waiting for player list update.
    PokerTHMessage msg;
    msg = receiveMessage();
    if (!msg.hasPlayerListMessage()) {
      failOnErrorMessage(msg);
      fail("Invalid message.");
    }

    Collection<Integer> l = new ArrayList<Integer>();
    String gameName = AuthUser + " run ranking game";
    NetGameInfo gameInfo = createGameInfo(NetGameType.rankingGame, 5, 7, 5, EndRaiseMode.doubleBlinds, 0, 50, gameName, l, 10, 0, 11, 10000);
    sendMessage(createGameRequestMsg(
        gameInfo,
        "",
        false));

    // Game list update (new game)
    msg = receiveMessage();
    if (!msg.hasGameListNewMessage()) {
      failOnErrorMessage(msg);
      fail("Invalid message.");
    }

    // Join game ack.
    msg = receiveMessage();
    if (!msg.hasJoinGameAckMessage()) {
      fail("Could not create game!");
    }
    int gameId = msg.getJoinGameAckMessage().getGameId();

    // Game list update (player joined).
    msg = receiveMessage();
    if (!msg.hasGameListPlayerJoinedMessage()) {
      failOnErrorMessage(msg);
      fail("Invalid message.");
    }

    // Let 9 additional clients join.
    Socket s[] = new Socket[9];
    long playerId[] = new long[9];
    for (int i = 0; i < 9; i++) {
      s[i] = new Socket("localhost", 7234);
      String username = "test" + (i+1);
      String password = username;
      playerId[i] = userInit(s[i], username, password);
      // Waiting for player list update.
      do {
        msg = receiveMessage(s[i]);
      } while (msg.hasGameListNewMessage() || msg.hasGamePlayerJoinedMessage());
      if (!msg.hasPlayerListMessage()) {
        failOnErrorMessage(msg);
        fail("Invalid message.");
      }
      sendMessage(joinGameRequestMsg(gameId, "", false), s[i]);
      do {
        msg = receiveMessage(s[i]);
        failOnErrorMessage(msg);
      } while (!msg.hasJoinGameAckMessage() && !msg.hasJoinGameFailedMessage());
      if (!msg.hasJoinGameAckMessage()) {
        fail("User " + username + " could not join ranking game.");
      }

      // The player should have joined the game.
      msg = receiveMessage();
      if (!msg.hasPlayerListMessage()) {
        failOnErrorMessage(msg);
        fail("Invalid message.");
      }
      msg = receiveMessage();
      if (!msg.hasGamePlayerJoinedMessage()) {
        failOnErrorMessage(msg);
        fail("Invalid message.");
      }
      msg = receiveMessage();
      if (!msg.hasGameListPlayerJoinedMessage()) {
        failOnErrorMessage(msg);
        fail("Invalid message.");
      }
    }

    // Server should automatically send start event.
    msg = receiveMessage();
    if (!msg.hasStartEventMessage()) {
      failOnErrorMessage(msg);
      fail("Invalid message.");
    }
    for (int i = 0; i < 9; i++) {
      do {
        msg = receiveMessage(s[i]);
        failOnErrorMessage(msg);
      } while (!msg.hasStartEventMessage());
    }
    // Acknowledge start event.
    StartEventAckMessage startAck = StartEventAckMessage.newBuilder()
      .setGameId(gameId)
      .build();
    msg = PokerTHMessage.newBuilder()
      .setMessageType(PokerTHMessageType.Type_StartEventAckMessage)
      .setStartEventAckMessage(startAck)
      .build();
    sendMessage(msg);
    for (int i = 0; i < 9; i++) {
      sendMessage(msg, s[i]);
    }

    // Game list update (game now running).
    msg = receiveMessage();
    if (!msg.hasGameListUpdateMessage()) {
      failOnErrorMessage(msg);
      fail("Invalid message.");
    }

    msg = receiveMessage();
    if (!msg.hasGameStartInitialMessage()) {
      failOnErrorMessage(msg);
      fail("Invalid message.");
    }

    int handNum = 0;
    int lastPlayerMoney = 0;
    do {
      msg = receiveMessage();
      failOnErrorMessage(msg);
      if (msg.hasHandStartMessage()) {
        handNum++;
        // Cards should be encrypted for registered users.
        assertTrue(msg.getHandStartMessage().hasEncryptedCards());
        byte[] encData = msg.getHandStartMessage().getEncryptedCards().toByteArray();
        byte[] cardData = decryptCards(AuthPassword, encData);
        int size = cardData.length;
        while (size > 0 && cardData[size-1] == 0) {
          size--;
        }
        String cardStr = new String(cardData, 0, size);
        String[] cardTok = cardStr.split("\\s");
        // First token is player id.
        assertEquals(String.valueOf(firstPlayerId), cardTok[0]);
        // Second token is game id.
        assertEquals(String.valueOf(gameId), cardTok[1]);
        // Third token is hand num.
        assertEquals(String.valueOf(handNum), cardTok[2]);
        // Fourth and fifth tokens are cards.
        int card1 = Integer.valueOf(cardTok[3]);
        int card2 = Integer.valueOf(cardTok[4]);
        assertTrue(card1 < 52);
        assertTrue(card1 >= 0);
        assertTrue(card2 < 52);
        assertTrue(card2 >= 0);
      }
      else if (msg.hasPlayersTurnMessage()) {
        if (msg.getPlayersTurnMessage().getPlayerId() == firstPlayerId) {
          MyActionRequestMessage myRequest = MyActionRequestMessage.newBuilder()
            .setGameId(gameId)
            .setGameState(msg.getPlayersTurnMessage().getGameState())
            .setHandNum(handNum)
            .setMyAction(NetPlayerAction.netActionAllIn)
            .setMyRelativeBet(0)
            .build();
          PokerTHMessage outMsg = PokerTHMessage.newBuilder()
            .setMessageType(PokerTHMessageType.Type_MyActionRequestMessage)
            .setMyActionRequestMessage(myRequest)
            .build();
          sendMessage(outMsg);
        }
      }
      for (int i = 0; i < 9; i++) {
        while (s[i].getInputStream().available() > 0) {
          PokerTHMessage inMsg = receiveMessage(s[i]);
          failOnErrorMessage(inMsg);
          if (inMsg.hasPlayersTurnMessage()) {
            if (inMsg.getPlayersTurnMessage().getPlayerId() == playerId[i]) {

              MyActionRequestMessage myRequest = MyActionRequestMessage.newBuilder()
                .setGameId(gameId)
                .setGameState(inMsg.getPlayersTurnMessage().getGameState())
                .setHandNum(handNum)
                .setMyAction(NetPlayerAction.netActionFold)
                .setMyRelativeBet(0)
                .build();
              PokerTHMessage outMsg = PokerTHMessage.newBuilder()
                .setMessageType(PokerTHMessageType.Type_MyActionRequestMessage)
                .setMyActionRequestMessage(myRequest)
                .build();
              sendMessage(outMsg, s[i]);
            }
View Full Code Here

TOP

Related Classes of de.pokerth.protocol.ProtoBuf.PokerTHMessage

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.