Package de.pokerth.protocol.ProtoBuf

Examples of de.pokerth.protocol.ProtoBuf.PlayerInfoReplyMessage


      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

TOP

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

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.