Skip to content

Commit c009f6f

Browse files
committed
fix: shutting down properly, when failing to StartHost or StartClient. This allows the next attempt to not fail automatically. (#1918)
1 parent 3b67385 commit c009f6f

1 file changed

Lines changed: 19 additions & 3 deletions

File tree

com.unity.netcode.gameobjects/Runtime/Transports/UTP/UnityTransport.cs

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1047,7 +1047,12 @@ public override bool StartClient()
10471047
return false;
10481048
}
10491049

1050-
return ClientBindAndConnect();
1050+
var succeeded = ClientBindAndConnect();
1051+
if (!succeeded)
1052+
{
1053+
Shutdown();
1054+
}
1055+
return succeeded;
10511056
}
10521057

10531058
public override bool StartServer()
@@ -1057,12 +1062,23 @@ public override bool StartServer()
10571062
return false;
10581063
}
10591064

1065+
bool succeeded;
10601066
switch (m_ProtocolType)
10611067
{
10621068
case ProtocolType.UnityTransport:
1063-
return ServerBindAndListen(ConnectionData.ListenEndPoint);
1069+
succeeded = ServerBindAndListen(ConnectionData.ListenEndPoint);
1070+
if (!succeeded)
1071+
{
1072+
Shutdown();
1073+
}
1074+
return succeeded;
10641075
case ProtocolType.RelayUnityTransport:
1065-
return StartRelayServer();
1076+
succeeded = StartRelayServer();
1077+
if (!succeeded)
1078+
{
1079+
Shutdown();
1080+
}
1081+
return succeeded;
10661082
default:
10671083
return false;
10681084
}

0 commit comments

Comments
 (0)