public async Task<JsonRpcResponse> SendRequestAsync(JsonRpcRequest jsonRpcRequest) { Debug.Assert(jsonRpcRequest != null && jsonRpcRequest.Id != null && jsonRpcRequest.Id != String.Empty); JTokenStreamContent streamContent = new JTokenStreamContent(JToken.FromObject(jsonRpcRequest)); TaskCompletionSource<JsonRpcResponse> sendJsonRpcRequestTask = new TaskCompletionSource<JsonRpcResponse>(jsonRpcRequest); _outgoingJsonRpcRequests.Enqueue(streamContent); _incompleteJsonRpcRequests.AddOrUpdate(jsonRpcRequest.Id, sendJsonRpcRequestTask, (k, v) => { Debug.Assert(false, "Should not send requests with the same id."); return sendJsonRpcRequestTask; }); return await sendJsonRpcRequestTask.Task; }
public void SendNotificationAsync(JsonRpcRequest jsonRpcRequest) { Debug.Assert(jsonRpcRequest != null && jsonRpcRequest.Id != null && jsonRpcRequest.Id != String.Empty); Debug.Assert(jsonRpcRequest.IsNotification == true); JTokenStreamContent streamContent = new JTokenStreamContent(JToken.FromObject(jsonRpcRequest)); _outgoingJsonRpcRequests.Enqueue(streamContent); }