Beispiel #1
0
            public async Task ReplyToAsync(TMessage message, uint seqNum)
            {
                var response = await _messageHandler.HandleAsync(message);

                var payload = _endPoint._serializer.Serialize(response, MessageEncoding.Bson);
                await _endPoint.SendPayloadAsync(payload, _endPoint.GetNextSeqNum(), seqNum, MessageType.MessageHandled, MessageEncoding.Bson, default(CancellationToken));
            }
Beispiel #2
0
            /// <summary>
            /// Creates a new slot in the response table.
            /// </summary>
            /// <param name="messageEndPoint">The message end point.</param>
            public ResponseTableSlot(MessageEndPoint messageEndPoint)
            {
                Assert(messageEndPoint != null);

                _messageEndPoint = messageEndPoint;
                _seqNum          = 0;

                _completionSource = new TaskCompletionSource <object>();

                // Allocate the next free seq-num that must not habe an entry in the response table.
                do
                {
                    _seqNum = _messageEndPoint.GetNextSeqNum();
                }while (!_messageEndPoint._responseTable.TryAdd(_seqNum, _completionSource));
            }