Skip to main content

Party

Last updated on

Overview

AccelByte Cloud's Lobby service includes Party features to enable multiplayer play. All Party features use WebSocket to ensure smooth communication between players. Players can interact with parties in several ways, including:

  • User Party Info shows players information about their party, including the Party ID, Leader ID, and the list of Party Members.
  • Create Party allows players to create a new party that other players can join.
  • Invite to Party allows players to invite their friends to join their party. Both the inviter and invitee will receive a notification when the invitation is sent.
  • Join Party allows players to join a party that they've been invited to join. When the player joins the party the inviter and other party members will be notified.
  • Reject Party Invitation allows players to reject a party invitation. The inviter will be notified that their invitation was rejected.
  • Promote a Member to Party Leader allows players to set another player as the party leader.
  • Kick Party allows party leaders to remove another player from their party.
  • Leave Party allows players to leave a party that they have already joined. The other party members will be notified when a player leaves their party.

Permissions

Permissions are used to grant access to specific resources within our services. Make sure your account has the following permissions before you attempt to manage a party in the Admin Portal.

UsageResourceAction
Admin Get All PartiesADMIN:NAMESPACE:{namespace}:PARTY:STORAGERead
Admin Get Party DataADMIN:NAMESPACE:{namespace}:PARTY:STORAGERead
Update Party AttributesADMIN:NAMESPACE:{namespace}:PARTY:STORAGEUpdate
Admin Get User Party DataADMIN:NAMESPACE:{namespace}:PARTY:STORAGERead

Permissions work slightly differently depending on whether they are assigned to IAM Clients or Roles assigned to users. For more information, read the Authentication and Authorization documentation.

Implement Party Interactions using the Client SDKs

Create a Party

Players can create a party that can be used for matchmaking. A player can only create one party at a time and will become the leader of the party they create.

FRegistry::Lobby.SetCreatePartyResponseDelegate(Lobby::FPartyCreateResponse::CreateLambda([](FAccelByteModelsCreatePartyResponse result)
{
UE_LOG(LogAccelByteLobbyTest, Log, TEXT("Create Party Success!"));
if (result.PartyId.IsEmpty())
{
UE_LOG(LogAccelByteLobbyTest, Log, TEXT("Create Party Error!"));
}
}));
FRegistry::Lobby.Connect();
FRegistry::Lobby.SendCreatePartyRequest();

Invite to a Party

Players can invite other players to their party, as long as the invited player is not already in a party. Party invitees will receive a notification that they have been invited to join a party and current party members will also receive a notification that someone has been invited to the party.

FRegistry::Lobby.SetInvitePartyResponseDelegate(Lobby::FPartyInviteResponse::CreateLambda([](FAccelByteModelsPartyInviteResponse result)
{
UE_LOG(LogAccelByteLobbyTest, Log, TEXT("Invite Party Success!"));
})
);
const FString InvitedPlayerId = “a1b2c3d4e5”;
FRegistry::Lobby.SendInviteToPartyRequest(InvitedPlayerId);

Party Codes

Party leaders can send party codes to players so that those players can join their party. Only party leaders can use party codes. They can also refresh or revoke a party code.

Generate or Refresh a Party Code

Use the following function to generate or refresh a party code.

FRegistry::Lobby.SetPartyGenerateCodeResponseDelegate(
Api::Lobby::FPartyGenerateCodeResponse::CreateLambda([](FAccelByteModelsPartyGenerateCodeResponse Response)
{
// Handle result.PartyCode here
}));

FRegistry::Lobby.SendPartyGenerateCodeRequest();

Get a Party Code

Once a code is generated, party leaders can get the code and share it from other players. This function allows party leaders to get the party code.

FRegistry::Lobby.SetPartyGetCodeResponseDelegate(
Api::Lobby::FAccelByteModelsPartyGetCodeResponse ::CreateLambda([](FAccelByteModelsPartyGetCodeResponse Response)
{
// Handle result.PartyCode here
}));
FRegistry::Lobby.SendPartyGetCodeRequest();
TIP

