Multiplayer
Parties
warning
Requires EOSCore 2.2.0 and later.
The Online Subsystem implements IOnlinePartySystem on top of EOS Lobbies. Use it to keep a group of friends together between matches, with invites, party data, presence and a voice room.
This is a C++ interface, get it with GetPartyInterface(). There are no Blueprint nodes for it. In Blueprint, use the EOSCore > Lobby functions, see Lobby.
Requirements
- The player is logged in to the EOSCore Online Subsystem with a Product User ID.
- Lobbies are enabled for your product, and the client policy allows the lobby actions.
- For invites through the EOS overlay and for presence, the player also needs an Epic Account login.
How parties use lobbies
- A party is a lobby in the bucket
EOSCoreParty:<PartyTypeId>. Session lobbies and party lobbies never show up in each other's searches. - One party per party type and local player. CreateParty fails with
AlreadyInPartyOfSpecifiedTypewhen the player is already in a party of that type. - MaxMembers of the party configuration is the lobby size,
4when it is not set, and at most the EOS lobby limit. - PresencePermissions set to
NooneorLeadermakes the lobby invite only. Other values allow joining through presence. - InvitePermissions set to
Nooneturns invites off. - The party configuration is stored in the lobby attribute
EOSCORE_PARTYCONFIG, so every member reads the same configuration.
Functions
| Area | Functions |
|---|---|
| Parties | CreateParty, JoinParty, LeaveParty, UpdateParty, GetJoinedParties, GetParty, CleanupParties |
| Members | GetPartyMembers, GetPartyMember, GetPartyMemberCount, IsMemberLeader, KickMember, PromoteMember |
| Invites | SendInvitation, RejectInvitation, ClearInvitations, GetPendingInvites, GetPendingInvitedUsers, RestoreInvites |
| Data | UpdatePartyData, UpdatePartyMemberData, GetPartyData, GetPartyMemberData |
| Join info | MakeJoinInfo, MakeJoinInfoJson, MakeJoinInfoFromJson, MakeTokenFromJoinInfo, MakeJoinInfoFromToken, QueryPartyJoinability |
- Invites are EOS lobby invites.
RestoreInvitesdownloads the pending invites withEOS_Lobby_QueryInvites. Accepting an invite or using Join in the EOS overlay joins the party, and leaves a party of the same type first. - Party data and member data are stored as lobby and lobby member attributes, one attribute per key, named
<Namespace>:<Key>. Only the party leader can callUpdatePartyData. Each member updates its own member data. - The member display name is stored in the member attribute
EOSCORE_DISPLAYNAME. - Join info works with the lobby id. A token from
MakeTokenFromJoinInfocan be sent to a friend another way, andMakeJoinInfoFromTokenturns it back into join info forJoinParty.
Delegates
| Delegate | Called when |
|---|---|
| OnPartyJoined, OnPartyExited | The local player joins or leaves a party |
| OnPartyStateChanged | The state of a party changes, for example while it is created or left |
| OnPartyMemberJoined, OnPartyMemberExited, OnPartyMemberPromoted | A member joins, leaves or becomes the leader |
| OnPartyConfigChanged | The party configuration changes |
| OnPartyDataReceived, OnPartyMemberDataReceived | Party data or member data changes |
| OnPartyInviteReceivedEx, OnPartyInviteRemovedEx, OnPartyInvitesChanged | An invite is received or removed |
Presence and voice
- With Enable Party Presence (on by default), the party lobby is created and joined with presence, so friends see the party in EOS presence. With the Steam Integrated Platform it is shown in Steam too. EOS allows only one lobby with presence: when another lobby already has presence, the party is created or joined without it.
- With Enable Party Voice Chat (on by default) and
bChatEnabledin the party configuration, the lobby gets an RTC voice room that joins automatically. The IVoiceChat interface adds it as a channel named after the lobby id. Enable RTC must be on in your EOS configuration.
See Project Settings.
Example
#include "OnlineSubsystem.h"
#include "OnlineSubsystemUtils.h"
#include "Interfaces/OnlinePartyInterface.h"
#include "Interfaces/OnlineIdentityInterface.h"
void AMyPlayerController::CreatePartyAndInvite(FUniqueNetIdRef FriendId)
{
IOnlineSubsystem* Subsystem = Online::GetSubsystem(GetWorld(), TEXT("EOSCore"));
IOnlinePartyPtr Party = Subsystem ? Subsystem->GetPartyInterface() : nullptr;
FUniqueNetIdPtr LocalUserId = Subsystem ? Subsystem->GetIdentityInterface()->GetUniquePlayerId(0) : nullptr;
if (!Party.IsValid() || !LocalUserId.IsValid())
{
return;
}
FPartyConfiguration Config;
Config.MaxMembers = 4;
Config.bChatEnabled = true;
Config.PresencePermissions = PartySystemPermissions::EPermissionType::Friends;
Config.InvitePermissions = PartySystemPermissions::EPermissionType::Anyone;
Party->CreateParty(*LocalUserId, IOnlinePartySystem::GetPrimaryPartyTypeId(), Config, FOnCreatePartyComplete::CreateLambda([Party, FriendId](const FUniqueNetId& LocalUserId, const TSharedPtr<const FOnlinePartyId>& PartyId, const ECreatePartyCompletionResult Result)
{
if (Result == ECreatePartyCompletionResult::Succeeded && PartyId.IsValid())
{
Party->SendInvitation(LocalUserId, *PartyId, FPartyInvitationRecipient(*FriendId));
}
}));
}
On the friend's side, bind OnPartyInviteReceivedEx and call JoinParty with the invite, or let the player accept the invite in the EOS overlay.
Not supported
EOS lobbies have no join requests and invites can't be cancelled. These functions do nothing, return an empty result or fail through their delegate:
- Join requests:
ApproveJoinRequest,GetPendingJoinRequestsandRespondToQueryJoinability. - Request to join:
RequestToJoinPartyfails,GetPendingRequestsToJoinreturns an empty list andClearRequestToJoinPartydoes nothing. - Join in progress (
JIPFromWithinParty,ApproveJIPRequest) on engine versions that still have it. CancelInvitation,GetAdvertisedPartyandConsumePendingCommandLineInvite.RestorePartiessucceeds without restoring anything.