차단된 사용자에 대한 매치메이킹 #

Nakama의 매치 메이커를 사용하여 애플리케이션에서 사용 가능한 모든 유형의 소셜 게임 플레이나 상호작용에 대해서 사용자를 불러올 수 있습니다. 모든 공동체 생활이 그렇듯이, 서로 잘 어울리는 사용자와 그렇지 않은 사용자들이 있습니다.

사용자가 다른 사용자를 차단한 경우, 매치 메이커에 의해서 두 사용자가 같은 대결, 그룹 또는 다른 소셜 기능에 함께 참여하지 않는 것이 좋습니다.

이 가이드에서는 사용자가 차단한 사람과 대결이 성사되지 않도록 하는 방법에 대해서 설명합니다. 여기에는 다음이 포함됩니다:

  • 사용자별 차단한 사용자의 목록 찾기
  • 개별적인 매치 메이커 속성의 일부로 목록을 사용함
  • 매치 메이커 쿼리에 문항을 추가하여 차단된 사용자와 매칭을 방지함

차단된 사용자 목록 보기 #

차단된 상태의 사용자만 필터링하는 친구 목록 API를 사용하여 플레이어가 차단한 모든 사용자의 목록을 볼 수 있습니다.

Client
1
2
var blockedState = 3;
var blockedFriendsResult = await client.ListFriendsAsync(session, blockedState, 100, null);
Client
1
2
const blockedState = 3;
const blockedFriendsResult = await client.listFriends(session, null, blockedState);
Client
1
2
3
4
5
6
7
int blockedState = 3;
auto successCallback = [](NFriendsPtr blockedFriendsResult)
{
  // Blocked friends available as blockedFriendsResult->friends
};

client->listFriends(session, {}, blockedState, {}, successCallback);
Client
1
2
var blocked_state = 3
var blocked_friends_result : NakamaAPI.ApiFriendList = yield(client.list_friends_async(session, blocked_state), "completed")
Client
1
2
3
local limit = 100
local blocked_state = 3
local blocked_friends_result = client.list_friends(limit, blocked_state)

Code snippet for this language Java/Android has not been found. Please choose another language to show equivalent examples.
Code snippet for this language REST has not been found. Please choose another language to show equivalent examples.
Code snippet for this language cURL has not been found. Please choose another language to show equivalent examples.

사용자의 매치 메이커 속성의 일부인 공간으로 구분되는 문자열(예: user-id-1 user-id-2 user-id-3)에 차단된 사용자 ID의 전체 목록을 작성해야 합니다.

Client
1
var blockedFriendIds = string.Join(" ", blockedFriendsResult.Friends.Select(x => x.User.Id));
Client
1
const blockedFriendIds = blockedFriendsResult.friends.map(friend => friend.userId).join(' ');
Client
1
2
3
4
5
6
7
auto successCallback = [](NFriendListPtr blockedFriendsResult)
{
  string blockedFriendIds = "";
  for (NFriend friend : blockedFriendsResult->friends) {
    blockedFriendIdsString += friend.user.id + " ";
  }
};
Client
1
2
3
4
var blocked_friend_ids = ""

for friend in blocked_friends_result.friends:
  blocked_friend_ids += friend.user.id + " "
Client
1
2
3
4
local blocked_friend_ids = ""
for i,friend in ipairs(blocked_friends_result.friends) do
  blocked_friend_ids = blocked_friend_ids .. friend.user.id .. " "
end

Code snippet for this language Java/Android has not been found. Please choose another language to show equivalent examples.
Code snippet for this language REST has not been found. Please choose another language to show equivalent examples.
Code snippet for this language cURL has not been found. Please choose another language to show equivalent examples.

매치 메이커 기준 #

사용자의 매치 메이커 기준에는 위에서 생성된 차단된 사용자에 대한 문자열을 포함하여 blocked 키를 사용한 추가적인 속성이 포함됩니다.

