diff --git a/Assets/Prefabs/NetworkingManager.prefab b/Assets/Prefabs/NetworkingManager.prefab
index ab4bcbdc9..93f7165ce 100644
--- a/Assets/Prefabs/NetworkingManager.prefab
+++ b/Assets/Prefabs/NetworkingManager.prefab
@@ -108,7 +108,7 @@ MonoBehaviour:
SourceHashToOverride: 0
OverridingTargetPrefab: {fileID: 0}
TickRate: 30
- ClientConnectionBufferTimeout: 1
+ ClientConnectionBufferTimeout: 5
ConnectionApproval: 1
ConnectionData:
EnableTimeResync: 0
@@ -136,8 +136,7 @@ MonoBehaviour:
m_EditorClassIdentifier:
m_ProtocolType: 0
m_MaxPacketQueueSize: 512
- m_MaxPayloadSize: 32000
- m_MaxSendQueueSize: 50000000
+ m_MaxPayloadSize: 6144
m_HeartbeatTimeoutMS: 500
m_ConnectTimeoutMS: 1000
m_MaxConnectAttempts: 10
diff --git a/Assets/Scripts/ConnectionManagement/ConnectionMethod.cs b/Assets/Scripts/ConnectionManagement/ConnectionMethod.cs
new file mode 100644
index 000000000..4ac0cbac0
--- /dev/null
+++ b/Assets/Scripts/ConnectionManagement/ConnectionMethod.cs
@@ -0,0 +1,158 @@
+using System;
+using System.Threading.Tasks;
+using Unity.BossRoom.UnityServices.Lobbies;
+using Unity.BossRoom.Utils;
+using Unity.Netcode.Transports.UTP;
+using Unity.Networking.Transport.Relay;
+using Unity.Services.Authentication;
+using Unity.Services.Core;
+using Unity.Services.Relay;
+using Unity.Services.Relay.Models;
+using UnityEngine;
+
+namespace Unity.BossRoom.ConnectionManagement
+{
+ ///
+ /// ConnectionMethod contains all setup needed to setup NGO to be ready to start a connection, either host or client side.
+ /// Please override this abstract class to add a new transport or way of connecting.
+ ///
+ public abstract class ConnectionMethodBase
+ {
+ protected ConnectionManager m_ConnectionManager;
+ readonly ProfileManager m_ProfileManager;
+ protected readonly string m_PlayerName;
+
+ public abstract Task SetupHostConnectionAsync();
+
+ public abstract Task SetupClientConnectionAsync();
+
+ public ConnectionMethodBase(ConnectionManager connectionManager, ProfileManager profileManager, string playerName)
+ {
+ m_ConnectionManager = connectionManager;
+ m_ProfileManager = profileManager;
+ m_PlayerName = playerName;
+ }
+
+ protected void SetConnectionPayload(string playerId, string playerName)
+ {
+ var payload = JsonUtility.ToJson(new ConnectionPayload()
+ {
+ playerId = playerId,
+ playerName = playerName,
+ isDebug = Debug.isDebugBuild
+ });
+
+ var payloadBytes = System.Text.Encoding.UTF8.GetBytes(payload);
+
+ m_ConnectionManager.NetworkManager.NetworkConfig.ConnectionData = payloadBytes;
+ }
+
+ protected string GetPlayerId()
+ {
+ if (Services.Core.UnityServices.State != ServicesInitializationState.Initialized)
+ {
+ return ClientPrefs.GetGuid() + m_ProfileManager.Profile;
+ }
+
+ return AuthenticationService.Instance.IsSignedIn ? AuthenticationService.Instance.PlayerId : ClientPrefs.GetGuid() + m_ProfileManager.Profile;
+ }
+ }
+
+ ///
+ /// Simple IP connection setup with UTP
+ ///
+ class ConnectionMethodIP : ConnectionMethodBase
+ {
+ string m_Ipaddress;
+ ushort m_Port;
+
+ public ConnectionMethodIP(string ip, ushort port, ConnectionManager connectionManager, ProfileManager profileManager, string playerName)
+ : base(connectionManager, profileManager, playerName)
+ {
+ m_Ipaddress = ip;
+ m_Port = port;
+ m_ConnectionManager = connectionManager;
+ }
+
+ public override async Task SetupClientConnectionAsync()
+ {
+ SetConnectionPayload(GetPlayerId(), m_PlayerName);
+ var utp = (UnityTransport)m_ConnectionManager.NetworkManager.NetworkConfig.NetworkTransport;
+ utp.SetConnectionData(m_Ipaddress, m_Port);
+ }
+
+ public override async Task SetupHostConnectionAsync()
+ {
+ SetConnectionPayload(GetPlayerId(), m_PlayerName); // Need to set connection payload for host as well, as host is a client too
+ var utp = (UnityTransport)m_ConnectionManager.NetworkManager.NetworkConfig.NetworkTransport;
+ utp.SetConnectionData(m_Ipaddress, m_Port);
+ }
+ }
+
+ ///
+ /// UTP's Relay connection setup
+ ///
+ class ConnectionMethodRelay : ConnectionMethodBase
+ {
+ LobbyServiceFacade m_LobbyServiceFacade;
+ LocalLobby m_LocalLobby;
+
+ public ConnectionMethodRelay(LobbyServiceFacade lobbyServiceFacade, LocalLobby localLobby, ConnectionManager connectionManager, ProfileManager profileManager, string playerName)
+ : base(connectionManager, profileManager, playerName)
+ {
+ m_LobbyServiceFacade = lobbyServiceFacade;
+ m_LocalLobby = localLobby;
+ m_ConnectionManager = connectionManager;
+ }
+
+ public override async Task SetupClientConnectionAsync()
+ {
+ Debug.Log("Setting up Unity Relay client");
+
+ SetConnectionPayload(GetPlayerId(), m_PlayerName);
+
+ if (m_LobbyServiceFacade.CurrentUnityLobby == null)
+ {
+ throw new Exception("Trying to start relay while Lobby isn't set");
+ }
+
+ Debug.Log($"Setting Unity Relay client with join code {m_LocalLobby.RelayJoinCode}");
+
+ // Create client joining allocation from join code
+ var joinedAllocation = await RelayService.Instance.JoinAllocationAsync(m_LocalLobby.RelayJoinCode);
+ Debug.Log($"client: {joinedAllocation.ConnectionData[0]} {joinedAllocation.ConnectionData[1]}, " +
+ $"host: {joinedAllocation.HostConnectionData[0]} {joinedAllocation.HostConnectionData[1]}, " +
+ $"client: {joinedAllocation.AllocationId}");
+
+ await m_LobbyServiceFacade.UpdatePlayerRelayInfoAsync(joinedAllocation.AllocationId.ToString(), m_LocalLobby.RelayJoinCode);
+
+ // Configure UTP with allocation
+ var utp = (UnityTransport)m_ConnectionManager.NetworkManager.NetworkConfig.NetworkTransport;
+ utp.SetRelayServerData(new RelayServerData(joinedAllocation, OnlineState.k_DtlsConnType));
+ }
+
+ public override async Task SetupHostConnectionAsync()
+ {
+ Debug.Log("Setting up Unity Relay host");
+
+ SetConnectionPayload(GetPlayerId(), m_PlayerName); // Need to set connection payload for host as well, as host is a client too
+
+ // Create relay allocation
+ Allocation hostAllocation = await RelayService.Instance.CreateAllocationAsync(m_ConnectionManager.MaxConnectedPlayers, region: null);
+ var joinCode = await RelayService.Instance.GetJoinCodeAsync(hostAllocation.AllocationId);
+
+ Debug.Log($"server: connection data: {hostAllocation.ConnectionData[0]} {hostAllocation.ConnectionData[1]}, " +
+ $"allocation ID:{hostAllocation.AllocationId}, region:{hostAllocation.Region}");
+
+ m_LocalLobby.RelayJoinCode = joinCode;
+
+ //next line enable lobby and relay services integration
+ await m_LobbyServiceFacade.UpdateLobbyDataAsync(m_LocalLobby.GetDataForUnityServices());
+ await m_LobbyServiceFacade.UpdatePlayerRelayInfoAsync(hostAllocation.AllocationIdBytes.ToString(), joinCode);
+
+ // Setup UTP with relay connection info
+ var utp = (UnityTransport)m_ConnectionManager.NetworkManager.NetworkConfig.NetworkTransport;
+ utp.SetRelayServerData(new RelayServerData(hostAllocation, OnlineState.k_DtlsConnType)); // This is with DTLS enabled for a secure connection
+ }
+ }
+}
diff --git a/Assets/Scripts/ConnectionManagement/ConnectionMethod.cs.meta b/Assets/Scripts/ConnectionManagement/ConnectionMethod.cs.meta
new file mode 100644
index 000000000..364fe4576
--- /dev/null
+++ b/Assets/Scripts/ConnectionManagement/ConnectionMethod.cs.meta
@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: e414e30101f84433b92459054c280675
+timeCreated: 1665689296
\ No newline at end of file
diff --git a/Assets/Scripts/ConnectionManagement/ConnectionState/ClientConnectingState.cs b/Assets/Scripts/ConnectionManagement/ConnectionState/ClientConnectingState.cs
index 638a3d719..2b27fef74 100644
--- a/Assets/Scripts/ConnectionManagement/ConnectionState/ClientConnectingState.cs
+++ b/Assets/Scripts/ConnectionManagement/ConnectionState/ClientConnectingState.cs
@@ -1,9 +1,7 @@
using System;
using System.Threading.Tasks;
using Unity.BossRoom.UnityServices.Lobbies;
-using Unity.Multiplayer.Samples.BossRoom;
using Unity.Multiplayer.Samples.Utilities;
-using Unity.Netcode.Transports.UTP;
using UnityEngine;
using VContainer;
@@ -20,6 +18,13 @@ class ClientConnectingState : OnlineState
protected LobbyServiceFacade m_LobbyServiceFacade;
[Inject]
protected LocalLobby m_LocalLobby;
+ ConnectionMethodBase m_ConnectionMethod;
+
+ public ClientConnectingState Configure(ConnectionMethodBase baseConnectionMethod)
+ {
+ m_ConnectionMethod = baseConnectionMethod;
+ return this;
+ }
public override void Enter()
{
@@ -37,6 +42,12 @@ public override void OnClientConnected(ulong _)
}
public override void OnClientDisconnect(ulong _)
+ {
+ // client ID is for sure ours here
+ StartingClientFailedAsync();
+ }
+
+ protected void StartingClientFailedAsync()
{
m_ConnectStatusPublisher.Publish(ConnectStatus.StartClientFailed);
m_ConnectionManager.ChangeState(m_ConnectionManager.m_Offline);
@@ -48,52 +59,30 @@ public override void OnDisconnectReasonReceived(ConnectStatus disconnectReason)
m_ConnectionManager.ChangeState(m_ConnectionManager.m_DisconnectingWithReason);
}
- protected async Task ConnectClientAsync()
+
+ internal async Task ConnectClientAsync()
{
- bool success = true;
- if (m_LobbyServiceFacade.CurrentUnityLobby != null)
+ try
{
- success = await JoinRelayServerAsync();
- }
+ // Setup NGO with current connection method
+ await m_ConnectionMethod.SetupClientConnectionAsync();
- if (success)
- {
- success = m_ConnectionManager.NetworkManager.StartClient();
- }
+ // NGO's StartClient launches everything
+ if (!m_ConnectionManager.NetworkManager.StartClient())
+ {
+ throw new Exception("NetworkManager StartClient failed");
+ }
- if (success)
- {
SceneLoaderWrapper.Instance.AddOnSceneEventCallback();
m_ConnectionManager.RegisterCustomMessages();
}
- else
- {
- OnClientDisconnect(0);
- }
- }
-
- async Task JoinRelayServerAsync()
- {
- Debug.Log($"Setting Unity Relay client with join code {m_LocalLobby.RelayJoinCode}");
-
- try
- {
- var (ipv4Address, port, allocationIdBytes, allocationId, connectionData, hostConnectionData, key) =
- await UnityRelayUtilities.JoinRelayServerFromJoinCode(m_LocalLobby.RelayJoinCode);
-
- await m_LobbyServiceFacade.UpdatePlayerRelayInfoAsync(allocationId.ToString(), m_LocalLobby.RelayJoinCode);
- var utp = (UnityTransport)m_ConnectionManager.NetworkManager.NetworkConfig.NetworkTransport;
- utp.SetClientRelayData(ipv4Address, port, allocationIdBytes, key, connectionData, hostConnectionData, isSecure: true);
- }
catch (Exception e)
{
- Debug.Log($"Relay join failed: {e.Message}");
- //leave the lobby if relay failed for some reason
- await m_LobbyServiceFacade.EndTracking();
- return false;
+ Debug.LogError("Error connecting client, see following exception");
+ Debug.LogException(e);
+ StartingClientFailedAsync();
+ throw;
}
-
- return true;
}
}
}
diff --git a/Assets/Scripts/ConnectionManagement/ConnectionState/ClientReconnectingState.cs b/Assets/Scripts/ConnectionManagement/ConnectionState/ClientReconnectingState.cs
index 8dd2d46f7..4d0ad9e82 100644
--- a/Assets/Scripts/ConnectionManagement/ConnectionState/ClientReconnectingState.cs
+++ b/Assets/Scripts/ConnectionManagement/ConnectionState/ClientReconnectingState.cs
@@ -25,9 +25,9 @@ class ClientReconnectingState : ClientConnectingState
public override void Enter()
{
+ m_NbAttempts = 0;
m_LobbyCode = m_LobbyServiceFacade.CurrentUnityLobby != null ? m_LobbyServiceFacade.CurrentUnityLobby.LobbyCode : "";
m_ReconnectCoroutine = m_ConnectionManager.StartCoroutine(ReconnectCoroutine());
- m_NbAttempts = 0;
}
public override void Exit()
diff --git a/Assets/Scripts/ConnectionManagement/ConnectionState/OfflineState.cs b/Assets/Scripts/ConnectionManagement/ConnectionState/OfflineState.cs
index 3c36166ca..34dc047df 100644
--- a/Assets/Scripts/ConnectionManagement/ConnectionState/OfflineState.cs
+++ b/Assets/Scripts/ConnectionManagement/ConnectionState/OfflineState.cs
@@ -3,9 +3,6 @@
using Unity.BossRoom.UnityServices.Lobbies;
using Unity.BossRoom.Utils;
using Unity.Multiplayer.Samples.Utilities;
-using Unity.Netcode.Transports.UTP;
-using Unity.Services.Authentication;
-using Unity.Services.Core;
using UnityEngine;
using UnityEngine.SceneManagement;
using VContainer;
@@ -22,6 +19,8 @@ class OfflineState : ConnectionState
LobbyServiceFacade m_LobbyServiceFacade;
[Inject]
ProfileManager m_ProfileManager;
+ [Inject]
+ LocalLobby m_LocalLobby;
const string k_MainMenuSceneName = "MainMenu";
@@ -39,55 +38,28 @@ public override void Exit() { }
public override void StartClientIP(string playerName, string ipaddress, int port)
{
- var utp = (UnityTransport)m_ConnectionManager.NetworkManager.NetworkConfig.NetworkTransport;
- utp.SetConnectionData(ipaddress, (ushort)port);
- SetConnectionPayload(GetPlayerId(), playerName);
- m_ConnectionManager.ChangeState(m_ConnectionManager.m_ClientConnecting);
+ var connectionMethod = new ConnectionMethodIP(ipaddress, (ushort)port, m_ConnectionManager, m_ProfileManager, playerName);
+ m_ConnectionManager.m_ClientReconnecting.Configure(connectionMethod);
+ m_ConnectionManager.ChangeState(m_ConnectionManager.m_ClientConnecting.Configure(connectionMethod));
}
public override void StartClientLobby(string playerName)
{
- SetConnectionPayload(GetPlayerId(), playerName);
- m_ConnectionManager.ChangeState(m_ConnectionManager.m_ClientConnecting);
+ var connectionMethod = new ConnectionMethodRelay(m_LobbyServiceFacade, m_LocalLobby, m_ConnectionManager, m_ProfileManager, playerName);
+ m_ConnectionManager.m_ClientReconnecting.Configure(connectionMethod);
+ m_ConnectionManager.ChangeState(m_ConnectionManager.m_ClientConnecting.Configure(connectionMethod));
}
public override void StartHostIP(string playerName, string ipaddress, int port)
{
- var utp = (UnityTransport)m_ConnectionManager.NetworkManager.NetworkConfig.NetworkTransport;
- utp.SetConnectionData(ipaddress, (ushort)port);
-
- SetConnectionPayload(GetPlayerId(), playerName);
- m_ConnectionManager.ChangeState(m_ConnectionManager.m_StartingHost);
+ var connectionMethod = new ConnectionMethodIP(ipaddress, (ushort)port, m_ConnectionManager, m_ProfileManager, playerName);
+ m_ConnectionManager.ChangeState(m_ConnectionManager.m_StartingHost.Configure(connectionMethod));
}
public override void StartHostLobby(string playerName)
{
- SetConnectionPayload(GetPlayerId(), playerName);
- m_ConnectionManager.ChangeState(m_ConnectionManager.m_StartingHost);
- }
-
- void SetConnectionPayload(string playerId, string playerName)
- {
- var payload = JsonUtility.ToJson(new ConnectionPayload()
- {
- playerId = playerId,
- playerName = playerName,
- isDebug = Debug.isDebugBuild
- });
-
- var payloadBytes = System.Text.Encoding.UTF8.GetBytes(payload);
-
- m_ConnectionManager.NetworkManager.NetworkConfig.ConnectionData = payloadBytes;
- }
-
- string GetPlayerId()
- {
- if (UnityServices.State != ServicesInitializationState.Initialized)
- {
- return ClientPrefs.GetGuid() + m_ProfileManager.Profile;
- }
-
- return AuthenticationService.Instance.IsSignedIn ? AuthenticationService.Instance.PlayerId : ClientPrefs.GetGuid() + m_ProfileManager.Profile;
+ var connectionMethod = new ConnectionMethodRelay(m_LobbyServiceFacade, m_LocalLobby, m_ConnectionManager, m_ProfileManager, playerName);
+ m_ConnectionManager.ChangeState(m_ConnectionManager.m_StartingHost.Configure(connectionMethod));
}
}
}
diff --git a/Assets/Scripts/ConnectionManagement/ConnectionState/OnlineState.cs b/Assets/Scripts/ConnectionManagement/ConnectionState/OnlineState.cs
index 4b4ba7e89..89cf92c71 100644
--- a/Assets/Scripts/ConnectionManagement/ConnectionState/OnlineState.cs
+++ b/Assets/Scripts/ConnectionManagement/ConnectionState/OnlineState.cs
@@ -5,6 +5,7 @@ namespace Unity.BossRoom.ConnectionManagement
///
abstract class OnlineState : ConnectionState
{
+ public const string k_DtlsConnType = "dtls";
public override void OnUserRequestedShutdown()
{
diff --git a/Assets/Scripts/ConnectionManagement/ConnectionState/StartingHostState.cs b/Assets/Scripts/ConnectionManagement/ConnectionState/StartingHostState.cs
index 774c00a3a..eca47b3b6 100644
--- a/Assets/Scripts/ConnectionManagement/ConnectionState/StartingHostState.cs
+++ b/Assets/Scripts/ConnectionManagement/ConnectionState/StartingHostState.cs
@@ -3,7 +3,6 @@
using Unity.BossRoom.UnityServices.Lobbies;
using Unity.Multiplayer.Samples.BossRoom;
using Unity.Netcode;
-using Unity.Netcode.Transports.UTP;
using UnityEngine;
using VContainer;
@@ -19,11 +18,13 @@ class StartingHostState : OnlineState
LobbyServiceFacade m_LobbyServiceFacade;
[Inject]
LocalLobby m_LocalLobby;
+ ConnectionMethodBase m_ConnectionMethod;
- ///
- /// How many connections we create a Unity relay allocation for
- ///
- const int k_MaxUnityRelayConnections = 8;
+ public StartingHostState Configure(ConnectionMethodBase baseConnectionMethod)
+ {
+ m_ConnectionMethod = baseConnectionMethod;
+ return this;
+ }
public override void Enter()
{
@@ -36,11 +37,16 @@ public override void OnClientDisconnect(ulong clientId)
{
if (clientId == m_ConnectionManager.NetworkManager.LocalClientId)
{
- m_ConnectStatusPublisher.Publish(ConnectStatus.StartHostFailed);
- m_ConnectionManager.ChangeState(m_ConnectionManager.m_Offline);
+ StartHostFailed();
}
}
+ void StartHostFailed()
+ {
+ m_ConnectStatusPublisher.Publish(ConnectStatus.StartHostFailed);
+ m_ConnectionManager.ChangeState(m_ConnectionManager.m_Offline);
+ }
+
public override void OnServerStarted()
{
m_ConnectStatusPublisher.Publish(ConnectStatus.Success);
@@ -68,36 +74,21 @@ public override void ApprovalCheck(NetworkManager.ConnectionApprovalRequest requ
async void StartHost()
{
- if (m_LobbyServiceFacade.CurrentUnityLobby != null)
+ try
{
- Debug.Log("Setting up Unity Relay host");
-
- try
- {
- var (ipv4Address, port, allocationIdBytes, connectionData, key, joinCode) =
- await UnityRelayUtilities.AllocateRelayServerAndGetJoinCode(k_MaxUnityRelayConnections);
-
- m_LocalLobby.RelayJoinCode = joinCode;
- //next line enabled lobby and relay services integration
- await m_LobbyServiceFacade.UpdateLobbyDataAsync(m_LocalLobby.GetDataForUnityServices());
- await m_LobbyServiceFacade.UpdatePlayerRelayInfoAsync(allocationIdBytes.ToString(), joinCode);
+ await m_ConnectionMethod.SetupHostConnectionAsync();
+ Debug.Log($"Created relay allocation with join code {m_LocalLobby.RelayJoinCode}");
- // we now need to set the RelayCode somewhere :P
- var utp = (UnityTransport)m_ConnectionManager.NetworkManager.NetworkConfig.NetworkTransport;
- utp.SetHostRelayData(ipv4Address, port, allocationIdBytes, key, connectionData, isSecure: true);
- }
- catch (Exception e)
+ // NGO's StartHost launches everything
+ if (!m_ConnectionManager.NetworkManager.StartHost())
{
- Debug.LogErrorFormat($"{e.Message}");
- throw;
+ OnClientDisconnect(m_ConnectionManager.NetworkManager.LocalClientId);
}
-
- Debug.Log($"Created relay allocation with join code {m_LocalLobby.RelayJoinCode}");
}
-
- if (!m_ConnectionManager.NetworkManager.StartHost())
+ catch (Exception)
{
- OnClientDisconnect(m_ConnectionManager.NetworkManager.LocalClientId);
+ StartHostFailed();
+ throw;
}
}
}
diff --git a/Assets/Scripts/ConnectionManagement/Unity.BossRoom.ConnectionManagement.asmdef b/Assets/Scripts/ConnectionManagement/Unity.BossRoom.ConnectionManagement.asmdef
index 4f0905cd6..0d83eed23 100644
--- a/Assets/Scripts/ConnectionManagement/Unity.BossRoom.ConnectionManagement.asmdef
+++ b/Assets/Scripts/ConnectionManagement/Unity.BossRoom.ConnectionManagement.asmdef
@@ -11,7 +11,8 @@
"Unity.BossRoom.Utils",
"Unity.Services.Lobbies",
"Unity.Networking.Transport",
- "VContainer"
+ "VContainer",
+ "Unity.Services.Relay"
],
"includePlatforms": [],
"excludePlatforms": [],
@@ -22,4 +23,4 @@
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
-}
\ No newline at end of file
+}
diff --git a/Assets/Scripts/Gameplay/GameplayObjects/Breakable.cs b/Assets/Scripts/Gameplay/GameplayObjects/Breakable.cs
index 2edb3ace1..00aa20303 100644
--- a/Assets/Scripts/Gameplay/GameplayObjects/Breakable.cs
+++ b/Assets/Scripts/Gameplay/GameplayObjects/Breakable.cs
@@ -3,7 +3,6 @@
using Unity.BossRoom.Infrastructure;
using Unity.Netcode;
using UnityEngine;
-using UnityEngine.Assertions;
namespace Unity.BossRoom.Gameplay.GameplayObjects
{
diff --git a/Assets/Scripts/Infrastructure/NetworkGuid.cs b/Assets/Scripts/Infrastructure/NetworkGuid.cs
index 05eb28377..6c28d2b3f 100644
--- a/Assets/Scripts/Infrastructure/NetworkGuid.cs
+++ b/Assets/Scripts/Infrastructure/NetworkGuid.cs
@@ -3,7 +3,7 @@
namespace Unity.BossRoom.Infrastructure
{
- public struct NetworkGuid : INetworkSerializable
+ public class NetworkGuid : INetworkSerializable
{
public ulong FirstHalf;
public ulong SecondHalf;
diff --git a/Assets/Tests/Runtime/NetworkedMessageChannelTests.cs b/Assets/Tests/Runtime/NetworkedMessageChannelTests.cs
index 511dc121c..2652aebb8 100644
--- a/Assets/Tests/Runtime/NetworkedMessageChannelTests.cs
+++ b/Assets/Tests/Runtime/NetworkedMessageChannelTests.cs
@@ -149,15 +149,18 @@ public IEnumerator NetworkedMessagesAreStillReceivedAfterNetworkManagerShutsDown
m_NbMessagesReceived = 0;
+ m_PlayerPrefab.SetActive(false); // to prevent NM from destroying the prefab on shutdown. This flow isn't great and is hackish, should be reworked
// Shutdown the server and clients
- NetcodeIntegrationTestHelpers.StopOneClient(m_ServerNetworkManager, false);
- NetcodeIntegrationTestHelpers.StopOneClient(m_ClientNetworkManagers[0], false);
- NetcodeIntegrationTestHelpers.StopOneClient(m_ClientNetworkManagers[1], false);
+ m_ServerNetworkManager.Shutdown();
+ m_ClientNetworkManagers[0].Shutdown();
+ m_ClientNetworkManagers[1].Shutdown();
yield return new WaitWhile(() => m_ServerNetworkManager.ShutdownInProgress);
yield return new WaitWhile(() => m_ClientNetworkManagers[0].ShutdownInProgress);
yield return new WaitWhile(() => m_ClientNetworkManagers[1].ShutdownInProgress);
+ m_PlayerPrefab.SetActive(true); // reactivating after destroy prevention
+
// Restart the server and clients
m_ServerNetworkManager.StartHost();
NetcodeIntegrationTestHelpers.StartOneClient(m_ClientNetworkManagers[0]);
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 8f9043d76..3d79411f0 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -12,7 +12,13 @@ Additional documentation and release notes are available at [Multiplayer Documen
*
### Changed
-*
+* Updated Boss Room to NGO 1.1.0 (#708)
+ * Now uses managed types for custom INetworkSerializable in NetworkVariables. NetworkGUID is now a class instead of a struct.
+ * Cleanup Relay and UTP setup. Flow is now simpler, no need for the RelayUtilities anymore.
+ * This cleansup various setup steps and puts them all in a new "ConnectionMethod.cs".
+ * MaxSendQueueSize value is removed, reserialized NetworkManager to remove that now useless value.
+ * Reverted the default value for max payload size, this is no longer useful as NGO is mostly reliable.
+ * Set connection approval timeout higher, 1 sec is pretty short. If there's a packet drop, some hangups on the network, clients would get timedout too easily.
### Cleanup
* Removed unnecessary FindObjectOfType usage inside of ClientCharSelectState (#754)
diff --git a/Packages/com.unity.multiplayer.samples.coop/CHANGELOG.md b/Packages/com.unity.multiplayer.samples.coop/CHANGELOG.md
index ec0a7cb71..8d5fc4a36 100644
--- a/Packages/com.unity.multiplayer.samples.coop/CHANGELOG.md
+++ b/Packages/com.unity.multiplayer.samples.coop/CHANGELOG.md
@@ -7,7 +7,7 @@
### Changed
*
### Removed
-*
+* Deprecated Unity Relay Utilities, it should no longer be needed with NGO 1.1.0's new API for setting up Relay (#708)
### Fixed
*
diff --git a/Packages/com.unity.multiplayer.samples.coop/Utilities/Net/UnityRelayUtilities.cs b/Packages/com.unity.multiplayer.samples.coop/Utilities/Net/UnityRelayUtilities.cs
index ca401330d..f792fe1d2 100644
--- a/Packages/com.unity.multiplayer.samples.coop/Utilities/Net/UnityRelayUtilities.cs
+++ b/Packages/com.unity.multiplayer.samples.coop/Utilities/Net/UnityRelayUtilities.cs
@@ -11,9 +11,16 @@ public static class UnityRelayUtilities
{
const string k_KDtlsConnType = "dtls";
- public static async
- Task<(string ipv4address, ushort port, byte[] allocationIdBytes, byte[] connectionData, byte[] key, string
- joinCode)> AllocateRelayServerAndGetJoinCode(int maxConnections, string region = null)
+ ///
+ /// Deprecated, please see updated ConnectionManager sample code for an example on how to connect to Relay
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ 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 joinCode;
@@ -43,9 +50,15 @@ public static async
allocation.ConnectionData, allocation.Key, joinCode);
}
- public static async
- Task<(string ipv4address, ushort port, byte[] allocationIdBytes, Guid allocationId, byte[] connectionData, byte[]
- hostConnectionData, byte[] key)> JoinRelayServerFromJoinCode(string joinCode)
+ ///
+ /// Deprecated, please see updated ConnectionManager sample code for an example on how to connect to Relay
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static async Task<(string ipv4address, ushort port, byte[] allocationIdBytes, Guid allocationId, byte[] connectionData, byte[] hostConnectionData, byte[] key)>
+ JoinRelayServerFromJoinCode(string joinCode)
{
JoinAllocation allocation;
try
diff --git a/Packages/com.unity.multiplayer.samples.coop/Utilities/SceneManagement/LoadingProgressManager.cs b/Packages/com.unity.multiplayer.samples.coop/Utilities/SceneManagement/LoadingProgressManager.cs
index a40a82753..a23fd6b2c 100644
--- a/Packages/com.unity.multiplayer.samples.coop/Utilities/SceneManagement/LoadingProgressManager.cs
+++ b/Packages/com.unity.multiplayer.samples.coop/Utilities/SceneManagement/LoadingProgressManager.cs
@@ -1,5 +1,4 @@
using System;
-using System.Collections;
using System.Collections.Generic;
using Unity.Netcode;
using UnityEngine;
diff --git a/Packages/com.unity.multiplayer.samples.coop/Utilities/SceneManagement/SceneLoaderWrapper.cs b/Packages/com.unity.multiplayer.samples.coop/Utilities/SceneManagement/SceneLoaderWrapper.cs
index 5be25c6ae..0ad640cd3 100644
--- a/Packages/com.unity.multiplayer.samples.coop/Utilities/SceneManagement/SceneLoaderWrapper.cs
+++ b/Packages/com.unity.multiplayer.samples.coop/Utilities/SceneManagement/SceneLoaderWrapper.cs
@@ -1,5 +1,4 @@
using System;
-using System.Collections.Generic;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.SceneManagement;
diff --git a/Packages/com.unity.multiplayer.samples.coop/package.json b/Packages/com.unity.multiplayer.samples.coop/package.json
index c4f6671cd..eefd8ef10 100644
--- a/Packages/com.unity.multiplayer.samples.coop/package.json
+++ b/Packages/com.unity.multiplayer.samples.coop/package.json
@@ -9,7 +9,7 @@
"dependencies": {
"com.unity.learn.iet-framework": "1.2.1",
"com.unity.multiplayer.tools": "1.0.0",
- "com.unity.netcode.gameobjects": "1.0.2",
+ "com.unity.netcode.gameobjects": "1.1.0",
"com.unity.services.relay": "1.0.3"
}
-}
+}
\ No newline at end of file
diff --git a/Packages/manifest.json b/Packages/manifest.json
index cae525a80..689f807a3 100644
--- a/Packages/manifest.json
+++ b/Packages/manifest.json
@@ -10,7 +10,7 @@
"com.unity.learn.iet-framework": "2.2.2",
"com.unity.memoryprofiler": "0.5.0-preview.1",
"com.unity.multiplayer.tools": "1.0.0",
- "com.unity.netcode.gameobjects": "1.0.2",
+ "com.unity.netcode.gameobjects": "1.1.0",
"com.unity.performance.profile-analyzer": "1.1.1",
"com.unity.postprocessing": "3.2.2",
"com.unity.render-pipelines.universal": "12.1.7",
diff --git a/Packages/packages-lock.json b/Packages/packages-lock.json
index 93d1b45c4..91bca3302 100644
--- a/Packages/packages-lock.json
+++ b/Packages/packages-lock.json
@@ -122,7 +122,7 @@
"dependencies": {
"com.unity.learn.iet-framework": "1.2.1",
"com.unity.multiplayer.tools": "1.0.0",
- "com.unity.netcode.gameobjects": "1.0.2",
+ "com.unity.netcode.gameobjects": "1.1.0",
"com.unity.services.relay": "1.0.3"
}
},
@@ -140,12 +140,12 @@
"url": "https://packages.unity.com"
},
"com.unity.netcode.gameobjects": {
- "version": "1.0.2",
+ "version": "1.1.0",
"depth": 0,
"source": "registry",
"dependencies": {
"com.unity.nuget.mono-cecil": "1.10.1",
- "com.unity.transport": "1.2.0"
+ "com.unity.transport": "1.3.0"
},
"url": "https://packages.unity.com"
},
@@ -359,7 +359,7 @@
"url": "https://packages.unity.com"
},
"com.unity.transport": {
- "version": "1.2.0",
+ "version": "1.3.0",
"depth": 1,
"source": "registry",
"dependencies": {