Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions com.unity.multiplayer.mlapi/Runtime/Core/MessageBatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class MessageBatcher
{
public class SendStream
{
public FrameQueueItem Item;
public string channel;
public PooledBitStream Stream = PooledBitStream.Get();
public bool Empty = true;
}
Expand Down Expand Up @@ -114,7 +114,7 @@ public void QueueItem(in FrameQueueItem item)
if (SendDict[clientId].Empty)
{
SendDict[clientId].Empty = false;
SendDict[clientId].Item = item;
SendDict[clientId].channel = item.Channel;
Writer.SetStream(SendDict[clientId].Stream);

Writer.WriteBit(false); // Encrypted
Expand Down Expand Up @@ -187,6 +187,7 @@ public void SendItems(int threshold, SendCallbackType sendCallback)
/// <param name="receiveTime"> the packet receive time to pass back to callback</param>
public int ReceiveItems(in BitStream messageStream, ReceiveCallbackType receiveCallback, MLAPI.RPCQueueManager.QueueItemType messageType, ulong clientId, float receiveTime)
{
using PooledBitStream copy = PooledBitStream.Get();
do
{
// read the length of the next RPC
Expand All @@ -200,7 +201,6 @@ public int ReceiveItems(in BitStream messageStream, ReceiveCallbackType receiveC

// copy what comes after current stream position
long pos = messageStream.Position;
BitStream copy = PooledBitStream.Get();
copy.SetLength(rpcSize);
copy.Position = 0;
Buffer.BlockCopy(messageStream.GetBuffer(), (int)pos, copy.GetBuffer(), 0, rpcSize);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ internal class RPCQueueProcessing
#endif
// Batcher object used to manage the RPC batching on the send side
private MessageBatcher batcher = new MessageBatcher();
private int BatchThreshold = 1000;
private int BatchThreshold = 512;
Comment thread
jeffreyrainy marked this conversation as resolved.

//NSS-TODO: Need to determine how we want to handle all other MLAPI send types
//Temporary place to keep internal MLAPI messages
Expand Down Expand Up @@ -208,7 +208,7 @@ private static void SendCallback(ulong clientId, MLAPI.MessageBatcher.SendStream
ArraySegment<byte> sendBuffer = new ArraySegment<byte>(bytes, 0, length);

NetworkingManager.Singleton.NetworkConfig.NetworkTransport.Send(clientId, sendBuffer,
string.IsNullOrEmpty(sendStream.Item.Channel) ? "MLAPI_DEFAULT_MESSAGE" : sendStream.Item.Channel);
string.IsNullOrEmpty(sendStream.channel) ? "MLAPI_DEFAULT_MESSAGE" : sendStream.channel);
}
}
}