Skip to content

Commit b63328f

Browse files
feat: Simpler relay data setters in the adapter (1.0.0) (#1611)
1 parent c2d96f0 commit b63328f

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

com.unity.netcode.adapter.utp/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ All notable changes to this package will be documented in this file. The format
66

77
### Added
88

9+
- Added new methods to set the relay server data: `SetHostRelayData` and `SetClientRelayData`. These are meant to be less error-prone than `SetRelayServerData` (which remains available). (#1609)
10+
911
### Changed
1012

1113
- Rename the 'Send Queue Batch Size' property to 'Max Payload Size' to better reflect its usage. (#1584)

com.unity.netcode.adapter.utp/Runtime/UnityTransport.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,33 @@ public void SetRelayServerData(string ipv4Address, ushort port, byte[] allocatio
391391
SetProtocol(ProtocolType.RelayUnityTransport);
392392
}
393393

394+
/// <summary>Set the relay server data for the host.</summary>
395+
/// <param name="ipAddress">IP address of the relay server.</param>
396+
/// <param name="port">UDP port of the relay server.</param>
397+
/// <param name="allocationId">Allocation ID as a byte array.</param>
398+
/// <param name="key">Allocation key as a byte array.</param>
399+
/// <param name="connectionData">Connection data as a byte array.</param>
400+
/// <param name="isSecure">Whether the connection is secure (uses DTLS).</param>
401+
public void SetHostRelayData(string ipAddress, ushort port, byte[] allocationId, byte[] key,
402+
byte[] connectionData, bool isSecure = false)
403+
{
404+
SetRelayServerData(ipAddress, port, allocationId, key, connectionData, isSecure: isSecure);
405+
}
406+
407+
/// <summary>Set the relay server data for the host.</summary>
408+
/// <param name="ipAddress">IP address of the relay server.</param>
409+
/// <param name="port">UDP port of the relay server.</param>
410+
/// <param name="allocationId">Allocation ID as a byte array.</param>
411+
/// <param name="key">Allocation key as a byte array.</param>
412+
/// <param name="connectionData">Connection data as a byte array.</param>
413+
/// <param name="hostConnectionData">Host's connection data as a byte array.</param>
414+
/// <param name="isSecure">Whether the connection is secure (uses DTLS).</param>
415+
public void SetClientRelayData(string ipAddress, ushort port, byte[] allocationId, byte[] key,
416+
byte[] connectionData, byte[] hostConnectionData, bool isSecure = false)
417+
{
418+
SetRelayServerData(ipAddress, port, allocationId, key, connectionData, hostConnectionData, isSecure);
419+
}
420+
394421
/// <summary>
395422
/// Sets IP and Port information. This will be ignored if using the Unity Relay and you should call <see cref="SetRelayServerData"/>
396423
/// </summary>

0 commit comments

Comments
 (0)