You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, the AMF3 serialization always writes the strings by value. This can be costly with an over the wire transfer with lots of data.
Describe the solution you'd like
An optimization would be, like the Deserializer, a serializer class which keeps track of what strings have been written and utilizes the reference part of the format. The following is a method of accomplishing this which will work:
classWriter {
map<string, int> referenceTracker;
voidSerialize(string str, RakNet::BitStream* stream) {
if (str.empty()) {
stream->Write29bitInt(1); // empty strings are never passed by referenecereturn;
}
auto itr = referenceTracker.find(str);
if (itr != referenceTracker.end()) {
stream->Write29bitInt((itr->second << 1UL)); // shift left 1 and mark lowest bit with 0 to denote this is a reference to the previous string of number x.return;
}
auto size = referenceTracker.size(); // size pre-insert is the reference number
referenceTracker[str] = size; // assign the number to this string value
stream->Write29bitint((str.size() << 1) | 1); // bit 1 is the flag bit for a string size
stream->Write(str.c_str(), str.size()); // write the string to the stream
}
}
the above code is simply an example and not representative of what a final product should look like and is mostly to get the idea across.
Repository breaking implications
Could break UI msgs
Describe alternatives you've considered
becoming one with AMF
Additional context
No response
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem?
Currently, the AMF3 serialization always writes the strings by value. This can be costly with an over the wire transfer with lots of data.
Describe the solution you'd like
An optimization would be, like the Deserializer, a serializer class which keeps track of what strings have been written and utilizes the reference part of the format. The following is a method of accomplishing this which will work:
the above code is simply an example and not representative of what a final product should look like and is mostly to get the idea across.
Repository breaking implications
Could break UI msgs
Describe alternatives you've considered
becoming one with AMF
Additional context
No response
The text was updated successfully, but these errors were encountered: