@@ -1668,6 +1668,21 @@ public void CreateDriver(UnityTransport transport, out NetworkDriver driver,
16681668 }
16691669#endif
16701670
1671+ #if UNITY_SERVER
1672+ if ( m_ProtocolType == ProtocolType . RelayUnityTransport )
1673+ {
1674+ if ( m_UseWebSockets )
1675+ {
1676+ Debug . LogError ( "Transport is configured to use Websockets, but websockets are not available on server builds. Ensure that the \" Use WebSockets\" checkbox is checked under \" Unity Transport\" component." ) ;
1677+ }
1678+
1679+ if ( m_RelayServerData . IsWebSocket != 0 )
1680+ {
1681+ Debug . LogError ( "Relay server data indicates usage of WebSockets, but websockets are not available on server builds. Be sure to use \" dtls\" or \" udp\" as the connection type when creating the server data" ) ;
1682+ }
1683+ }
1684+ #endif
1685+
16711686#if UTP_TRANSPORT_2_0_ABOVE
16721687 if ( m_UseEncryption )
16731688 {
@@ -1713,32 +1728,30 @@ public void CreateDriver(UnityTransport transport, out NetworkDriver driver,
17131728#endif
17141729
17151730#if UTP_TRANSPORT_2_1_ABOVE
1716- if ( m_ProtocolType == ProtocolType . RelayUnityTransport )
1731+ if ( m_UseWebSockets && m_RelayServerData . IsWebSocket == 0 )
17171732 {
1718- if ( m_UseWebSockets && m_RelayServerData . IsWebSocket == 0 )
1719- {
1720- Debug . LogError ( "Transport is configured to use WebSockets, but Relay server data isn't. Be sure to use \" wss\" as the connection type when creating the server data (instead of \" dtls\" or \" udp\" )." ) ;
1721- }
1733+ Debug . LogError ( "Transport is configured to use WebSockets, but Relay server data isn't. Be sure to use \" wss\" as the connection type when creating the server data (instead of \" dtls\" or \" udp\" )." ) ;
1734+ }
17221735
1723- if ( ! m_UseWebSockets && m_RelayServerData . IsWebSocket != 0 )
1724- {
1725- Debug . LogError ( "Relay server data indicates usage of WebSockets, but \" Use WebSockets\" checkbox isn't checked under \" Unity Transport\" component." ) ;
1726- }
1736+ if ( ! m_UseWebSockets && m_RelayServerData . IsWebSocket != 0 )
1737+ {
1738+ Debug . LogError ( "Relay server data indicates usage of WebSockets, but \" Use WebSockets\" checkbox isn't checked under \" Unity Transport\" component." ) ;
17271739 }
1740+ }
17281741#endif
17291742
17301743#if UTP_TRANSPORT_2_0_ABOVE
17311744 if ( m_UseWebSockets )
17321745 {
1733- driver = NetworkDriver . Create ( new WebSocketNetworkInterface ( ) , m_NetworkSettings ) ;
1746+ driver = NetworkDriver . Create ( private new WebSocketNetworkInterface( ) , m_NetworkSettings ) ;
17341747 }
17351748 else
17361749 {
17371750#if UNITY_WEBGL && ! UNITY_EDITOR
17381751 Debug . LogWarning ( $ "WebSockets were used even though they're not selected in NetworkManager. You should check { nameof ( UseWebSockets ) } ', on the Unity Transport component, to silence this warning.") ;
17391752 driver = NetworkDriver . Create ( new WebSocketNetworkInterface ( ) , m_NetworkSettings ) ;
17401753#else
1741- driver = NetworkDriver . Create ( new UDPNetworkInterface ( ) , m_NetworkSettings ) ;
1754+ driver = NetworkDriver . Create ( private new UDPNetworkInterface( ) , m_NetworkSettings) ;
17421755#endif
17431756 }
17441757#else
@@ -1755,10 +1768,10 @@ public void CreateDriver(UnityTransport transport, out NetworkDriver driver,
17551768 out unreliableSequencedFragmentedPipeline ,
17561769 out reliableSequencedPipeline ) ;
17571770#else
1758- SetupPipelinesForUtp2 ( driver ,
1759- out unreliableFragmentedPipeline ,
1760- out unreliableSequencedFragmentedPipeline ,
1761- out reliableSequencedPipeline ) ;
1771+ SetupPipelinesForUtp2 ( driver ,
1772+ out unreliableFragmentedPipeline ,
1773+ out unreliableSequencedFragmentedPipeline ,
1774+ out reliableSequencedPipeline ) ;
17621775#endif
17631776 }
17641777
@@ -1826,74 +1839,74 @@ private void SetupPipelinesForUtp2(NetworkDriver driver,
18261839 out NetworkPipeline unreliableFragmentedPipeline ,
18271840 out NetworkPipeline unreliableSequencedFragmentedPipeline ,
18281841 out NetworkPipeline reliableSequencedPipeline )
1829- {
1842+ {
18301843
1831- unreliableFragmentedPipeline = driver . CreatePipeline (
1832- typeof ( FragmentationPipelineStage )
1844+ unreliableFragmentedPipeline = driver . CreatePipeline (
1845+ typeof ( FragmentationPipelineStage )
18331846#if UNITY_MP_TOOLS_NETSIM_IMPLEMENTATION_ENABLED
1834- , typeof ( SimulatorPipelineStage )
1847+ , typeof ( SimulatorPipelineStage )
18351848#endif
18361849#if MULTIPLAYER_TOOLS_1_0_0_PRE_7
18371850 , typeof ( NetworkMetricsPipelineStage )
18381851#endif
1839- ) ;
1852+ ) ;
18401853
1841- unreliableSequencedFragmentedPipeline = driver . CreatePipeline (
1842- typeof ( FragmentationPipelineStage ) ,
1843- typeof ( UnreliableSequencedPipelineStage )
1854+ unreliableSequencedFragmentedPipeline = driver . CreatePipeline (
1855+ typeof ( FragmentationPipelineStage ) ,
1856+ typeof ( UnreliableSequencedPipelineStage )
18441857#if UNITY_MP_TOOLS_NETSIM_IMPLEMENTATION_ENABLED
1845- , typeof ( SimulatorPipelineStage )
1858+ , typeof ( SimulatorPipelineStage )
18461859#endif
18471860#if MULTIPLAYER_TOOLS_1_0_0_PRE_7
18481861 , typeof ( NetworkMetricsPipelineStage )
18491862#endif
1850- ) ;
1863+ ) ;
18511864
1852- reliableSequencedPipeline = driver . CreatePipeline (
1853- typeof ( ReliableSequencedPipelineStage )
1865+ reliableSequencedPipeline = driver . CreatePipeline (
1866+ typeof ( ReliableSequencedPipelineStage )
18541867#if UNITY_MP_TOOLS_NETSIM_IMPLEMENTATION_ENABLED
1855- , typeof ( SimulatorPipelineStage )
1868+ , typeof ( SimulatorPipelineStage )
18561869#endif
18571870#if MULTIPLAYER_TOOLS_1_0_0_PRE_7
18581871 , typeof ( NetworkMetricsPipelineStage )
18591872#endif
1860- ) ;
1861- }
1873+ ) ;
1874+ }
18621875#endif
1863- // -------------- Utility Types -------------------------------------------------------------------------------
1876+ // -------------- Utility Types -------------------------------------------------------------------------------
18641877
18651878
1866- /// <summary>
1867- /// Cached information about reliability mode with a certain client
1868- /// </summary>
1869- private struct SendTarget : IEquatable < SendTarget >
1870- {
1871- public readonly ulong ClientId ;
1872- public readonly NetworkPipeline NetworkPipeline ;
1879+ /// <summary>
1880+ /// Cached information about reliability mode with a certain client
1881+ /// </summary>
1882+ private struct SendTarget : IEquatable < SendTarget >
1883+ {
1884+ public readonly ulong ClientId ;
1885+ public readonly NetworkPipeline NetworkPipeline ;
18731886
1874- public SendTarget ( ulong clientId , NetworkPipeline networkPipeline )
1875- {
1876- ClientId = clientId ;
1877- NetworkPipeline = networkPipeline ;
1878- }
1887+ public SendTarget ( ulong clientId , NetworkPipeline networkPipeline )
1888+ {
1889+ ClientId = clientId ;
1890+ NetworkPipeline = networkPipeline ;
1891+ }
18791892
1880- public bool Equals ( SendTarget other )
1881- {
1882- return ClientId == other . ClientId && NetworkPipeline . Equals ( other . NetworkPipeline ) ;
1883- }
1893+ public bool Equals ( SendTarget other )
1894+ {
1895+ return ClientId == other . ClientId && NetworkPipeline . Equals ( other . NetworkPipeline ) ;
1896+ }
18841897
1885- public override bool Equals ( object obj )
1886- {
1887- return obj is SendTarget other && Equals ( other ) ;
1888- }
1898+ public override bool Equals ( object obj )
1899+ {
1900+ return obj is SendTarget other && Equals ( other ) ;
1901+ }
18891902
1890- public override int GetHashCode ( )
1891- {
1892- unchecked
1893- {
1894- return ( ClientId . GetHashCode ( ) * 397 ) ^ NetworkPipeline . GetHashCode ( ) ;
1895- }
1896- }
1903+ public override int GetHashCode ( )
1904+ {
1905+ unchecked
1906+ {
1907+ return ( ClientId . GetHashCode ( ) * 397 ) ^ NetworkPipeline . GetHashCode ( ) ;
18971908 }
18981909 }
1910+ }
1911+ }
18991912}
0 commit comments