Package de.pokerth.protocol.ProtoBuf

Examples of de.pokerth.protocol.ProtoBuf.GameListPlayerJoinedMessage


    assertEquals(gameId, msg.getJoinGameAckMessage().getGameId());

    // Next message is game list player joined.
    msg = receiveMessage();
    assertTrue(msg.hasGameListPlayerJoinedMessage());
    GameListPlayerJoinedMessage gameListJoinedMsg = msg.getGameListPlayerJoinedMessage();
    assertEquals(gameId, gameListJoinedMsg.getGameId());
    assertEquals(myId, gameListJoinedMsg.getPlayerId());

    // Check game list for newly connected players.
    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);
      msg = receiveMessage();
      assertTrue(msg.hasPlayerListMessage());

      do {
        msg = receiveMessage(s[i]);
      } while (msg.hasPlayerListMessage());
      assertTrue(msg.hasGameListNewMessage());
      gameListNewMsg = msg.getGameListNewMessage();
      assertEquals(gameId, gameListNewMsg.getGameId());
      assertTrue(0 != gameListNewMsg.getGameId());
      checkGameListNewMsg(
          myId,
          gameListNewMsg,
          NetGameMode.netGameCreated,
          gameInfo);
      assertEquals(1, gameListNewMsg.getPlayerIdsCount());
      assertEquals(myId, gameListNewMsg.getPlayerIds(0));
    }

    // Let 9 players join the game.
    for (int i = 0; i < 9; i++) {
      sendMessage(joinGameRequestMsg(gameId, "", false), s[i]);
      do {
        msg = receiveMessage(s[i]);
      } while (msg.hasPlayerListMessage());
      for (int j = 0; j < i; j++) {
        assertTrue(msg.hasGameListPlayerJoinedMessage());
        gameListJoinedMsg = msg.getGameListPlayerJoinedMessage();
        assertEquals(gameId, gameListJoinedMsg.getGameId());
        assertEquals(playerId[j], gameListJoinedMsg.getPlayerId());
        msg = receiveMessage(s[i]);
      }
      failOnErrorMessage(msg);
      // Next message is join game ack.
      assertTrue(msg.hasJoinGameAckMessage());
      // Make sure game list id equals join game ack id.
      assertEquals(gameId, msg.getJoinGameAckMessage().getGameId());

      // Next message is game list player joined.
      do {
        msg = receiveMessage(s[i]);
      } while (msg.hasGamePlayerJoinedMessage());
      assertTrue(msg.hasGameListPlayerJoinedMessage());
      gameListJoinedMsg = msg.getGameListPlayerJoinedMessage();
      assertEquals(gameId, gameListJoinedMsg.getGameId());
      assertEquals(playerId[i], gameListJoinedMsg.getPlayerId());
    }

    // Wait for game list update which marks start of game.
    do {
      msg = receiveMessage();
View Full Code Here

TOP

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

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.