false));
// Game list message is sent before join game ack.
msg = receiveMessage();
assertTrue(msg.hasGameListNewMessage());
GameListNewMessage gameListNewMsg = msg.getGameListNewMessage();
int gameId = gameListNewMsg.getGameId();
assertTrue(0 != gameListNewMsg.getGameId());
checkGameListNewMsg(
myId,
gameListNewMsg,
NetGameMode.netGameCreated,
gameInfo);
assertTrue(gameListNewMsg.getPlayerIdsCount() == 0);
// Next message is join game ack.
msg = receiveMessage();
assertTrue(msg.hasJoinGameAckMessage() && msg.getMessageType() == PokerTHMessageType.Type_JoinGameAckMessage);
// Make sure game list id equals join game ack id.
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]);