FragmentBuffer
The FragmentBuffer
class stores the fragments of a message for reassembly. It is used by the StreamConnection class.
Constructors
FragmentBuffer new
FragmentBuffer.new = function(timeout: number?): FragmentBuffer
Returns a new FragmentBuffer object with the given timeout. If timeout
is not provided, 10 seconds will be used.
Arguments:
number?
timeout
- The timeout in seconds.
Properties
number Timeout
The buffer timeout in seconds. If a new fragment is not received within this time, the buffer will be cleared to prevent memory leaks.
number CutOffTime
The time at which the buffer will be cleared if no new fragments are received.
number TotalFragments
The number of fragments the full message is expected to have.
{CsrpMessage} Fragments
The received fragments of the message. The key is the fragment index and the value is the message fragment object.
Events
RBXScriptSignal TimedOut
Fired when the buffer times out.
Methods
void Add
FragmentBuffer:Add = function(fragment: CsrpMessage)
Adds a fragment to the buffer and resets the timeout timer.
Arguments:
CsrpMessage
fragment
- The fragment to add.
boolean IsComplete
FragmentBuffer:IsComplete = function(): boolean
Returns whether the buffer contains all of the fragments of the message.
void Disable
FragmentBuffer:Disable = function()
Disables the buffer. This will prevent additional fragments from being added to the buffer and will stop the timeout timer.
void Dispose
FragmentBuffer:Dispose = function()
Disables and clears the buffer.