Documentation 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.
TerbinExecutor is the bridge between your code and Terbin’s packet routing engine. It provides two things: a one-line startup call (Register) that scans any assembly for [TerbinExecutable]-decorated methods and feeds them into TerbinExecutableManager, and an Init method that connects a TerbinCommunicator so that response packets can be routed back through GiveResponse. In practice, most services only ever call TerbinExecutor.Register(Assembly.GetExecutingAssembly()) once at startup and let the attribute-based declarative system handle the rest.
TerbinExecutor (static class)
TerbinExecutor holds a single nullable TerbinCommunicator? reference (_communicator) that is populated by Init. All other behaviour is stateless — the routing state lives inside TerbinExecutableManager.
Register
pAssembly for static methods decorated with [TerbinExecutable] and registers them into TerbinExecutableManager. This is the primary public entry point for application-level handler registration.
The assembly to scan. Pass
Assembly.GetExecutingAssembly() from your service’s Worker or startup code.Worker.cs:
RegisterInternal
TerbinLibrary itself — Load, Solicit, Prolong, Response, etc. Called automatically by Init. You do not need to call this manually; it is documented here for completeness.
Init
TerbinCommunicator constructor to complete the two-way wiring:
- Calls
RegisterInternal()to ensure the library’s own protocol handlers are loaded. - Stores the communicator reference so the built-in
Responsehandler can callpCommunicator.GiveResponse(...)when a response packet arrives.
The active communicator instance. After
Init, the Response handler forwards response packets back to any in-flight request awaiting a reply.Built-in Protocol Handlers
TerbinExecutor itself carries several [TerbinExecutable]-decorated static methods for core protocol operations:
Load — CodeTerbinProtocol.Load (2)
Load — CodeTerbinProtocol.Load (2)
Stores incoming payload fragments in
TerbinMemoryManager. Handles both ordered fragments (OrderRequest > 0) and single-shot overwrites (OrderRequest == 0). Returns null (no reply required for data loads).Solicit — CodeTerbinProtocol.Solicit (4)
Solicit — CodeTerbinProtocol.Solicit (4)
When
pHead.IdMemory == CodeTerbinMemory.New, allocates a free memory slot and returns its ID as a single-byte payload. Used by clients to request a fresh memory region before sending fragmented data.Prolong — CodeTerbinProtocol.Prolong (3)
Prolong — CodeTerbinProtocol.Prolong (3)
Deserializes a
ushort request ID from the payload and calls _communicator?.GiveProlong(id) to extend the timeout window of an in-flight request. Returns null.Response — CodeTerbinProtocol.Response (1)
Response — CodeTerbinProtocol.Response (1)
Handles response packets coming back from the remote side. If
pHead.Status == CodeStatus.ExecutionException the exception DTO is deserialized and printed to the error console. Otherwise the packet is forwarded to _communicator?.GiveResponse(...) so the caller’s await can complete.TerbinExecutableHelper (static utility class)
TerbinExecutableHelper contains the reflection logic that both ExecutableDispatcher.RegisterFromAssembly and TerbinExecutableManagerSimple.RegisterFromAssembly delegate to. You will not normally call it directly, but understanding it clarifies what happens during the scan.
RegisterFromAssembly<T, E>
pAssembly, then over every public, non-public, and static method, looking for custom attributes of type T. For each match it:
- Prints a yellow console warning for methods that also carry
[Obsolete], but continues to register them. - Calls
IsFirmParameters— validates that the method has exactly three parameters:Header,byte[],CancellationToken. - Calls
IsFirmReturn— validates that the return type isTask<InfoResponse?>. - If both checks pass, creates a typed delegate via
Delegate.CreateDelegate. - Calls
pExecutor.Register(attr, (h, b, ct) => del(h, b, ct))for every attribute instance on the method (supportingAllowMultiple).
TerbinExecutableDelegate exactly.
ExecutionList
ExecutableDispatcher.DispatchAsync when at least one handler is registered for a key. All handlers are started concurrently; Task.WhenAny is used in a loop to process completions in order. The first handler that returns a non-null InfoResponse short-circuits the loop — the result is returned immediately and remaining tasks are abandoned.
The ordered list of delegates registered for the action key.
Forwarded unchanged to every handler.
Forwarded unchanged to every handler.
The per-action CTS.
pToken.Token is passed to every handler so all of them share the same cancellation scope.Registration Flow Diagram
TerbinExecutableManagerSimple (obsolete)
TerbinExecutableManagerSimple is a simpler single-byte-key variant of the registration system, backed by ExecutableDispatcherSimple. It uses a ConcurrentDictionary<byte, …> instead of ConcurrentDictionary<ByteArrayKey, …> and supports only a single action byte rather than multi-byte composite keys. Both classes are marked [Obsolete] and most of their methods throw NotImplementedException. They exist for historical reference only — use TerbinExecutableManager and ExecutableDispatcher for all new code.See Also
[TerbinExecutable]Attribute — how to annotate handler methods.- ExecutableDispatcher — the thread-safe routing engine that stores and invokes handlers.