11using System ;
22using System . Collections . Generic ;
33using UnityEngine ;
4+ using UnityEngine . Serialization ;
45using NetcodeNetworkEvent = Unity . Netcode . NetworkEvent ;
56using TransportNetworkEvent = Unity . Networking . Transport . NetworkEvent ;
67using Unity . Collections . LowLevel . Unsafe ;
@@ -85,8 +86,8 @@ private enum State
8586 }
8687
8788 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 ;
9091
9192 private static ConnectionAddressData s_DefaultConnectionAddressData = new ConnectionAddressData ( )
9293 { Address = "127.0.0.1" , Port = 7777 } ;
@@ -103,9 +104,9 @@ private enum State
103104 "Basically this is how many packets can be sent/received in a single update/frame." ) ]
104105 [ SerializeField ] private int m_MaxPacketQueueSize = InitialMaxPacketQueueSize ;
105106
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 ;
109110
110111 [ Tooltip ( "The maximum size in bytes of the transport send queue. The send queue accumulates messages for " +
111112 "batching and stores messages when other internal send queues are full. If you routinely observe an " +
@@ -639,9 +640,9 @@ public override void Initialize()
639640
640641 m_NetworkSettings = new NetworkSettings ( Allocator . Persistent ) ;
641642
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
643644 // 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 ;
645646
646647 m_NetworkSettings
647648 . WithFragmentationStageParameters ( payloadCapacity : fragmentationCapacity )
@@ -660,9 +661,9 @@ public override NetcodeNetworkEvent PollEvent(out ulong clientId, out ArraySegme
660661
661662 public override void Send ( ulong clientId , ArraySegment < byte > payload , NetworkDelivery networkDelivery )
662663 {
663- if ( payload . Count > m_SendQueueBatchSize )
664+ if ( payload . Count > m_MaxPayloadSize )
664665 {
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 } ).") ;
666667 return ;
667668 }
668669
@@ -671,7 +672,7 @@ public override void Send(ulong clientId, ArraySegment<byte> payload, NetworkDel
671672 var sendTarget = new SendTarget ( clientId , pipeline ) ;
672673 if ( ! m_SendQueue . TryGetValue ( sendTarget , out var queue ) )
673674 {
674- queue = new BatchedSendQueue ( Math . Max ( m_MaxSendQueueSize , m_SendQueueBatchSize ) ) ;
675+ queue = new BatchedSendQueue ( Math . Max ( m_MaxSendQueueSize , m_MaxPayloadSize ) ) ;
675676 m_SendQueue . Add ( sendTarget , queue ) ;
676677 }
677678
0 commit comments