Send and Receive Party Invites #

Using party invites, players can directly invite other players to join their party.This topic provides instructions on how to send, receive, and cancel party invites.

Send a party invite #

Invite a player to an existing party

Send an invite

Party invites are not sent until the Party interface’s sendInvite() method is called. This method can be invoked in the following ways:

  • from the player client Party API SendPartyInvite() method and the Party Plugin handlePlayerSendInviteRequest() method
  • directly from any Party Plugin method

To facilitate sending an invitation through the Party API for Unreal and Unity, use PartyApi.SendPartyInvite():

Player->PartyApi().SendPartyInvite(
  const FString& PlayerId,
  const FOnInviteSentDelegate& OnComplete
);
player.PartyApi.SendPartyInvite(
  PragmaId inviteePlayerId,
  CompleteDelegate onComplete
);
{
  "requestId": 2,
  "type": "PartyRpc.SendInviteV1Request",
  "payload": {
    "inviteePlayerId": "f9525239-cd99-425d-9f14-1ff948c02553"
  }
}

PartyApi.SendPartyInvite() calls the Party Plugin’s handlePlayerSendInviteRequest() method, which you can customize to allow/disallow a player to send a party invite. By default, handlePlayerSendInviteRequest() calls Party.Party.sendInvite():

suspend fun handlePlayerSendInviteRequest(
 party: Party.Party,
 requestingPlayer: Party.PartyPlayer,
 inviteePlayerId: PlayerId
) {
    party.sendInvite(requestingPlayer.playerId, inviteePlayerId)
}

The player who receives the invite can handle the OnPartyInviteReceived and OnReceivedPartyInvitesChanged events.

If a player sends a party invite to another player who already has an unanswered invite from the first player, the original invite is revoked and replaced with the new invite. On the platform side, the revoking process is the same as the invite cancellation process (see Cancel party invite).

Cancel a party invite #

Revoke a sent invite

Players can cancel a sent party invite provided the invite has not yet been accepted or rejected.

Cancel a sent party invite

Party invites are not canceled until the Party interface’s cancelInvite() method is called. This method can be invoked in the following ways:

  • from the player client SDK PartyApi.CancelPartyInvite() method and the Party Plugin handlePlayerCancelInviteRequest() method
  • directly from any Party Plugin method

To facilitate cancelling an invitation through the Party API for Unreal and Unity, use PartyApi.CancelPartyInvite():

Player->PartyApi().CancelPartyInvite(
  const FString& InviteId, 
  const FOnCompleteDelegate& OnComplete
);
player.PartyApi.CancelPartyInvite(
  PragmaId inviteId,
  CompleteDelegate onComplete
);

PartyApi.CancelPartyInvite() calls the Party Plugin’s handlePlayerCancelInviteRequest() method, which you can customize to allow/disallow a player to cancel a party invite. By default, handlePlayerCancelInviteRequest() calls Party.Party.cancelInvite() with the invite ID if the requesting player is the inviter or the party leader:

suspend fun handlePlayerCancelInviteRequest(
    party: Party.Party,
    requestingPlayer: Party.PartyPlayer,
    invite: Party.PartyInvite
) {
    if (invite.inviter.playerId != requestingPlayer.playerId || !requestingPlayer.isLeader) {
        partyApplicationError(
            PragmaError.PartyService_CancelInviteFailed,
            "Player '${requestingPlayer.playerId}' cannot cancel invite '${invite.id}'. A party invite can only be canceled by the inviter or a leader of the party.")
    }

    party.cancelInvite(invite.id)
}

The player who originally received the invite gets an OnReceivedPartyInviteCancelled and OnReceivedPartyInvitesChanged events. All players in the party get the OnPartyInviteCancelled event.

Accept a party invite #

Accept a pending party invite to join a party

The Party API’s AcceptInvite() method allows players to accept a received party invite.

This request contains the following information:

  • InviteID: ID of the party invite to accept
  • ExtPlayerJoinRequest: Use this payload to specify custom player data, such as a selected champion, to pass to the onAddPlayer() plugin method when a player is added to a party
  • gameServerZoneToPing: (optional) a ping map. You can change this value later (see SetPartyPlayerGameServerZoneToPing).
Player->PartyApi().AcceptPartyInvite(
  const FString& InviteId,
  const FPragma_Party_ExtPlayerJoinRequest& ExtPlayerJoinRequest,
  const TMap<FString, int>& GameServerZoneToPing,
  const FOnCompleteDelegate& FOnCompleteDelegate
);
player.PartyApi.AcceptPartyInvite(
  PragmaId inviteId,
  ExtPlayerJoinRequest extPlayerJoinRequest,
  Dictionary<string, int> gameServerZoneToPing,
  CompleteDelegate onComplete
);

When a player accepts a party invite via AcceptPartyInvite(), the Party service adds the player to the party and invokes the Party Plugin onAddPlayer() method. See handle added players.

All players in the party are notified with the OnPartyInviteAccepted event.

Decline a party invite #

Decline a pending party invite and do not join the party

The Party API’s DeclineInvite() method allows players to decline a received party invite, identified by invite ID.

Player->PartyApi().DeclinePartyInvite(
  const FString& InviteId,
  const FOnCompleteDelegate& FOnCompleteDelegate
);
player.PartyApi.DeclinePartyInvite(
  PragmaId inviteId,
  CompleteDelegate onComplete
);

When a player declines a party invite, all players in the party are notified with the OnPartyInviteDeclined event.

Related events:

Related errors:

  • PartyService_SendInviteFailed
  • PartyService_CancelInviteFailed