1
1
using System ;
2
2
using System . Collections . Generic ;
3
3
using UnityEngine ;
4
+ using UnityEngine . Serialization ;
4
5
using NetcodeNetworkEvent = Unity . Netcode . NetworkEvent ;
5
6
using TransportNetworkEvent = Unity . Networking . Transport . NetworkEvent ;
6
7
using Unity . Collections . LowLevel . Unsafe ;
@@ -85,8 +86,8 @@ private enum State
85
86
}
86
87
87
88
public const int InitialMaxPacketQueueSize = 128 ;
88
- public const int InitialBatchQueueSize = 6 * 1024 ;
89
- public const int InitialMaxSendQueueSize = 16 * InitialBatchQueueSize ;
89
+ public const int InitialMaxPayloadSize = 6 * 1024 ;
90
+ public const int InitialMaxSendQueueSize = 16 * InitialMaxPayloadSize ;
90
91
91
92
private static ConnectionAddressData s_DefaultConnectionAddressData = new ConnectionAddressData ( )
92
93
{ Address = "127.0.0.1" , Port = 7777 } ;
@@ -103,9 +104,9 @@ private enum State
103
104
"Basically this is how many packets can be sent/received in a single update/frame." ) ]
104
105
[ SerializeField ] private int m_MaxPacketQueueSize = InitialMaxPacketQueueSize ;
105
106
106
- [ Tooltip ( "The maximum size of a batched send. The send queue accumulates messages and batches them together " +
107
- "up to this size. This is effectively the maximum payload size that can be handled by the transport. ") ]
108
- [ SerializeField ] private int m_SendQueueBatchSize = InitialBatchQueueSize ;
107
+ [ Tooltip ( "The maximum size of a payload that can be handled by the transport." ) ]
108
+ [ FormerlySerializedAs ( "m_SendQueueBatchSize ") ]
109
+ [ SerializeField ] private int m_MaxPayloadSize = InitialMaxPayloadSize ;
109
110
110
111
[ Tooltip ( "The maximum size in bytes of the transport send queue. The send queue accumulates messages for " +
111
112
"batching and stores messages when other internal send queues are full. If you routinely observe an " +
@@ -639,9 +640,9 @@ public override void Initialize()
639
640
640
641
m_NetworkSettings = new NetworkSettings ( Allocator . Persistent ) ;
641
642
642
- // If the user sends a message of exactly m_SendQueueBatchSize in length, we need to
643
+ // If the user sends a message of exactly m_MaxPayloadSize in length, we need to
643
644
// account for the overhead of its length when we store it in the send queue.
644
- var fragmentationCapacity = m_SendQueueBatchSize + BatchedSendQueue . PerMessageOverhead ;
645
+ var fragmentationCapacity = m_MaxPayloadSize + BatchedSendQueue . PerMessageOverhead ;
645
646
646
647
m_NetworkSettings
647
648
. WithFragmentationStageParameters ( payloadCapacity : fragmentationCapacity )
@@ -660,9 +661,9 @@ public override NetcodeNetworkEvent PollEvent(out ulong clientId, out ArraySegme
660
661
661
662
public override void Send ( ulong clientId , ArraySegment < byte > payload , NetworkDelivery networkDelivery )
662
663
{
663
- if ( payload . Count > m_SendQueueBatchSize )
664
+ if ( payload . Count > m_MaxPayloadSize )
664
665
{
665
- Debug . LogError ( $ "Payload of size { payload . Count } larger than configured 'Send Queue Batch Size' ({ m_SendQueueBatchSize } ).") ;
666
+ Debug . LogError ( $ "Payload of size { payload . Count } larger than configured 'Max Payload Size' ({ m_MaxPayloadSize } ).") ;
666
667
return ;
667
668
}
668
669
@@ -671,7 +672,7 @@ public override void Send(ulong clientId, ArraySegment<byte> payload, NetworkDel
671
672
var sendTarget = new SendTarget ( clientId , pipeline ) ;
672
673
if ( ! m_SendQueue . TryGetValue ( sendTarget , out var queue ) )
673
674
{
674
- queue = new BatchedSendQueue ( Math . Max ( m_MaxSendQueueSize , m_SendQueueBatchSize ) ) ;
675
+ queue = new BatchedSendQueue ( Math . Max ( m_MaxSendQueueSize , m_MaxPayloadSize ) ) ;
675
676
m_SendQueue . Add ( sendTarget , queue ) ;
676
677
}
677
678
0 commit comments