PokerTHMessage msg;
msg = receiveMessage();
assertTrue(msg.hasPlayerListMessage());
// This should be a "player list new" notification with correct player id.
PlayerListMessage listMsg = msg.getPlayerListMessage();
assertEquals(myId, listMsg.getPlayerId());
assertEquals(PlayerListNotification.playerListNew, listMsg.getPlayerListNotification());
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());
listMsg = msg.getPlayerListMessage();
// Id should be different from first id.
assertTrue(myId != playerId[i]);
// This should be a "player list new" notification with correct player id.
assertEquals(playerId[i], listMsg.getPlayerId());
assertEquals(PlayerListNotification.playerListNew, listMsg.getPlayerListNotification());
s[i].close();
// After the connection is closed, a "player list left" notification should be received.
msg = receiveMessage();
assertTrue(msg.hasPlayerListMessage());
listMsg = msg.getPlayerListMessage();
assertEquals(playerId[i], listMsg.getPlayerId());
assertEquals(PlayerListNotification.playerListLeft, listMsg.getPlayerListNotification());
}
}