示例#1
0
  /** Called when we successfully obtain a connection to a client. */
  @Override
  public void onConnected(Bundle connectionHint) {
    debugLog("onConnected: connected!");

    if (connectionHint != null) {
      debugLog("onConnected: connection hint provided. Checking for invite.");
      Invitation inv = connectionHint.getParcelable(Multiplayer.EXTRA_INVITATION);
      if (inv != null && inv.getInvitationId() != null) {
        // retrieve and cache the invitation ID
        debugLog("onConnected: connection hint has a room invite!");
        mInvitation = inv;
        debugLog("Invitation ID: " + mInvitation.getInvitationId());
      }

      // Do we have any requests pending?
      mRequests = Games.Requests.getGameRequestsFromBundle(connectionHint);
      if (!mRequests.isEmpty()) {
        // We have requests in onConnected's connectionHint.
        debugLog("onConnected: connection hint has " + mRequests.size() + " request(s)");
      }

      debugLog("onConnected: connection hint provided. Checking for TBMP game.");
      mTurnBasedMatch = connectionHint.getParcelable(Multiplayer.EXTRA_TURN_BASED_MATCH);
    }

    // we're good to go
    succeedSignIn();
  }