When using MessagingService:PublishAsync(topic, value)
we are limited to ~1kb of data per request. How can we check the data size of these values?
e.g.
getSize(("a"):rep(64))
64 characters
The values may be tables of unpredictable data sizes.
When using MessagingService:PublishAsync(topic, value)
we are limited to ~1kb of data per request. How can we check the data size of these values?
e.g.
getSize(("a"):rep(64))
64 characters
The values may be tables of unpredictable data sizes.
Perhaps you could loop through the table and have a reference table of how many bytes that datatype takes up?
local reference = {
["string"] = 1,
["number"] = 2, --It's 2 bytes right?
}
local amount = 0
if typeof(data) == "table" then
for _, v in pairs(data) do
amount = amount + reference[typeof(v)]
end
else
amount = reference[typeof(data)]
end
local HttpService = game:GetService("HttpService")
local data = 'okaaaaaaaaaaaahhhhhy'
print(#HttpService:JSONEncode(data))
-- > 22
local data2 = {'cat','dog','bird','tiger'}
print(#HttpService:JSONEncode(data2))
-- > 28