If the success response returns an empty party code, you need to call the GeneratePartyCode function to generate a new party code.

Revoke a Party Code

Party leaders can revoke a party code. If a party code is revoked, players will no longer be able to use it to join the party. This function allows party leaders to revoke the party code.

FRegistry::Lobby.SetPartyGetCodeResponseDelegate(
Api::Lobby::FAccelByteModelsPartyGetCodeResponse ::CreateLambda([](FAccelByteModelsPartyGetCodeResponse Response)
{
// Handle result.PartyCode here
}));
FRegistry::Lobby.SendPartyGetCodeRequest();

Join a Party with a Party Code

Players that have been sent a party code can use it to join a party. This function allows players to join a party using a party code.

FRegistry::Lobby.SetPartyJoinViaCodeResponseDelegate(
Api::Lobby::FPartyJoinViaCodeResponse::CreateLambda([](FPartyJoinViaCodeResponse Response)
{
// Handle result here
}));
FRegistry::Lobby.SendPartyJoinViaCodeRequest();

Join a Party

Players that are invited to a party can accept the invitation and join the party. Party invitees will receive a notification that they've joined the party and current party members will also receive a notification that someone is joining the party.

FRegistry::Lobby.SetPartyGetInvitedNotifDelegate(Lobby::FPartyGetInvitedNotif::CreateLambda([](FAccelByteModelsPartyGetInvitedNotice result)
{
UE_LOG(LogAccelByteLobbyTest, Log, TEXT("Get Party Invitation!"));
FRegistry::Lobby.SendAcceptInvitationRequest(*result.PartyId, *result.InvitationToken);
}));

FAccelByteModelsPartyJoinReponse joinPartyResponse;
FRegistry::Lobby.SetInvitePartyJoinResponseDelegate(Lobby::FPartyJoinResponse::CreateLambda([&joinPartyResponse](FAccelByteModelsPartyJoinReponse result)
{
UE_LOG(LogAccelByteLobbyTest, Log, TEXT("Join Party Success! Member : %d"), result.Members.Num());
joinPartyResponse = result;
if (result.Code != "0")
{
UE_LOG(LogAccelByteLobbyTest, Log, TEXT("Join Party Failed!"));
}
}));

Reject a Party Invitation

When a player has been invited to a party, they can choose to reject the invitation. Party invitees will receive a notification that they've rejected the invitation and current party members will also receive a notification that someone has rejected the party invitation.

FRegistry::Lobby.Connect();
FRegistry::Lobby.SetInvitePartyRejectResponseDelegate(AccelByte::Api::Lobby::FPartyRejectResponse::CreateLambda([](const FAccelByteModelsPartyRejectResponse& Result)
{
if (Result.Code == "0")
{
// Do something if InvitePartyRejectResponseDelegate has been successful
}
else
{
// Do something if InvitePartyRejectResponseDelegate has an error
}
}));

FString PartyId = FString("SomePartyId");
FString InvitationToken = FString("SomeInvitationToken");

FRegistry::Lobby.SendRejectInvitationRequest(PartyId, InvitationToken);

Promote a Member to Party Leader

The party leader can promote another party member to become the new party leader. All party members will be notified of the new party leader.

This is how the party leader can promote another party member to become a new party leader. The new party leader is identified by a specific user id from a party member.

FRegistry::Lobby.Connect();
FRegistry::Lobby.SetPartyPromoteLeaderResponseDelegate(AccelByte::Api::Lobby::FPartyPromoteLeaderResponse::CreateLambda([](const FAccelByteModelsPartyPromoteLeaderResponse& Result)
{
if (Result.Code == "0")
{
// Do something if PartyPromoteLeaderResponseDelegate has been successful
}
else
{
// Do something if PartyPromoteLeaderResponseDelegate has an error
}
}));

FString UserId = FString("SomeUserId");

FRegistry::Lobby.SendPartyPromoteLeaderRequest(UserId);

Kick a Player From a Party

The party leader has the privilege to remove a party member from their party by kicking them out of the party. The kicked party member will receive a notification that they've been kicked out of the party, and current party members will also receive a notification that someone has been kicked from the party.

