Enable DTLS encryption
Configure your Relay client to use Datagram Transport Layer Security for encrypted connections.
読み終わるまでの所要時間 1 分最終更新 22日前
Relay supports DTLS encryption of all UDP communication to and from the Relay servers. Set the Relay server to when creating an allocation as a host player to enable DTLS encryption.
RelayProtocolDTLSThe following code snippet shows how to create sessions with DTLS encryption:
using Unity.Services.Multiplayer;// As host: create a session with DTLS encryption explicitly setvar session = await MultiplayerService.Instance.CreateSessionAsync( new SessionOptions { MaxPlayers = 4 } .WithRelayNetwork() .WithNetworkOptions(new NetworkOptions { RelayProtocol = RelayProtocol.DTLS }));Debug.Log($"Session created with join code: {session.Code}");
The following code snippet shows how to join a session with DTLS encryption:
// As client: join by code with DTLSvar session = await MultiplayerService.Instance.JoinSessionByCodeAsync( joinCode, new JoinSessionOptions() .WithNetworkOptions(new NetworkOptions { RelayProtocol = RelayProtocol.DTLS }));