Friends
Overview
AccelByte Cloud's Friends service allows players to connect socially with other players. This service uses WebSocket to ensure all players get real-time updates about their Friend List. Players can manage their friends in several different ways, including:
Request Friend allows players to add another player as a friend using that player's User ID. Players will be notified when they receive a friend request.
Accept Friend Request allows players to accept friend requests they've received. After the player accepts the request, the requester will be notified and the two players will be linked as friends.
Reject Friend Request allows players to deny a friend request from a player they don't want to be friends with.
Cancel Friend Request allows players to cancel and remove a pending friend request they have sent to another player, in case they have changed their mind or sent the request to the wrong player.
Get Friendship Status shows players their friendship status with another player. Possible statuses include:
Not Friend indicates that the players are not connected as friends.
Outgoing Friend indicates that the friend request sent by the player to another player is still pending.
Incoming Friend indicates that the player has received a friend request that is still pending.
Friend indicates that the two players are connected as friends.
List of Friends shows the player all of the players they're currently friends with.
List of Incoming Friends shows the player a list of players that have requested to be their friend. Players can accept or reject these requests.
List of Outgoing Friends shows players the list of pending friend requests they have sent to other players.
Unfriend allows players to stop being friends with other players. Unfriending a player will remove that player from their friend list. If the player wants to be friends with an unfriended player, they will have to send that player another friend request.
Bulk Synchronization of Third-party Platform Friends allows players to connect their friends from third-party platforms to the AccelByte Cloud platform.
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 friends in the Admin Portal.
Usage | Resource | Action |
---|---|---|
Add Friends Without Confirmation | NAMESPACE:{namespace}:USER:{userId}:FRIENDS | Create |
Get List of Friends | NAMESPACE:{namespace}:USER:{userId}:FRIENDS | Read |
Get Blocked Players by User ID | ADMIN:NAMESPACE:{namespace}:USER:{userId}:PLAYER:BLOCK | Read |
Get Players Who Blocked This Player by User ID | ADMIN:NAMESPACE:{namespace}:USER:{userId}:PLAYER:BLOCK | Read |
Configure a New 3rd Party Integration | ADMIN:NAMESPACE:{namespace}:THIRDPARTY:CONFIG | Create |
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.
Implement Friends using the Client SDKs
Search for a Player
You can search for a player's account information using their Display Name or Username as the query. You can configure the type of search by setting the enum of SearchType for Unity and EAccelByteSearchType for Unreal to DisplayName or Username.
- Unreal Engine
- Unity
FString Query = FString("UsersDisplayName");
EAccelByteSearchType By = EAccelByteSearchType::DISPLAYNAME;
FRegistry::User.SearchUsers(Query, By, THandler < FPagedPublicUsersInfo > ::CreateLambda([](const FPagedPublicUsersInfo & Result) {
// Do something if SearchUsers has been successful
}), FErrorHandler::CreateLambda([](int32 ErrorCode,
const FString & ErrorMessage) {
// Do something if SearchUsers has an error
UE_LOG(LogTemp, Log, TEXT("Error SearchUsers, Error Code: %d Error Message: %s"), ErrorCode, * ErrorMessage);
}));
string query = "UsersDisplayName";
SearchType by = SearchType.DISPLAYNAME;
AccelBytePlugin.GetUser().SearchUsers(query, by, result => {
if (result.IsError) {
// Do something if SearchUsers has an error
Debug.Log($"Error SearchUsers, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
} else {
// Do something if SearchUsers has been successful
}
});
Friend Interactions
These are all features for how players can manage their friends.
Retrieve a Player's Public Code
You can retrieve a player's public code using the PublicId parameter.
- Unreal Engine
- Unity
const FString & InUserIds = "userId1, userId2";
Api::UserProfile UserProfileApi(InCredentials, FRegistry::Settings, FRegistry::HttpRetryScheduler);
UserProfileApi.BatchGetPublicUserProfileInfos(InUserIds,
THandler < TArray < FAccelByteModelsPublicUserProfileInfo >> ::CreateLambda([ & ](const TArray < FAccelByteModelsPublicUserProfileInfo > & Result) {
UE_LOG(LogTemp, Log, TEXT("Public Id - User 1 = %s"), * Result[0].PublicId);
UE_LOG(LogTemp, Log, TEXT("Public Id - User 2 = %s"), * Result[1].PublicId);
}),
FErrorHandler::CreateLambda([ & ](int32 ErrorCode,
const FString & ErrorMessage) {
UE_LOG(LogTemp, Warning, TEXT("Error %d: %s"), ErrorCode, * ErrorMessage);
}));
public void GetUserProfilePublicInfoByPublicId(string publicId,
ResultCallback < PublicUserProfile > callback) {
Report.GetFunctionLog(GetType().Name);
if (!session.IsValid()) {
callback.TryError(ErrorCode.IsNotLoggedIn);
return;
}
coroutineRunner.Run(
api.GetUserProfilePublicInfoByPublicId(publicId, callback));
}
Retrieve the Friend List
Use the following function to retrieve a friends list.
- Unreal Engine
- Unity
FRegistry::Lobby.Connect();
FRegistry::Lobby.SetLoadFriendListResponseDelegate(AccelByte::Api::Lobby::FLoadFriendListResponse::CreateLambda([](const FAccelByteModelsLoadFriendListResponse & Result) {
// Do something if LoadFriendListResponseDelegate has been successful
}), FErrorHandler::CreateLambda([](int32 ErrorCode,
const FString & ErrorMessage) {
// Do something if LoadFriendListResponseDelegate has an error
UE_LOG(LogTemp, Log, TEXT("Error LoadFriendListResponseDelegate, Error Code: %d Error Message: %s"), ErrorCode, * ErrorMessage);
}));
FRegistry::Lobby.LoadFriendsList();
AccelBytePlugin.GetLobby().Connect();
AccelBytePlugin.GetLobby().LoadFriendsList(result => {
if (result.IsError) {
// Do something if LoadFriendsList has an error
Debug.Log($"Error LoadFriendsList, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
} else {
// Do something if LoadFriendsList has been successful
}
});
Send a Friend Request using a User ID
The first step in making a friend is sending a friend request to another player. Use this code to send a friend request using a User ID.
- Unreal Engine
- Unity
FRegistry::Lobby.Connect();
FRegistry::Lobby.SetRequestFriendsResponseDelegate(AccelByte::Api::Lobby::FRequestFriendsResponse::CreateLambda([](const FAccelByteModelsRequestFriendsResponse & Result) {
// Do something if RequestFriendsResponseDelegate has been successful
}), FErrorHandler::CreateLambda([](int32 ErrorCode,
const FString & ErrorMessage) {
// Do something if RequestFriendsResponseDelegate has an error
UE_LOG(LogTemp, Log, TEXT("Error RequestFriendsResponseDelegate, Error Code: %d Error Message: %s"), ErrorCode, * ErrorMessage);
}));
FString UserId = FString("SomeUserId");
FRegistry::Lobby.RequestFriend(UserId);
string userId = "SomeTargetFriendUserId";
AccelBytePlugin.GetLobby().Connect();
AccelBytePlugin.GetLobby().RequestFriend(userId, result => {
if (result.IsError) {
// Do something if RequestFriend has an error
Debug.Log($"Error RequestFriend, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
} else {
// Do something if RequestFriend has been successful
}
});
Send a Friend Request using a Public Code
The first step in making a friend is sending a friend request to another player. Use this code to send a friend request using a Public Code.
- Unreal Engine
- Unity
FApiClientPtr ApiClient = FMultiRegistry::GetApiClient();
const auto OnRequestFriendByPublicIdDone = Api::Lobby::FRequestFriendsResponse::CreateLambda([](const FAccelByteModelsRequestFriendsResponse& Result)
{
if(Result.Code == "0")
{
// do something when request success
}
else
{
// do something when request failed
}
});
ApiClient->Lobby.SetRequestFriendsByPublicIdResponseDelegate(OnRequestFriendByPublicIdDone);
ApiClient->Lobby.RequestFriendByPublicId(PublicId);
AccelBytePlugin.GetLobby().RequestFriendByPublicId(publicId, result =>
{
if (result.IsError)
{
// do something if operation failed
Debug.Log("Request friend error with message " + result.Error.Message);
}
else
{
// do something if request friend success
}
});
Retrieve a List of Incoming Friend Requests
Use this function to retrieve all the information about incoming friend requests. This function retrieves user ID which you can use to accept or reject each request.
- Unreal Engine
- Unity
FRegistry::Lobby.Connect();
FRegistry::Lobby.SetListIncomingFriendsResponseDelegate(AccelByte::Api::Lobby::FListIncomingFriendsResponse::CreateLambda([](const FAccelByteModelsListIncomingFriendsResponse& Result)
{
if (Result.Code == "0")
{
// Do something if ListIncomingFriendsResponseDelegate has been successful
}
else
{
// Do something if ListIncomingFriendsResponseDelegate has an error
}
}));
FRegistry::Lobby.ListIncomingFriends();
AccelBytePlugin.GetLobby().Connect();
AccelBytePlugin.GetLobby().ListIncomingFriends(result =>
{
if (result.IsError)
{
// Do something if ListIncomingFriends has an error
Debug.Log($"Error ListIncomingFriends, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
}
else
{
// Do something if ListIncomingFriends has been successful
}
});
Accept Incoming Friend Requests
After a friend request has been sent, the player who received the request can either accept or reject it. Use the following function to accept a friend request.
NOTE
To see a list of incoming friend requests, you can retrieve a list of incoming friend requests.
- Unreal Engine
- Unity
FRegistry::Lobby.Connect();
FRegistry::Lobby.SetAcceptFriendsResponseDelegate(AccelByte::Api::Lobby::FAcceptFriendsResponse::CreateLambda([](const FAccelByteModelsAcceptFriendsResponse& Result)
{
if (Result.Code == "0")
{
// Do something if AcceptFriendsResponseDelegate has been successful
}
else
{
// Do something if AcceptFriendsResponseDelegate has an error
}
}));
FString UserId = FString("SomeUserId");
FRegistry::Lobby.AcceptFriend(UserId);
string userId = "SomeTargetedAcceptedFriendUserId";
AccelBytePlugin.GetLobby().Connect();
AccelBytePlugin.GetLobby().AcceptFriend(userId, result =>
{
if (result.IsError)
{
// Do something if AcceptFriend has an error
Debug.Log($"Error AcceptFriend, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
}
else
{
// Do something if AcceptFriend has been successful
}
});
Reject Incoming Friend Requests
You can reject the incoming friend request by their User ID. To get the user ID, you need to retrieve a list of incoming friend requests, copy the User ID, and store it somewhere safe for use in the following function.
- Unreal Engine
- Unity
FRegistry::Lobby.Connect();
FRegistry::Lobby.SetRejectFriendsResponseDelegate(AccelByte::Api::Lobby::FRejectFriendsResponse::CreateLambda([](const FAccelByteModelsRejectFriendsResponse& Result)
{
if (Result.Code == "0")
{
// Do something if RejectFriendsResponseDelegate has been successful
}
else
{
// Do something if RejectFriendsResponseDelegate has an error
}
}));
FString UserId = FString("SomeTargetRejectFriendUserId");
FRegistry::Lobby.RejectFriend(UserId);
string userId = "SomeTargetRejectedFriendUserId";
AccelBytePlugin.GetLobby().Connect();
AccelBytePlugin.GetLobby().RejectFriend(userId, result =>
{
if (result.IsError)
{
// Do something if RejectFriend has an error
Debug.Log($"Error RejectFriend, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
}
else
{
// Do something if RejectFriend has been successful
}
});
Retrieve a List of Outgoing Friend Requests
Use the following function to retrieve a list of outgoing friend requests.
- Unreal Engine
- Unity
FRegistry::Lobby.Connect();
FRegistry::Lobby.SetListOutgoingFriendsResponseDelegate(AccelByte::Api::Lobby::FListOutgoingFriendsResponse::CreateLambda([](const FAccelByteModelsListOutgoingFriendsResponse& Result)
{
if (Result.Code == "0")
{
// Do something if ListOutgoingFriendsResponseDelegate has an error
}
else
{
// Do something if ListOutgoingFriendsResponseDelegate has been successful
}
}));
FRegistry::Lobby.ListOutgoingFriends();
AccelBytePlugin.GetLobby().Connect();
AccelBytePlugin.GetLobby().ListOutgoingFriends(result =>
{
if (result.IsError)
{
// Do something if ListOutgoingFriends has an error
Debug.Log($"Error ListOutgoingFriends, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
}
else
{
// Do something if ListOutgoingFriends has been successful
}
});
Cancel Outgoing Friend Requests
You can cancel outgoing friend requests using User ID. To get the user ID, you need to retrieve a list of outgoing friend requests, copy the User ID, and store it somewhere safe for the following function.
- Unreal Engine
- Unity
FRegistry::Lobby.Connect();
FRegistry::Lobby.SetCancelFriendsResponseDelegate(AccelByte::Api::Lobby::FCancelFriendsResponse::CreateLambda([](const FAccelByteModelsCancelFriendsResponse& Result)
{
if (Result.Code == "0")
{
// Do something if CancelFriendsResponseDelegate has been successful
}
else
{
// Do something if CancelFriendsResponseDelegate has an error
}
}));
FString UserId = FString("SomeTargetCancelFriendUserId");
FRegistry::Lobby.CancelFriendRequest(UserId);
string userId = "SomeTargetOutgoingFriendUserId";
AccelBytePlugin.GetLobby().Connect();
AccelBytePlugin.GetLobby().CancelFriendRequest(userId, result =>
{
if (result.IsError)
{
// Do something if CancelFriendRequest has an error
Debug.Log($"Error CancelFriendRequest, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
}
else
{
// Do something if CancelFriendRequest has been successful
}
});
Unfriend
Use the following function to unfriend another player.
- Unreal Engine
- Unity
FRegistry::Lobby.Connect();
FRegistry::Lobby.SetUnfriendResponseDelegate(AccelByte::Api::Lobby::FUnfriendResponse::CreateLambda([](const FAccelByteModelsUnfriendResponse& Result)
{
if (Result.Code == "0")
{
// Do something if UnfriendResponseDelegate has been successful
}
else
{
// Do something if UnfriendResponseDelegate has an error
}
}));
FString UserId = FString("SomeTargetFriendUserId");
FRegistry::Lobby.Unfriend(UserId);
string userId = "SomeTargetFriendUserId";
AccelBytePlugin.GetLobby().Connect();
AccelBytePlugin.GetLobby().Unfriend(userId, result =>
{
if (result.IsError)
{
// Do something if Unfriend has an error
Debug.Log($"Error Unfriend, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
}
else
{
// Do something if Unfriend has been successful
}
});
Friend Notifications
Incoming Friend Notifications
When a player sends a friend request to another player, the receiver will get an incoming friend request notification. You'll need to set up a delegate to enable this notification. Use the following function to implement the delegate for incoming friend request notifications.
- Unreal Engine
- Unity
FRegistry::Lobby.Connect();
FRegistry::Lobby.SetOnIncomingRequestFriendsNotifDelegate(AccelByte::Api::Lobby::FRequestFriendsNotif::CreateLambda([](const FAccelByteModelsRequestFriendsNotif& Result)
{
// Do something if OnIncomingRequestFriendsNotifDelegate has been successful
}));
AccelBytePlugin.GetLobby().Connect();
AccelBytePlugin.GetLobby().OnIncomingFriendRequest += result =>
{
if (result.IsError)
{
// Do something if OnIncomingFriendRequest has an error
Debug.Log($"Error OnIncomingFriendRequest, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
}
else
{
// Do something if OnIncomingFriendRequest has been successful
}
};
Accepted Friend Request Notification
Use the following function to set up a notification for when your friend accepts your friend request.
- Unreal Engine
- Unity
FRegistry::Lobby.Connect();
FRegistry::Lobby.SetOnFriendRequestAcceptedNotifDelegate(AccelByte::Api::Lobby::FAcceptFriendsNotif::CreateLambda([](const FAccelByteModelsAcceptFriendsNotif& Result)
{
// Do something if OnFriendRequestAcceptedNotifDelegate has been successful
}));
AccelBytePlugin.GetLobby().Connect();
AccelBytePlugin.GetLobby().FriendRequestAccepted += result =>
{
if (result.IsError)
{
// Do something if FriendRequestAccepted has an error
Debug.Log($"Error FriendRequestAccepted, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
}
else
{
// Do something if FriendRequestAccepted has been successful
}
};
Rejected Friend Request Notification
Use the following function to set up a notification for when a player rejects your friend request.
- Unreal Engine
- Unity
FRegistry::Lobby.Connect();
FRegistry::Lobby.SetOnRejectFriendsNotifDelegate(AccelByte::Api::Lobby::FRejectFriendsNotif::CreateLambda([](const FAccelByteModelsRejectFriendsNotif& Result)
{
// Do something if OnRejectFriendsNotifDelegate has been successful
}));
AccelBytePlugin.GetLobby().Connect();
AccelBytePlugin.GetLobby().FriendRequestRejected += result =>
{
if (result.IsError)
{
// Do something if FriendRequestRejected has an error
Debug.Log($"Error FriendRequestRejected, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
}
else
{
// Do something if FriendRequestRejected has been successful
}
};
Canceled Outgoing Friend Request Notification
Use the following function to set up a notification when another player cancels their friend request.
- Unreal Engine
- Unity
FRegistry::Lobby.Connect();
FRegistry::Lobby.SetOnCancelFriendsNotifDelegate(AccelByte::Api::Lobby::FCancelFriendsNotif::CreateLambda([](const FAccelByteModelsCancelFriendsNotif& Result)
{
// Do something if OnCancelFriendsNotifDelegate has been successful
}));
AccelBytePlugin.GetLobby().Connect();
AccelBytePlugin.GetLobby().FriendRequestCanceled += result =>
{
if (result.IsError)
{
// Do something if FriendRequestCanceled has an error
Debug.Log($"Error FriendRequestCanceled, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
}
else
{
// Do something if FriendRequestCanceled has been successful
}
};
Unfriend Notification
Use this function to set up a notification when a player unfriends another player.
- Unreal Engine
- Unity
FRegistry::Lobby.SetOnUnfriendNotifDelegate(AccelByte::Api::Lobby::FUnfriendNotif::CreateLambda([](const FAccelByteModelsUnfriendNotif& Result)
{
// Do something if OnUnfriendNotifDelegate has been successful
}));
AccelBytePlugin.GetLobby().Connect();
AccelBytePlugin.GetLobby().OnUnfriend += result =>
{
if (result.IsError)
{
// Do something if OnUnfriend has an error
Debug.Log($"Error OnUnfriend, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
}
else
{
// Do something if OnUnfriend has been successful
}
};
Block a Player
Blocking allows players to restrict other players from interacting with them. When one player blocks another, both players are prevented from:
- Adding the other as a friend. If the players are already friends, they will be unfriended.
- Sending or receiving messages to one another.
- Seeing each other's messages in global chat rooms.
- Inviting each other to parties.
- Meeting each other in matches.
- Being placed in the same party. (Unless they are both invited by a third player. When this occurs, the two blocked players will be able to interact with each other in the party chat.)
- Inviting each other to join groups.
- Seeing each other's player profiles in the group members lists.
Blocked players cannot see the profile of the blocking player, and blocked players receive no notification regarding the block. See the tutorials below to implement player blocking using the SDKs.
Block Player Request
Use the following function to block a player.
- Unreal Engine
- Unity
FRegistry::Lobby.Connect();
FRegistry::Lobby.SetBlockPlayerResponseDelegate(AccelByte::Api::Lobby::FBlockPlayerResponse::CreateLambda([](const FAccelByteModelsBlockPlayerResponse& Result)
{
if (Result.Code == "0")
{
// Do something if BlockPlayerResponseDelegate has been successful
}
else
{
// Do something if BlockPlayerResponseDelegate has an error
}
}));
FRegistry::Lobby.BlockPlayer(UserId);
string userId = "SomeUserId";
AccelBytePlugin.GetLobby().Connect();
AccelBytePlugin.GetLobby().BlockPlayer(userId, result =>
{
if (result.IsError)
{
// Do something if BlockPlayer has an error
Debug.Log($"Error BlockPlayer, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
}
else
{
// Do something if BlockPlayer has been successful
}
});
Listen to Player Blocking Events
The game needs to know if a player has been blocked by another player to avoid matching blocked players together and other similar tasks. Blocking events can be tracked by subscribing to the below event. The event will be raised on the blocked player side and will pass data that contains both the blocking player and blocked player's user IDs.
- Unreal Engine
- Unity
FRegistry::Lobby.Connect();
FRegistry::Lobby.SetBlockPlayerNotifDelegate(AccelByte::Api::Lobby::FBlockPlayerNotif::CreateLambda([](const FAccelByteModelsBlockPlayerNotif& Result)
{
// Do something if BlockPlayerNotifDelegate has been successful
}));
AccelBytePlugin.GetLobby().Connect();
AccelBytePlugin.GetLobby().PlayerBlockedNotif += result =>
{
if (result.IsError)
{
// Do something if PlayerBlockedNotif has an error
Debug.Log($"Error PlayerBlockedNotif, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
}
else
{
// Do something if PlayerBlockedNotif has been successful
}
};
Unblock a Player
Use the following function to unblock a player
- Unreal Engine
- Unity
FString UserId = FString("SomeUserId");
FRegistry::Lobby.Connect();
FRegistry::Lobby.SetUnblockPlayerResponseDelegate(AccelByte::Api::Lobby::FUnblockPlayerResponse::CreateLambda([](const FAccelByteModelsUnblockPlayerResponse& Result)
{
if (Result.Code == "0")
{
// Do something if UnblockPlayerResponseDelegate has been successful
}
else
{
// Do something if UnblockPlayerResponseDelegate has an error
}
}));
FRegistry::Lobby.UnblockPlayer(UserId);
string userId = "SomeUserId";
AccelBytePlugin.GetLobby().Connect();
AccelBytePlugin.GetLobby().UnblockPlayer(userid, result =>
{
if (result.IsError)
{
// Do something if UnblockPlayer has an error
Debug.Log($"Error UnblockPlayer, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
}
else
{
// Do something if UnblockPlayer has been successful
}
});
Listen to Player Unblocked Events
Just like the Player Blocked Event, this event will be raised on the unblock player's side and will pass data that contains both the unblocking player and unblocked player's User IDs.
- Unreal Engine
- Unity
FRegistry::Lobby.Connect();
FRegistry::Lobby.SetUnblockPlayerNotifDelegate(AccelByte::Api::Lobby::FUnblockPlayerNotif::CreateLambda([](const FAccelByteModelsUnblockPlayerNotif& Result)
{
// Do something if UnblockPlayerNotifDelegate has been successful
}));
AccelBytePlugin.GetLobby().Connect();
AccelBytePlugin.GetLobby().PlayerUnblockedNotif += result =>
{
if (result.IsError)
{
// Do something if PlayerUnblockedNotif has an error
Debug.Log($"Error PlayerUnblockedNotif, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
}
else
{
// Do something if PlayerUnblockedNotif has been successful
}
};
Retrieve List of Blocked Players
Use the following function to retrieve a list of currently blocked players. This method has a callback that returns an array of data containing the blocked players' User IDs.
- Unreal Engine
- Unity
FRegistry::Lobby.Connect();
FRegistry::Lobby.GetListOfBlockedUsers(THandler<FAccelByteModelsListBlockedUserResponse>::CreateLambda([](const FAccelByteModelsListBlockedUserResponse& Result)
{
// Do something if GetListOfBlockedUsers has been successful
}), FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if GetListOfBlockedUsers has an error
UE_LOG(LogTemp, Log, TEXT("Error GetListOfBlockedUsers, Error Code: %d Error Message: %s"), ErrorCode, *ErrorMessage);
}));
AccelBytePlugin.GetLobby().Connect();
AccelBytePlugin.GetLobby().GetListOfBlockedUser(result =>
{
if (result.IsError)
{
// Do something if GetListOfBlockedUser has an error
Debug.Log($"Error GetListOfBlockedUser, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
}
else
{
// Do something if GetListOfBlockedUser has been successful
}
});
Retrieve List of Blocked Players by User ID
Use the following function to retrieve a list of blocked players specific to a certain user, based on their User ID.
- Unreal Engine
FRegistry::Lobby.Connect();
FRegistry::Lobby.GetListOfBlockedUsers(UserId, THandler<FAccelByteModelsListBlockedUserResponse>::CreateLambda([](const FAccelByteModelsListBlockedUserResponse& Result)
{
// Do something if GetListOfBlockedUsers has been successful
}), FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if GetListOfBlockedUsers has an error
UE_LOG(LogTemp, Log, TEXT("Error GetListOfBlockedUsers, Error Code: %d Error Message: %s"), ErrorCode, *ErrorMessage);
}));
Retrieve List of Blocking Players
Use the following function to retrieve a list of players that have blocked the current player. This method has a callback that returns an array of data that contains the blocking player's User ID.
- Unreal Engine
- Unity
FRegistry::Lobby.Connect();
FRegistry::Lobby.GetListOfBlockers(THandler<FAccelByteModelsListBlockerResponse>::CreateLambda([](const FAccelByteModelsListBlockerResponse& Result)
{
// Do something if GetListOfBlockers has been successful
}), FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if GetListOfBlockers has an error
UE_LOG(LogTemp, Log, TEXT("Error GetListOfBlockers, Error Code: %d Error Message: %s"), ErrorCode, *ErrorMessage);
}));
AccelBytePlugin.GetLobby().Connect();
AccelBytePlugin.GetLobby().GetListOfBlocker(result =>
{
if (result.IsError)
{
// Do something if GetListOfBlocker has an error
Debug.Log($"Error GetListOfBlocker, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
}
else
{
// Do something if GetListOfBlocker has been successful
}
});
Retrieve List of Blocking Players by User ID
Use the following function to retrieve a list of players that have been blocked by a specific player, using that player's User ID.
- Unreal Engine
FString UserId = FString("SomeUserId");
FRegistry::Lobby.Connect();
FRegistry::Lobby.GetListOfBlockers(UserId, THandler<FAccelByteModelsListBlockerResponse>::CreateLambda([](const FAccelByteModelsListBlockerResponse& Result)
{
// Do something if GetListOfBlockers has been successful
}), FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if GetListOfBlockers has an error
UE_LOG(LogTemp, Log, TEXT("Error GetListOfBlockers, Error Code: %d Error Message: %s"), ErrorCode, *ErrorMessage);
}));
Bulk Synchronization of Third-party Platform Friends
This process is used to connect players' friends from third-party platforms to AccelByte Cloud's IAM service. This process works in the background and is triggered automatically every time your game starts, or manually by interaction between a player and the game client.
To allow your players to sync their third-party platform friends lists with their AccelByte Cloud friends list, you must call user.BulkGetUserByOtherPlatformUserIds() and lobby.BulkRequestFriend() consecutively.
- Unreal Engine
TArray<FString> ThirdPartyPlatformFriendId = {"12345abcd", "abcd12345"};
EAccelBytePlatformType PlatformType = EAccelBytePlatformType::Steam;
FRegistry::User.BulkGetUserByOtherPlatformUserIds(PlatformType, ThirdPartyPlatformFriendId, THandler<FBulkPlatformUserIdResponse>::CreateLambda([](const FBulkPlatformUserIdResponse& Result)
{
TArray<FString> UserIds;
for (auto UserData : Result.UserIdPlatforms)
{
UserIds.Add(UserData.UserId);
}
FAccelByteModelsBulkFriendsRequest BulkFriendsRequest;
BulkFriendsRequest.FriendIds = UserIds;
FRegistry::Lobby.BulkFriendRequest(BulkFriendsRequest, FVoidHandler::CreateLambda([]()
{
// Do something if BulkFriendRequest has been successful
}), FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if BulkFriendRequest has an error
UE_LOG(LogTemp, Log, TEXT("Error BulkFriendRequest, Error Code: %d Error Message: %s"), ErrorCode, *ErrorMessage);
}));
}), FErrorHandler::CreateLambda([](int32 ErrorCode, const FString ErrorMessage)
{
// Do something if BulkGetUserByOtherPlatformUserIds has an error
UE_LOG(LogTemp, Log, TEXT("Error BulkGetUserByOtherPlatformUserIds, Error Code: %d Error Message: %s"), ErrorCode, *ErrorMessage);
}));
Related Concepts
- See our Party and Presence documentation for more information about friend interactions.
- Read more about how to integrate player accounts with third-party platform accounts.