Files
2026-04-17 14:55:32 -04:00

59 lines
4.0 KiB
Markdown

---
source_files:
- Common/DTS.Common/Enums/Communication/CommunicationConstantsAndEnums.cs
generated_at: "2026-04-16T03:21:11.012586+00:00"
model: "Qwen/Qwen3-Coder-Next-FP8"
schema_version: 1
sha256: "009da99cbbcb47bb"
---
# Communication
### **1. Purpose**
This module defines core enumerations and delegates used for representing the outcomes of communication operations and for implementing callback mechanisms in the DTS communication subsystem. It serves as a shared contract between communication implementations and higher-level consumers, ensuring consistent reporting of connection, disconnection, send, receive, and cancellation events across the system.
---
### **2. Public Interface**
- **`CommunicationResult` enum**
A strongly-typed enumeration of possible outcomes for communication operations. Each value corresponds to a specific state or result of a communication action:
- `ConnectOK`, `ConnectFailed`, `ConnectTimeout` — outcomes of a connection attempt.
- `DisconnectOK`, `DisconnectFailed`, `DisconnectTimeout` — outcomes of a disconnection attempt.
- `SendOK`, `SendFailed`, `SendTimeout` — outcomes of a send operation.
- `ReceiveOK`, `ReceiveFailed`, `ReceiveTimeout` — outcomes of a receive operation.
- `Canceled` — indicates the operation was canceled (e.g., by user or timeout).
- **`CommunicationCallback` delegate**
```csharp
public delegate bool CommunicationCallback(ICommunicationReport report);
```
A function pointer type used to register callbacks that process communication reports. It takes an `ICommunicationReport` instance as input and returns a `bool` (typically indicating whether the callback handled the report successfully or whether further processing should continue).
---
### **3. Invariants**
- The `CommunicationResult` enum values are exhaustive for reporting the status of communication operations; no other result codes are defined in this module.
- Callbacks registered via `CommunicationCallback` must accept and process an `ICommunicationReport` instance; the return value semantics (e.g., `true` = handled, `false` = not handled) are implied by usage but not enforced by this module.
- No runtime validation or normalization of enum values is performed in this module; consumers are responsible for interpreting results consistently.
---
### **4. Dependencies**
- **Dependencies *of* this module**:
- `DTS.Common.Interface.Communication.ICommunicationReport` — referenced by the `CommunicationCallback` delegate. This interface is expected to define the contract for communication reports (e.g., containing result type, timestamp, payload, etc.), but its definition is not included here.
- **Dependencies *on* this module**:
- Any module implementing or consuming communication operations (e.g., network drivers, protocol handlers, UI components) is expected to reference this module to interpret operation outcomes and register callbacks.
- The namespace `DTS.Common.Enums.Communication` suggests this is part of a shared common library (`DTS.Common`), implying usage across multiple components in the DTS ecosystem.
---
### **5. Gotchas**
- **No explicit mapping between `CommunicationResult` and `ICommunicationReport` is defined here** — consumers must infer how report contents (e.g., `ICommunicationReport.Result`) correspond to `CommunicationResult` enum values.
- **`Canceled` is a generic result** — it does not specify *which* operation was canceled (e.g., connect vs. send); callers must inspect the report context (e.g., via `ICommunicationReport.OperationType`, if defined) to disambiguate.
- **Return value semantics of `CommunicationCallback` are not standardized in this file** — the meaning of `true`/`false` depends on the calling convention (e.g., chain-of-responsibility vs. fire-and-forget).
- **No error codes or exception details are included** — the enum only captures high-level outcomes; detailed diagnostics must be embedded in the `ICommunicationReport` instance passed to callbacks.
None identified beyond the above.