コード例 #1
0
        private async Task HandleReceivedRequest(Request request)
        {
            RequestReceived?.Invoke(this, request);
            Response response = null;

            foreach (var handler in RequestPipeline.GetHandlers())
            {
                var resp = await handler.Invoke(request);

                if (resp != null)
                {
                    response = resp;
                    break;
                }
            }
            if (response != null)
            {
                // Only if response was handled
                // Remember, notifications do not get a reply
                await _transportLock.WaitAsync();

                await DataWriter.WriteLineAsync(response.ToString());

                await DataWriter.FlushAsync();

                _transportLock.Release();
            }
        }