When a payload exceedsDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/FarlandsModdingTeam/TerbinProyect/llms.txt
Use this file to discover all available pages before exploring further.
TerbinProtocol.MAX_PLD (65,520 bytes), Terbin splits it into fragments and sends them as separate packets. The receiver side uses TerbinMemory slots — managed by TerbinMemoryManager — to accumulate those fragments before reassembling the complete payload. Application code does not need to interact with these classes directly; TerbinCommunicator handles the entire lifecycle automatically.
Slots with IDs ≤
TerbinProtocol.RESERVE_MEMORY (9) are reserved for internal protocol operations. TerbinMemoryHelper.TryReleaseMemory refuses to release reserved slots.TerbinMemory
A single fragment accumulation slot.Properties
The slot’s identifier, assigned when the slot is created in the pool.
The request ID currently using this slot. A value of
CodeTerbinMemory.NotAsign (1) means the slot is free.Computed:
true when IdRequest != (ushort)CodeTerbinMemory.NotAsign.Events
Fires after each
AddFragment() call. Useful for monitoring assembly progress.Fires when
Release() is called. Clears OnAdd first, then invokes OnRelease, then calls Clear().Methods
Adds a fragment at the given order index in a thread-safe manner (locks
_fragments). Duplicate order keys are silently ignored. Fires OnAdd.Sorts all stored fragments by order key, validates there are no gaps in the sequence, then concatenates them into a single
byte[]. Returns (true, None) on success or (false, OrderMismatch) if a fragment is missing.Resets
IdRequest to NotAsign, clears OnAdd, fires OnRelease, and calls Clear().Discards all stored fragments and resets
_totalSize to 0. Thread-safe via lock.TerbinMemoryManager (Static)
The global pool ofTerbinMemory slots backed by a ConcurrentDictionary<byte, TerbinMemory>.
Methods
Scans
Containers for any slot where IsOcupated == false. If none is found, creates a new slot with a random byte ID via MiniID.NewB. Returns the slot’s byte ID.Stores a fragment in the slot identified by
pIdMemory, creating the slot if it does not exist yet.Creates a fresh slot and forcibly replaces any existing entry at
pIdMemory via AddOrUpdate.If a slot exists, calls
Clear() on it and adds the fragment. Otherwise delegates to Store.Retrieves the complete reassembled byte array from the slot by calling
TryGetFullData. Returns (false, ValueOutOfRange) if the slot does not exist.Returns the raw
TerbinMemory instance for a slot without reassembling it.Calls
TerbinMemory.Release() on the slot, marking it free. Returns true if the slot existed.Permanently removes the slot from
Containers. Returns true if it was present.TerbinMemoryHelper (Static)
High-level helpers used internally byTerbinCommunicator.handleReceive.
Methods
The main entry point for the receive loop.
- If
pCapsule.Head.OrderRequest != FINAL_PACKET: returns the packet’s ownPayloaddirectly (single packet, no memory slot involved). - If
pCapsule.Head.OrderRequest == FINAL_PACKET: callsTryAssembleStream, thenTryReleaseMemory. ReturnsNoneon success, theTerbinErrorCodefromTryAssembleStreamon assembly failure, orMemoryReleaseFailedif the slot could not be freed.
Calls
TerbinMemoryManager.TryGetResult to get the fragments, then concatenates them with pCapsule.Payload via CombinePayload. Returns the TerbinErrorCode from the manager.Concatenates
pBytes (previously stored fragments) and pCapsule.Payload (the final packet’s payload) into a single byte[].Refuses to release slots with IDs ≤
TerbinProtocol.RESERVE_MEMORY (9). For valid IDs, delegates to TerbinMemoryManager.Release.