@@ -544,46 +544,13 @@ private bool ServerBindAndListen(NetworkEndpoint endPoint)
544
544
return true ;
545
545
}
546
546
547
- private static RelayAllocationId ConvertFromAllocationIdBytes ( byte [ ] allocationIdBytes )
548
- {
549
- unsafe
550
- {
551
- fixed ( byte * ptr = allocationIdBytes )
552
- {
553
- return RelayAllocationId . FromBytePointer ( ptr , allocationIdBytes . Length ) ;
554
- }
555
- }
556
- }
557
-
558
- private static RelayHMACKey ConvertFromHMAC ( byte [ ] hmac )
559
- {
560
- unsafe
561
- {
562
- fixed ( byte * ptr = hmac )
563
- {
564
- return RelayHMACKey . FromBytePointer ( ptr , RelayHMACKey . k_Length ) ;
565
- }
566
- }
567
- }
568
-
569
- private static RelayConnectionData ConvertConnectionData ( byte [ ] connectionData )
570
- {
571
- unsafe
572
- {
573
- fixed ( byte * ptr = connectionData )
574
- {
575
- return RelayConnectionData . FromBytePointer ( ptr , RelayConnectionData . k_Length ) ;
576
- }
577
- }
578
- }
579
-
580
547
private void SetProtocol ( ProtocolType inProtocol )
581
548
{
582
549
m_ProtocolType = inProtocol ;
583
550
}
584
551
585
552
/// <summary>Set the relay server data for the server.</summary>
586
- /// <param name="ipv4Address">IP address of the relay server.</param>
553
+ /// <param name="ipv4Address">IP address or hostname of the relay server.</param>
587
554
/// <param name="port">UDP port of the relay server.</param>
588
555
/// <param name="allocationIdBytes">Allocation ID as a byte array.</param>
589
556
/// <param name="keyBytes">Allocation key as a byte array.</param>
@@ -592,33 +559,8 @@ private void SetProtocol(ProtocolType inProtocol)
592
559
/// <param name="isSecure">Whether the connection is secure (uses DTLS).</param>
593
560
public void SetRelayServerData ( string ipv4Address , ushort port , byte [ ] allocationIdBytes , byte [ ] keyBytes , byte [ ] connectionDataBytes , byte [ ] hostConnectionDataBytes = null , bool isSecure = false )
594
561
{
595
- RelayConnectionData hostConnectionData ;
596
-
597
- if ( ! NetworkEndpoint . TryParse ( ipv4Address , port , out var serverEndpoint ) )
598
- {
599
- Debug . LogError ( $ "Invalid address { ipv4Address } :{ port } ") ;
600
-
601
- // We set this to default to cause other checks to fail to state you need to call this
602
- // function again.
603
- m_RelayServerData = default ;
604
- return ;
605
- }
606
-
607
- var allocationId = ConvertFromAllocationIdBytes ( allocationIdBytes ) ;
608
- var key = ConvertFromHMAC ( keyBytes ) ;
609
- var connectionData = ConvertConnectionData ( connectionDataBytes ) ;
610
-
611
- if ( hostConnectionDataBytes != null )
612
- {
613
- hostConnectionData = ConvertConnectionData ( hostConnectionDataBytes ) ;
614
- }
615
- else
616
- {
617
- hostConnectionData = connectionData ;
618
- }
619
-
620
- m_RelayServerData = new RelayServerData ( ref serverEndpoint , 0 , ref allocationId , ref connectionData , ref hostConnectionData , ref key , isSecure ) ;
621
-
562
+ var hostConnectionData = hostConnectionDataBytes ?? connectionDataBytes ;
563
+ m_RelayServerData = new RelayServerData ( ipv4Address , port , allocationIdBytes , connectionDataBytes , hostConnectionData , keyBytes , isSecure ) ;
622
564
SetProtocol ( ProtocolType . RelayUnityTransport ) ;
623
565
}
624
566
@@ -631,7 +573,7 @@ public void SetRelayServerData(RelayServerData serverData)
631
573
}
632
574
633
575
/// <summary>Set the relay server data for the host.</summary>
634
- /// <param name="ipAddress">IP address of the relay server.</param>
576
+ /// <param name="ipAddress">IP address or hostname of the relay server.</param>
635
577
/// <param name="port">UDP port of the relay server.</param>
636
578
/// <param name="allocationId">Allocation ID as a byte array.</param>
637
579
/// <param name="key">Allocation key as a byte array.</param>
@@ -643,7 +585,7 @@ public void SetHostRelayData(string ipAddress, ushort port, byte[] allocationId,
643
585
}
644
586
645
587
/// <summary>Set the relay server data for the host.</summary>
646
- /// <param name="ipAddress">IP address of the relay server.</param>
588
+ /// <param name="ipAddress">IP address or hostname of the relay server.</param>
647
589
/// <param name="port">UDP port of the relay server.</param>
648
590
/// <param name="allocationId">Allocation ID as a byte array.</param>
649
591
/// <param name="key">Allocation key as a byte array.</param>
0 commit comments