IJsLauw:
@CosmicStud I’m doing the above, except my data is already a string (gziped json). And when the writeSize even goes around 1772 I get the OverflowException
OverflowException: Writing past the end of the buffer
Here’s my code:
public void SendNamedMessage(CustomNamedMessage customNamedMessage, string message)
{
//Write
var writeSize = FastBufferWriter.GetWriteSize(message); //Get size of bytes to allocate network buffer
using FastBufferWriter writer = new FastBufferWriter(writeSize, Allocator.Temp);
Debug.LogFormat("writer writeSize {0} vs maxCap {1} ", writeSize, writer.MaxCapacity);
writer.WriteValueSafe(message); //Write to buffer
NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage(customNamedMessage.ToString(), NetworkManager.Singleton.ServerClientId, writer,
NetworkDelivery.Reliable);
}
Any ideas on what to try next?
Change the network delivery to a fragmented style.
NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage(customNamedMessage.ToString(), NetworkManager.Singleton.ServerClientId, writer,
NetworkDelivery.ReliableFragmentedSequenced);
If you need to use the other network deliveries, make sure your data size is less then 1084 bytes, so you’d have to split the string into segments and send that. Otherwise the fragmented size can send upwards to 59392 bytes with Unet transport.
2 Likes