FRegistry::Lobby.Connect();
FRegistry::Lobby.SetInvitePartyKickMemberResponseDelegate(AccelByte::Api::Lobby::FPartyKickResponse::CreateLambda([](const FAccelByteModelsKickPartyMemberResponse& Result)
{
if (Result.Code == "0")
{
// Do something if InvitePartyKickMemberResponseDelegate has been successful
}
else
{
// Do something if InvitePartyKickMemberResponseDelegate has an error
}
}));

FString UserId = FString("SomeUserId");

FRegistry::Lobby.SendKickPartyMemberRequest(UserId);

Leave a Party

Party members can choose to leave their party. If the party leader leaves the party, party leadership will be passed to another party member automatically. Party members that leave the party will receive a notification that they've left the party and current party members will also receive a notification that someone is leaving the party.

FRegistry::Lobby.Connect();
FRegistry::Lobby.SetLeavePartyResponseDelegate(AccelByte::Api::Lobby::FPartyLeaveResponse::CreateLambda([](const FAccelByteModelsLeavePartyResponse& Result)
{
if (Result.Code == "0")
{
// Do something if LeavePartyResponseDelegate has been successful
}
else
{
// Do something if LeavePartyResponseDelegate has an error
}
}));

FRegistry::Lobby.SendLeavePartyRequest();

Implement Party Notifications using the Client SDKs

Invite a Player

This is how the invited player will get notification after the other player requests an invite party to the player that will get the notification.

FRegistry::Lobby.Connect();
FRegistry::Lobby.SetPartyGetInvitedNotifDelegate(AccelByte::Api::Lobby::FPartyGetInvitedNotif::CreateLambda([](const FAccelByteModelsPartyGetInvitedNotice& Result)
{
// Do something if PartyGetInvitedNotifDelegate has been successful
}));

Join a Party

When someone joins the party, the player inside the party will get some notification that there are some new party members inside the party.

FRegistry::Lobby.Connect();
FRegistry::Lobby.SetPartyJoinNotifDelegate(AccelByte::Api::Lobby::FPartyJoinNotif::CreateLambda([](const FAccelByteModelsPartyJoinNotice& Result)
{
// Do something if PartyJoinNotifDelegate has been successful
}));

Reject a Party Notification

This is how the player party member and party leader will get notification after the invitation player rejects the invitation request.

FRegistry::Lobby.Connect();
FRegistry::Lobby.SetPartyInvitationRejectedNotifDelegate(AccelByte::Api::Lobby::FPartyRejectNotif::CreateLambda([](const FAccelByteModelsPartyRejectNotice& Result)
{
// Do something if PartyInvitationRejectedNotifDelegate has been successful
}));

Promote a Party Leader

When there is some update from the party info data like promoting a new party leader, all party members including party leader will get a notification and get new information about the party.

FRegistry::Lobby.Connect();
FRegistry::Lobby.SetPartyDataUpdateNotifDelegate(AccelByte::Api::Lobby::FPartyDataUpdateNotif::CreateLambda([](const FAccelByteModelsPartyDataNotif& Result)
{
// Do something if PartyDataUpdateNotifDelegate has been successful
}));

Kick a Party Member

Kick some party members will send a notification for all player members and party leaders that are still in the party.

FRegistry::Lobby.Connect();
FRegistry::Lobby.SetPartyKickNotifDelegate(AccelByte::Api::Lobby::FPartyKickNotif::CreateLambda([](const FAccelByteModelsGotKickedFromPartyNotice& Result)
{
// Do something if PartyKickNotifDelegate has been successful
}));

Leave a Party

For other players that are still at the party, they will get a notification after some players leave from the party. Call this delegate function to get a notification when some party member leaves the party.

FRegistry::Lobby.Connect();
FRegistry::Lobby.SetPartyLeaveNotifDelegate(AccelByte::Api::Lobby::FPartyLeaveNotif::CreateLambda([](const FAccelByteModelsLeavePartyNotice& Result)
{
// Do something if PartyLeaveNotifDelegate has been successful
}));

