Sending Bytes over remote event or The data itself?

I’m curious if the rule I’m giving myself is better on performance. The title basically gives it away.

For those of you that don’t know what bytes this post may not pertain to you.

Heres a small code sample of what I mean.

This is how the client reads in incoming byte events…

PacketEvent.OnClientEvent:Connect(function(opcode, buffer)

-- print("opcode")

ops[opcode]:HandleBuffer(buffer)

end)

Server also has one similar to it… which looks like

PacketEvent.OnServerEvent:Connect(function(Client, op, buffer)

      --print("opcode coming in ", op)

      opcodes[op]:HandleBuffer(Client, buffer)

end)

This is how my client sends data to the server

function module:SendContainerSlotClick(slotClicked, containerId)

       local buffer = ByteBuffer.Create()

       buffer:WriteSigned(64, slotClicked)

       buffer:WriteSigned(64, containerId)

       PacketEvent:FireServer(SendContainerClick, buffer:ToBase64())

end

What are your thoughts :thinking:

Is this far more effective than, sending the entire data as its own parameter value during its FireEvent?

The data is already sent as its byte representation to the server regularly. What are you trying to accomplish?

Say for instance i was sending a Vector3 object, it sends the byte value for the entire object Vs sending byte values for x y z values. Having more control of what kind of byte and what size the byte is.

A Vector3… only has its X Y Z values. That and a tag is all that’s sent over the network, you would be sending more data if you sent it in string representation like you propose.

A Vector3 is a vector.new(x, y z) which creates an Object of itself. Which also contains things like .Magnitude, and other vector properties/functions meaning you’d also be sending those during the object value being sent.

meaning your’e sending extra bytes when its not relevant.

Vector3 is sent over only as X, Y, Z. Everything else can be calculated from these values or whatever else.

How about things like number and size of number bytes 8 bit number vs 16 bit vs 32 etc signed unsigned

Roblox probably just chucks em all at 64 bit right?

There seems to be a fundamental misunderstanding of how ROBLOX replicates values and properties. Your attempt to [give] “better on performance” is going to ultimately drastically reduce the actual performance, as the Lua overhead is going to be much greater than the transmission time for the minuscule amount of data that is saved through encoding the data into a smaller datatype.

Bandwidth is cheap these days. No need to write an entire system to encode your Vectors into 8-bit chars streams.

2 Likes

So its recommended to just sent all the values as their own just to save the time of converting to base64 and then converting back into actual data representation hmm

Alright seems like theirs enough reason to switch this up.