How synchronous request/response works
mainWatsonTcp provides a mechanism for synchronous request/response patterns using ConversationGuid to match requests with responses.
The Workflow:
- Sender: Creates a
TaskCompletionSource<SyncResponse>, stores it in a dictionary keyed by the message'sConversationGuid, and sends the message withSyncRequest = trueand anExpirationUtc. - Receiver: Detects
msg.SyncRequest == true, triggers theSyncRequestReceivedcallback, and sends a response withSyncResponse = trueusing the sameConversationGuid. - Original Sender: The receiver's
DataReceiverdetects theSyncResponse, finds the matchingConversationGuidin the dictionary, and completes theTaskCompletionSource. - Timeout: If the response does not arrive before
ExpirationUtc, aTimeoutExceptionis thrown.
Note on Clock Skew: The library uses WatsonCommon.GetExpirationTimestamp() to adjust for differences between the sender's and receiver's system clocks.