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

**URL:** https://heroiclabs.com/docs/kr/nakama/guides/concepts/matchmaking-blocked-users/
**Summary:** Nakama 매치 메이커 실행을 통해 플레이어가 차단된 사용자와 대결이 성립되지 않도록 하기 위한 가이드.
**Keywords:** matchmaker, blocked users, matchmaking, blocked, matchmaking criteria
**Categories:** guides

---


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

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

사용자가 다른 사용자를 [차단](../../../concepts/friends/#block-a-friend)한 경우, 매치 메이커에 의해서 두 사용자가 같은 대결, 그룹 또는 다른 소셜 기능에 함께 참여하지 않는 것이 좋습니다.

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

* 사용자별 차단한 사용자의 목록 찾기
* 개별적인 [매치 메이커 속성](../../../concepts/multiplayer/matchmaker/#properties)의 일부로 목록을 사용함
* 매치 메이커 [쿼리](../../../concepts/multiplayer/matchmaker/#query)에 문항을 추가하여 차단된 사용자와 매칭을 방지함

## 차단된 사용자 목록 보기

차단된 상태의 사용자만 필터링하는 [친구 목록 API](../../../server-framework/typescript-runtime/function-reference/#friendsList)를 사용하여 플레이어가 차단한 모든 사용자의 목록을 볼 수 있습니다.

{{< code type="client" >}}
```csharp
var blockedState = 3;
var blockedFriendsResult = await client.ListFriendsAsync(session, blockedState, 100, null);
```
{{< / code >}}

{{< code type="client" >}}
```javascript
const blockedState = 3;
const blockedFriendsResult = await client.listFriends(session, null, blockedState);
```
{{< / code >}}

{{< code type="client" >}}
```cpp
int blockedState = 3;
auto successCallback = [](NFriendsPtr blockedFriendsResult)
{
  // Blocked friends available as blockedFriendsResult->friends
};

client->listFriends(session, {}, blockedState, {}, successCallback);
```
{{< / code >}}

{{< code type="client" framework="godot3" >}}
```gdscript
var blocked_state = 3
var blocked_friends_result : NakamaAPI.ApiFriendList = yield(client.list_friends_async(session, blocked_state), "completed")
```
{{< / code >}}

{{< code type="client" framework="defold" >}}
```lua
local limit = 100
local blocked_state = 3
local blocked_friends_result = client.list_friends(limit, blocked_state)
```
{{< / code >}}

{{< missing type="client" lang="java" />}}
{{< missing type="client" lang="shell" />}}
{{< missing type="client" lang="bash" />}}

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

{{< code type="client" >}}
```csharp
var blockedFriendIds = string.Join(" ", blockedFriendsResult.Friends.Select(x => x.User.Id));
```
{{< / code >}}

{{< code type="client" >}}
```javascript
const blockedFriendIds = blockedFriendsResult.friends.map(friend => friend.userId).join(' ');
```
{{< / code >}}

{{< code type="client" >}}
```cpp
auto successCallback = [](NFriendListPtr blockedFriendsResult)
{
  string blockedFriendIds = "";
  for (NFriend friend : blockedFriendsResult->friends) {
    blockedFriendIdsString += friend.user.id + " ";
  }
};
```
{{< / code >}}

{{< code type="client" framework="godot3" >}}
```gdscript
var blocked_friend_ids = ""

for friend in blocked_friends_result.friends:
  blocked_friend_ids += friend.user.id + " "
```
{{< / code >}}

{{< code type="client" framework="defold" >}}
```lua
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 >}}

{{< missing type="client" lang="java" />}}
{{< missing type="client" lang="shell" />}}
{{< missing type="client" lang="bash" />}}

## 매치 메이커 기준

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

{{< code type="client" >}}
```csharp
var stringProperties = new Dictionary<string, string>
{
    { "blocked", blockedFriendIds }
}; 
```
{{< / code >}}

{{< code type="client" >}}
```javascript
const stringProperties = {
  "blocked": blockedFriendIds
};
```
{{< / code >}}

{{< code type="client" >}}
```cpp
NStringMap stringProperties;
stringProperties.emplace("blocked", blockedFriendIds);
```
{{< / code >}}

{{< code type="client" framework="godot3" >}}
```gdscript
var string_properties = { "blocked", blocked_friend_ids }
```
{{< / code >}}

{{< code type="client" framework="defold" >}}
```lua
local string_properties = { blocked = blocked_friend_ids }
```
{{< / code >}}

{{< missing type="client" lang="java" />}}
{{< missing type="client" lang="shell" />}}
{{< missing type="client" lang="bash" />}}

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

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

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

{{< code type="client" >}}
```csharp
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);
```
{{< /code >}}

{{< code type="client" >}}
```javascript
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);
```
{{< / code >}}

{{< code type="client" >}}
```cpp
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);
```
{{< / code >}}


{{< code type="client" framework="godot3" >}}
```gdscript
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")
```
{{< / code >}}

{{< code type="client" framework="defold" >}}
```lua
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 >}}

{{< missing type="client" lang="java" />}}
{{< missing type="client" lang="shell" />}}
{{< missing type="client" lang="bash" />}}
