Blocklist
1. Overview
The Blocklist service provides allows developers to manage player blocklists. No notification will be pushed to blocked player when they are added to or removed from the blocklist.
Each player can add any other player to the blocklist, which is used to restrict their interactive behaviors, such as chatting, friend requests, teaming up, and so on.
After completing this tutorial, developers will know:
- How to manage the in-game blocklist.
- Synchronize the blocklist of the account platform.
You can query a blocklist on the Web Portal as shown below.
2. Features
2.1 In-game Blocklist
Blocklist maintained by the game itself.
- Manage a Blocklist
- Query: Get the player's blocklist.
- Add: A player can add another player to their blocklist. The target player will not be informed.
- Remove: Remove the player from the player's blocklist.
2.2 Account Platform Blocklist
Blocklist maintained by platforms, such as XBox, PS5, Steam, etc. To make the platform blocklist effective in the game, developers need to synchronize the platform's blocklist to PGOS. Synchronization needs to be timely. It is recommended to synchronize the platform blocklist to PGOS as soon as the player successfully log in to PGOS. Of course, when changes are detected in the platform blocklist, game also need to be synchronized the latest blocklist as soon as possible.
❗ Note
Developers usually do not need to pay attention to the content of the platform blocklist. Only when the game needs to be released on a console platform, relevant interfaces will be used according to the compliance requirements of the console platform.
- Synchronize account platform blocklist: Fully synchronize the platform blocklist to PGOS.
- Synchronize added account platform blocklist: After full synchronization, any newly added data should also be synchronized to PGOS.
- Synchronize removed account platform blocklist: After full synchronization, any newly removed data should also be synchronized to PGOS.
- Synchronize account platform voice blocklist: Fully synchronize the platform voice blocklist to PGOS.
3. Using Blocklist Service(In-game)
3.1 Get Blocklist
Get the player's blocklist first.
Call GetBlocklist
from Blocklist module as follows:
- UE C++
- UE BP
#include "PgosSDKCpp.h"
#include "Core/PgosErrorCode.h"
void SomeUObjectClass::GetBlocklist()
{
auto blocklist = IPgosSDKCpp::Get().GetClientBlocklistAPI();
if (blocklist)
{
blocklist->GetBlocklist([](const FPgosResult& Ret, const FClientBlocklistInfo* Data) {
if (Ret.err_code == (int32)Pgos::PgosErrCode::kSuccess)
{
UE_LOG(LogTemp, Log, TEXT("OnGetBlocklistSuccess"));
}
else
{
UE_LOG(LogTemp, Log, TEXT("OnGetBlocklistFailed: err_code=%d, err_msg=%s"), Ret.err_code, *Ret.msg);
}
});
}
}
#include "PgosClientBlocklistAPI.h"
void SomeUObjectClass::GetBlocklist()
{
PGOS_CALL_ASYNC_API(UPgosClientAPIGetBlocklist::GetBlocklist,
this,
&SomeUObjectClass::OnGetBlocklistSuccess,
&SomeUObjectClass::OnGetBlocklistFailed);
}
void SomeUObjectClass::OnGetBlocklistSuccess(
FPgosResult Error, FClientBlocklistInfo ListInfo)
{
UE_LOG(LogTemp, Log, TEXT("OnGetBlocklistSuccess"));
}
void SomeUObjectClass::OnGetBlocklistFailed(
FPgosResult Error, FClientBlocklistInfo ListInfo)
{
UE_LOG(LogTemp, Error, TEXT("OnGetBlocklistFailed: err_code=%d, err_msg=%s"), Result.err_code, *Result.msg);
}
If successful, the player's blocklist will be returned.
If the result is "fail", check the error code and error message to see what happened.
❗ Note
If the game synchronizes the account platform blocklist, the returned result will include both the in-game blocklist and the account platform blocklist.
3.2 Add To the Blocklist
When you want to add another player to the player's blocklist, you need to get the player ID of target player and call the AddToBlocklist
function.
Call AddToBlocklist
from Blocklist module as follows:
- UE C++
- UE BP
#include "PgosSDKCpp.h"
#include "Core/PgosErrorCode.h"
void SomeUObjectClass::AddToBlocklist()
{
FString PlayerId = ObtainFromSomeWhere(); // The id for target player.
auto blocklist = IPgosSDKCpp::Get().GetClientBlocklistAPI();
if (blocklist)
{
blocklist->AddToBlocklist(PlayerId, [](const FPgosResult& Ret) {
if (Ret.err_code == (int32)Pgos::PgosErrCode::kSuccess)
{
UE_LOG(LogTemp, Log, TEXT("OnAddToBlocklistSuccess"));
}
else
{
UE_LOG(LogTemp, Log, TEXT("OnAddToBlocklistFailed: err_code=%d, err_msg=%s"), Ret.err_code, *Ret.msg);
}
});
}
}
#include "PgosClientBlocklistAPI.h"
void SomeUObjectClass::AddToBlocklist()
{
FString PlayerId = ObtainFromSomeWhere(); // The id for target player.
PGOS_CALL_ASYNC_API(UPgosClientAPIAddToBlocklist::AddToBlocklist,
this,
&SomeUObjectClass::OnAddToBlocklistSuccess,
&SomeUObjectClass::OnAddToBlocklistFailed,
PlayerId);
}
void SomeUObjectClass::OnAddToBlocklistSuccess(FPgosResult Error)
{
UE_LOG(LogTemp, Log, TEXT("OnAddToBlocklistSuccess"));
}
void SomeUObjectClass::OnAddToBlocklistFailed(FPgosResult Error)
{
UE_LOG(LogTemp, Error, TEXT("OnAddToBlocklistFailed: err_code=%d, err_msg=%s"), Result.err_code, *Result.msg);
}
If it is successful, the target player will appear in the player's blocklist.
3.3 Remove from the Blocklist
Remove a player from the blocklist using the RemoveFromBlocklist
function.
Call RemoveFromBlocklist
from Blocklist module as follows:
- UE C++
- UE BP
#include "PgosSDKCpp.h"
#include "Core/PgosErrorCode.h"
void SomeUObjectClass::RemoveFromBlocklist()
{
FString PlayerId = ObtainFromSomeWhere(); // The id for target player.
auto blocklist = IPgosSDKCpp::Get().GetClientBlocklistAPI();
if (blocklist)
{
blocklist->RemoveFromBlocklist(PlayerId, [](const FPgosResult& Ret) {
if (Ret.err_code == (int32)Pgos::PgosErrCode::kSuccess)
{
UE_LOG(LogTemp, Log, TEXT("OnRemoveFromBlocklistSuccess"));
}
else
{
UE_LOG(LogTemp, Log, TEXT("OnRemoveFromBlocklistFailed: err_code=%d, err_msg=%s"), Ret.err_code, *Ret.msg);
}
});
}
}
#include "PgosClientBlocklistAPI.h"
void SomeUObjectClass::RemoveFromBlocklist()
{
FString PlayerId = ObtainFromSomeWhere(); // The id for target player.
PGOS_CALL_ASYNC_API(UPgosClientAPIRemoveFromBlocklist::RemoveFromBlocklist,
this,
&SomeUObjectClass::OnRemoveFromBlocklistSuccess,
&SomeUObjectClass::OnRemoveFromBlocklistFailed,
PlayerId);
}
void SomeUObjectClass::OnRemoveFromBlocklistSuccess(FPgosResult Error)
{
UE_LOG(LogTemp, Log, TEXT("OnRemoveFromBlocklistSuccess"));
}
void SomeUObjectClass::OnRemoveFromBlocklistFailed(FPgosResult Error)
{
UE_LOG(LogTemp, Error, TEXT("OnRemoveFromBlocklistFailed: err_code=%d, err_msg=%s"), Result.err_code, *Result.msg);
}
If successful, the player will be removed from player's blocklist.
4. Using Blocklist Service(Account Platform)
The platform blocklist saves the user's account ID in the platform, and it is necessary to convert the account ID to the player ID used in PGOS by calling 'PgosClientFriendAPI::BatchAccountIDToPlayerID' interface.
4.1 Synchronize Account Platform Blocklist
Interface prototype:
/**
* Synchronize account platform blocklist to PGOS. The result returns the all blocklist
*
* @param PlayerIds The player ids to Synchronize.
*/
void SyncAPBlocklist(
const TArray<FString>& PlayerIds,
TFunction<void(const FPgosResult& Ret, const FClientSyncAccountPlatformBlocklistResult* Data)> Callback) const;
Example Code:
#include "PgosSDKCpp.h"
void SomeUObjectClass::SomeFunction()
{
auto Blocklist = IPgosSDKCpp::Get().GetClientBlocklistAPI();
if (Blocklist)
{
TArray<FString> PlayerIds;
Blocklist->SyncAPBlocklist(PlayerIds, [](const FPgosResult& Ret, const FClientSyncAccountPlatformBlocklistResult* Data) {
if (Ret.err_code == (int32)Pgos::PgosErrCode::kSuccess)
{
UE_LOG(LogTemp, Log, TEXT("SyncAPBlocklist Success"));
}
else
{
UE_LOG(LogTemp, Log, TEXT("SyncAPBlocklist Failed: err_code=%d, err_msg=%s"), Ret.err_code, *Ret.msg);
}
});
}
}
4.2 Synchronize Added Account Platform Blocklist
Interface prototype:
/**
* Synchronize added account platform blocklist to PGOS.
*
* @param PlayerId Added platform blocklist player to Synchronize.
*/
void SyncAPBlocklistAdded(
const FString& PlayerId,
TFunction<void(const FPgosResult& Ret)> Callback) const;
Example Code:
#include "PgosSDKCpp.h"
void SomeUObjectClass::SomeFunction()
{
auto Blocklist = IPgosSDKCpp::Get().GetClientBlocklistAPI();
if (Blocklist)
{
FString PlayerId;
Blocklist->SyncAPBlocklistAdded(PlayerId, [](const FPgosResult& Ret) {
if (Ret.err_code == (int32)Pgos::PgosErrCode::kSuccess)
{
UE_LOG(LogTemp, Log, TEXT("SyncAPBlocklistAdded Success"));
}
else
{
UE_LOG(LogTemp, Log, TEXT("SyncAPBlocklistAdded Failed: err_code=%d, err_msg=%s"), Ret.err_code, *Ret.msg);
}
});
}
}
4.3 Synchronize Removed Account Platform Blocklist
Interface prototype:
/**
* Synchronize removed account platform blocklist to PGOS.
*
* @param PlayerId Removed platform blocklist player to Synchronize.
*/
void SyncAPBlocklistRemoved(
const FString& PlayerId,
TFunction<void(const FPgosResult& Ret)> Callback) const;
Example Code:
#include "PgosSDKCpp.h"
void SomeUObjectClass::SomeFunction()
{
auto Blocklist = IPgosSDKCpp::Get().GetClientBlocklistAPI();
if (Blocklist)
{
FString PlayerId;
Blocklist->SyncAPBlocklistRemoved(PlayerId, [](const FPgosResult& Ret) {
if (Ret.err_code == (int32)Pgos::PgosErrCode::kSuccess)
{
UE_LOG(LogTemp, Log, TEXT("SyncAPBlocklistRemoved Success"));
}
else
{
UE_LOG(LogTemp, Log, TEXT("SyncAPBlocklistRemoved Failed: err_code=%d, err_msg=%s"), Ret.err_code, *Ret.msg);
}
});
}
}
4.4 Synchronize Account Platform Voice Blocklist
Interface prototype:
/**
* Synchronize account platform voice blocklist to PGOS. For platforms with voice blocklist such as XBOX
*
* @param PlayerIds The player ids to Synchronize.
*/
void SyncAPVoiceBlocklist(
const TArray<FString>& PlayerIds,
TFunction<void(const FPgosResult& Ret)> Callback) const;
Example Code:
#include "PgosSDKCpp.h"
void SomeUObjectClass::SomeFunction()
{
auto Blocklist = IPgosSDKCpp::Get().GetClientBlocklistAPI();
if (Blocklist)
{
TArray<FString> PlayerIds;
Blocklist->SyncAPVoiceBlocklist(PlayerIds, [](const FPgosResult& Ret) {
if (Ret.err_code == (int32)Pgos::PgosErrCode::kSuccess)
{
UE_LOG(LogTemp, Log, TEXT("SyncAPVoiceBlocklist Success"));
}
else
{
UE_LOG(LogTemp, Log, TEXT("SyncAPVoiceBlocklist Failed: err_code=%d, err_msg=%s"), Ret.err_code, *Ret.msg);
}
});
}
}