> ## Documentation Index
> Fetch the complete documentation index at: https://devdocs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Workaround for peer-to-peer connection

> PlayFab マッチメイキングを使用してマッチしたプレイヤー間で IP アドレスと接続情報を交換し、ピアツーピアのマルチプレイヤー セッション ホスティングを実現します。

マッチメイキングの最終的な結果はマッチであり、キューのルールを満たすチケットのコレクションです。専用サーバーを持つタイトルの場合、マッチ ID は一意であり、一緒にプレイするべきプレイヤーのグループを識別するために使用できます。

しかし、ピアツーピアの場合、タイトルは接続情報をお互いに渡す必要があります。このチュートリアルでは、これを行うための回避策について説明します。

<Note>
  マッチメイキングでのピアツーピア接続は、現在公式にはサポートされていません。[PlayFab Party](/services/playfab/multiplayer/networking) を検討するか、詳細についてはお問い合わせください。
</Note>

## IP アドレスを属性として指定する

[チケットで属性を指定する](/services/playfab/multiplayer/matchmaking/ticket-attributes) と同様に、IP アドレスなどの任意の値を属性として指定できます。ルールに対応する必要はありません。

```json theme={null}
POST https://{{TitleId}}.playfabapi.com/Match/CreateMatchmakingTicket
{
    "Creator": {
        "Entity": {
            "Id": "A8140AB9109712B",
            "Type": "title_player_account",
            "TypeString": "title_player_account"
        },
        "Attributes": {
            "DataObject": {
                "IP": "123.234.123.12"
            }
        }
    },
    "MembersToMatchWith": [],
    "GiveUpAfterSeconds": 2,
    "QueueName": "IPExampleQueue"
}
```

## マッチからすべてのプレイヤーの IP を取得する

[GetMatch](xref:titleid.playfabapi.com.multiplayer.matchmaking.getmatch) を呼び出すときに、フラグ `ReturnMemberAttributes` を `true` として指定して、各チケットの属性を返すようにします。これには、指定された IP アドレスが含まれます。

```json theme={null}
{
    "code": 200,
    "status": "OK",
    "data": {
        "MatchId": "3d58dc0f-2eb6-4162-a2e0-1ed6ac5ea551",
        "Members": [
            {
                "TeamId": "",
                "Entity": {
                    "Id": "A8140AB9109712B",
                    "Type": "title_player_account",
                    "TypeString": "title_player_account"
                },
                "Attributes": {
                    "DataObject": {
                        "IP": "123.234.123.12"
                    }
                }
            },
            {
                "TeamId": "",
                "Entity": {
                    "Id": "562D72A5B184F612",
                    "Type": "title_player_account",
                    "TypeString": "title_player_account"
                },
                "Attributes": {
                    "DataObject": {
                        "IP": "123.234.123.12"
                    }
                }
            }
        ]
    }
}
```

<Note>
  IP を交換するためにこれを使用できますが、クライアント間の接続性を保証するものではありません。
</Note>


## Related topics

- [Using direct peer-to-peer connections](/ja-jp/services/playfab/multiplayer/networking/concepts-direct-peer-connectivity.md)
- [セッションテンプレートの定数](/ja-jp/services/xbox-services/multiplayer/mpsd/concepts/live-session-template-constants.md)
- [XblMultiplayerPeerToPeerRequirements](/ja-jp/reference/live/xsapi-c/multiplayer_c/structs/xblmultiplayerpeertopeerrequirements.md)
- [XblMultiplayerSessionConstantsSetPeerToPeerRequirements](/ja-jp/reference/live/xsapi-c/multiplayer_c/functions/xblmultiplayersessionconstantssetpeertopeerrequirements.md)
- [PartyDirectPeerConnectivityOptions](/ja-jp/services/playfab/multiplayer/networking/reference/enums/partydirectpeerconnectivityoptions.md)
