public Task <IResultMonad <TR> > Send <T, TR>(TPayloadType payloadType, T message) { var identifier = new MessageIdentifier(this.connectionId, Interlocked.Increment(ref this.correlationId)); this.outgoingConnection.Send(new Message <TPayloadType, TBody> { Body = this.encoder.Encode(message), MessageIdentifier = identifier, MessageType = MessageType.Request, PayloadType = payloadType, UserId = Guid.NewGuid(), }); var node = new PendingRequestNode <TR>(); this.pendingRequestNodes[identifier] = node; return(node.task.Task); }
public Task <Message <TPayloadType, TBody> > Send <T>(TPayloadType payloadType, T body, Guid userId) { var identifier = new MessageIdentifier( this.connectionId, Interlocked.Increment(ref this.correlationId)); var msg = new Message <TPayloadType, TBody> { Body = encoder.Encode(body), MessageIdentifier = identifier, MessageType = MessageType.Request, PayloadType = payloadType, UserId = userId, }; var pendingNode = new PendingRequestNode(); this.pendingRequestNodes[identifier] = pendingNode; this.outgoingConnection.Send(msg); return(pendingNode.task.Task); }