Skip to content

feat: Simpler relay data setters in the adapter #1609

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions com.unity.netcode.adapter.utp/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ All notable changes to this package will be documented in this file. The format

### Added

- 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)

### Changed

- Rename the 'Send Queue Batch Size' property to 'Max Payload Size' to better reflect its usage (#1584)
Expand Down
27 changes: 27 additions & 0 deletions com.unity.netcode.adapter.utp/Runtime/UnityTransport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,33 @@ public void SetRelayServerData(string ipv4Address, ushort port, byte[] allocatio
SetProtocol(ProtocolType.RelayUnityTransport);
}

/// <summary>Set the relay server data for the host.</summary>
/// <param name="ipAddress">IP address of the relay server.</param>
/// <param name="port">UDP port of the relay server.</param>
/// <param name="allocationId">Allocation ID as a byte array.</param>
/// <param name="key">Allocation key as a byte array.</param>
/// <param name="connectionData">Connection data as a byte array.</param>
/// <param name="isSecure">Whether the connection is secure (uses DTLS).</param>
public void SetHostRelayData(string ipAddress, ushort port, byte[] allocationId, byte[] key,
byte[] connectionData, bool isSecure = false)
{
SetRelayServerData(ipAddress, port, allocationId, key, connectionData, isSecure: isSecure);
}

/// <summary>Set the relay server data for the host.</summary>
/// <param name="ipAddress">IP address of the relay server.</param>
/// <param name="port">UDP port of the relay server.</param>
/// <param name="allocationId">Allocation ID as a byte array.</param>
/// <param name="key">Allocation key as a byte array.</param>
/// <param name="connectionData">Connection data as a byte array.</param>
/// <param name="hostConnectionData">Host's connection data as a byte array.</param>
/// <param name="isSecure">Whether the connection is secure (uses DTLS).</param>
public void SetClientRelayData(string ipAddress, ushort port, byte[] allocationId, byte[] key,
byte[] connectionData, byte[] hostConnectionData, bool isSecure = false)
{
SetRelayServerData(ipAddress, port, allocationId, key, connectionData, hostConnectionData, isSecure);
}

/// <summary>
/// Sets IP and Port information. This will be ignored if using the Unity Relay and you should call <see cref="SetRelayServerData"/>
/// </summary>
Expand Down