Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -1442,6 +1442,11 @@ public override bool StartServer()
/// </summary>
public override void Shutdown()
{
if (NetworkManager && !NetworkManager.ShutdownInProgress)
{
Debug.LogWarning("Directly calling `UnityTransport.Shutdown()` results in unexpected shutdown behaviour. All pending events will be lost. Use `NetworkManager.Shutdown()` instead.");
}

if (m_Driver.IsCreated)
{
// Flush all send queues to the network. NGO can be configured to flush its message
Expand All @@ -1461,6 +1466,7 @@ public override void Shutdown()
DisposeInternals();

m_ReliableReceiveQueues.Clear();
m_State = State.Disconnected;

// We must reset this to zero because UTP actually re-uses clientIds if there is a clean disconnect
m_ServerClientId = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -517,5 +517,42 @@ public IEnumerator ReliablePayloadsCanBeLargerThanMaximum()

yield return null;
}

public enum AfterShutdownAction
{
Send,
DisconnectRemoteClient,
DisconnectLocalClient,
}

[UnityTest]
public IEnumerator DoesNotActAfterShutdown([Values] AfterShutdownAction afterShutdownAction)
{
InitializeTransport(out m_Server, out m_ServerEvents);
InitializeTransport(out m_Client1, out m_Client1Events);

m_Server.StartServer();
m_Client1.StartClient();

yield return WaitForNetworkEvent(NetworkEvent.Connect, m_Client1Events);

m_Server.Shutdown();

if (afterShutdownAction == AfterShutdownAction.Send)
{
var data = new ArraySegment<byte>(new byte[16]);
m_Server.Send(m_Client1.ServerClientId, data, NetworkDelivery.Reliable);
}
else if (afterShutdownAction == AfterShutdownAction.DisconnectRemoteClient)
{
m_Server.DisconnectRemoteClient(m_Client1.ServerClientId);

LogAssert.Expect(LogType.Assert, "DisconnectRemoteClient should be called on a listening server");
}
else if (afterShutdownAction == AfterShutdownAction.DisconnectLocalClient)
{
m_Server.DisconnectLocalClient();
}
}
}
}
Loading