ドキュメント

サポート

Relay

Relay

DTLS 暗号化を有効にする

Configure your Relay client to use Datagram Transport Layer Security for encrypted connections.
読み終わるまでの所要時間 1 分最終更新 1ヶ月前

Relay は、Relay サーバー 間の全 UDP 通信の DTLS 暗号化 に対応しています。DTLS 暗号化を有効にするには、割り当てをホストプレイヤーとして作成しているときに、Relay サーバーの
connectionType
dtls
に設定します。
以下のコードスニペットには
AllocateRelayServerAndGetJoinCode
という関数があり、Relay SDK を使用して割り当てを作成する方法、参加コード をリクエストする方法、接続の種類を DTLS に設定する方法を示しています。
public static async Task<(string ipv4address, ushort port, byte[] allocationIdBytes, byte[] connectionData, byte[] key, string joinCode)> AllocateRelayServerAndGetJoinCode(int maxConnections, string region = null){ Allocation allocation; string createJoinCode; try { allocation = await RelayService.Instance.CreateAllocationAsync(maxConnections, region); } catch (Exception e) { Debug.LogError($"Relay create allocation request failed {e.Message}"); throw; } Debug.Log($"server connection data: {allocation.ConnectionData[0]} {allocation.ConnectionData[1]}"); Debug.Log($"server allocation ID: {allocation.AllocationId}"); try { createJoinCode = await RelayService.Instance.GetJoinCodeAsync(allocation.AllocationId); } catch { Debug.LogError("Relay create join code request failed"); throw; } var dtlsEndpoint = allocation.ServerEndpoints.First(e => e.ConnectionType == "dtls"); return (dtlsEndpoint.Host, (ushort)dtlsEndpoint.Port, allocation.AllocationIdBytes, allocation.ConnectionData, allocation.Key, createJoinCode);}