Implement Party Storage using the Client SDKs

Party Storage enables a party to store party attributes that can be passed from the game server to the game client. The game server will write the party's storage to ensure that all party members get the same information or notifications from the server.

Party Data Update Notifications

Use this function to notify players of any updates to party data. Party members will be notified if an event occurs in the party, such as when a player accepts a party invitation, joins the party, or leaves the party.

FRegistry::Lobby.Connect();
FRegistry::Lobby.SetPartyDataUpdateNotifDelegate(AccelByte::Api::Lobby::FPartyDataUpdateNotif::CreateLambda([](const FAccelByteModelsPartyDataNotif& Result)
{
// Do something if PartyDataUpdateNotifDelegate has been successful
}));

Retrieve Party Data (Client-Side)

Use this function to retrieve specific party data from the client side. Make sure you have players logged in to allow this API call.

FRegistry::Lobby.Connect();
FRegistry::Lobby.GetPartyStorage(PartyId, THandler<FAccelByteModelsPartyDataNotif>::CreateLambda([](const FAccelByteModelsPartyDataNotif& Result)
{
// Do something if GetPartyStoraget has been successful
}), FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if GetPartyStorage has an error
UE_LOG(LogTemp, Log, TEXT("Error GetPartyStorage, Error Code: %d Error Message: %s"), ErrorCode, *ErrorMessage);
}));

Retrieve Party Data (Server Side)

Use this function to retrieve specific party data from the server side. Make sure the game server is authenticated to allow this API call.

FString PartyId = FString("SomePartyId");

FRegistry::ServerLobby.GetPartyStorage(PartyId, THandler<FAccelByteModelsPartyDataNotif>::CreateLambda([](const FAccelByteModelsPartyDataNotif& Result)
{
// Do something if GetPartyStorage has been successful
}), FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if GetPartyStorage has an error
UE_LOG(LogTemp, Log, TEXT("Error GetPartyStorage, Error Code: %d Error Message: %s"), ErrorCode, *ErrorMessage);
}));

Write Party Data

Write Party Data is an exclusive feature for the game server. It's possible that multiple servers can write to the same party at the same time. To avoid this, our SDK has a timestamp in the backend to ensure that the latest write data will never be overwritten with older data.

This function you can modify from Previous Data that we called oldPartyData that you can get from the lambda or even you can input your own new Party Data.

FString PartyId = FString("SomePartyId");

FRegistry::ServerLobby.WritePartyStorage(PartyId, [](FJsonObjectWrapper OldPartyData)
{
// You can choose either to create new PartyDataStorage or modified from OldPartyDataStorage
/*FJsonObjectWrapper NewPartyData;
TSharedPtr<FJsonObject> MyNewJsonValue;
MyNewJsonValue->SetStringField(FString("MyNewFieldName"), FString("MyNewStringValue"));
NewPartyData.JsonObject->SetObjectField(FString("NewField"), MyNewJsonValue);
return NewPartyData;*/

FJsonObjectWrapper ModifiedPartyData = OldPartyData;
TSharedPtr<FJsonObject> MyNewJsonValue;
MyNewJsonValue->SetStringField(FString("MyNewFieldName"), FString("MyNewStringValue"));
ModifiedPartyData.JsonObject->SetObjectField(FString("NewField"), MyNewJsonValue);
return OldPartyData;
}, THandler<FAccelByteModelsPartyDataNotif>::CreateLambda([](const FAccelByteModelsPartyDataNotif& Result)
{
// Do something if WritePartyStorage has been successful
}), FErrorHandler::CreateLambda([](int32 ErrorCode, const FString ErrorMessage)
{
// Do something if WritePartyStorage has an error
UE_LOG(LogTemp, Log, TEXT("Error WritePartyStorage, Error Code: %d Error Message: %s"), ErrorCode, *ErrorMessage);
}));
  • For more information about the Party service, you can access this API Reference.
  • Learn about our Chat service, which lets party members interact with each other.
  • Check out our Matchmaking guide to see how parties can be matched to play against each other.
  • Players can form parties with their friends if you integrate our Friends service into your game.