Client
1
2
3
4
var stringProperties = new Dictionary<string, string>
{
    { "blocked", blockedFriendIds }
}; 
Client
1
2
3
const stringProperties = {
  "blocked": blockedFriendIds
};
Client
1
2
NStringMap stringProperties;
stringProperties.emplace("blocked", blockedFriendIds);
Client
1
var string_properties = { "blocked", blocked_friend_ids }
Client
1
local string_properties = { blocked = blocked_friend_ids }

Code snippet for this language Java/Android has not been found. Please choose another language to show equivalent examples.
Code snippet for this language REST has not been found. Please choose another language to show equivalent examples.
Code snippet for this language cURL has not been found. Please choose another language to show equivalent examples.

새로운 속성과 함께 사용자의 매치 메이커 쿼리에는 새로운 must not 항목이 -properties.blocked:/.my\-user\-id./의 형태로 존재합니다.

이 항목은 플레이어의 ID를 사용하여 어떤 대결에서도 차단된 목록의 플레이어가 검색되지 않도록 합니다. 즉, 플레이어는 본인을 차단한 다른 사용자와 함께 대결에 참여하지 않게 됩니다.

완전한 매치 메이커 요청은 다음과 같습니다.

Client
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
var blockedState = 3;
var blockedFriendsResult = await client.ListFriendsAsync(session, blockedState, 100, null);
var blockedFriendIds = string.Join(" ", blockedFriendsResult.Friends.Select(x => x.User.Id));]

var stringProperties = new Dictionary<string, string>
{
    { "blocked", blockedFriendIds }
};

var ticket =
    await socket.AddMatchmakerAsync($"-properties.blocked:/.{session.UserId}./", 2, 4, stringProperties, null);
Client
1
2
3
4
5
6
7
8
9
const blockedState = 3;
const blockedFriendsResult = await client.listFriends(session, null, blockedState);
const blockedFriendIds = blockedFriendsResult.friends.map(friend => friend.userId).join(' ');

const stringProperties = {
  "blocked": blockedFriendIds
};

const ticket = await socket.addMatchmaker(`-properties.blocked:/.${session.userId}./`, 2, 4, stringProperties, null);
Client
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
int blockedState = 3;
auto successCallback = [](NFriendsPtr blockedFriendsResult)
{
  string blockedFriendIds = "";
  for (NFriend friend : blockedFriendsResult->friends) {
    blockedFriendIdsString += friend.user.id + " ";
  }

  NStringMap stringProperties;
  NStringDoubleMap numericProperties;
  stringProperties.emplace("blocked", blockedFriendIds);

  string query = "-properties.blocked:/." + blockedFriendIds + "./";
  rtClient->addMatchmaker(2, 4, query, stringProperties, numericProperties, matchmakerSuccessCallback);
};

client->listFriends(session, {}, blockedState, {}, successCallback);
Client
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
var blocked_state = 3
var blocked_friends_result : NakamaAPI.ApiFriendList = yield(client.list_friends_async(session, blocked_state), "completed")
var blocked_friend_ids = ""

for friend in blocked_friends_result.friends:
  blocked_friend_ids += friend.user.id + " "

var string_properties = { "blocked", blocked_friend_ids }

var query = "-properties.blocked:/.%s./" % [blocked_friend_ids]
var ticket : NakamaRTAPI.MatchmakerTicket = yield(socket.add_matchmaker_async(query, 2, 4, string_properties, null), "completed")
Client
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
local limit = 100
local blocked_state = 3
local blocked_friends_result = client.list_friends(limit, blocked_state)

local blocked_friend_ids = ""
for i,friend in ipairs(blocked_friends_result.friends) do
  blocked_friend_ids = blocked_friend_ids .. friend.user.id .. " "
end

local min_players = 2
local max_players = 4
local query = ("-properties.blocked:/.%s./"):format(blocked_friend_ids)
local string_properties = { blocked = blocked_friend_ids}
local ticket = socket.matchmaker_add(min_players, max_players, query, string_properties)

Code snippet for this language Java/Android has not been found. Please choose another language to show equivalent examples.
Code snippet for this language REST has not been found. Please choose another language to show equivalent examples.
Code snippet for this language cURL has not been found. Please choose another language to show equivalent examples.