public static JsonElement?ReadJson(this PeekableBinaryStream stream)
        {
            var sb = new StringBuilder();

            // ReSharper disable once IteratorMethodResultIsIgnored
            stream.ReadAllAsciiLines(l => sb.Append(l).ToString().Parse() != null);
            return(sb.ToString().Parse());
        }
Exemple #2
0
 public JsonRpcConnection(Stream inputStream, Stream outputStream, Dictionary <string, IncomingRequestAction>?incomingRequestActions = null)
 {
     _cancellationToken      = CancellationTokenSource.Token;
     _inputStream            = new PeekableBinaryStream(inputStream);
     _outputStream           = outputStream;
     _incomingRequestActions = incomingRequestActions ?? new Dictionary <string, IncomingRequestAction>();
     _incomingMessageHandler = new IncomingMessageHandler(_inputStream, HandleIncomingRequest, HandleIncomingResponse);
     _outgoingMessageHandler = new OutgoingMessageHandler(_outputStream, _cancellationToken);
     _listener = Task.Factory.StartNew(Listen).Unwrap();
 }
 public static JsonElement?ReadJson(this PeekableBinaryStream stream, int contentLength) => Encoding.UTF8.GetString(stream.ReadBytes(contentLength)).Parse();
 public IncomingMessageHandler(PeekableBinaryStream stream, IncomingRequestProcess requestProcess, IncomingResponseProcess responseProcess)
 {
     _stream          = stream;
     _requestProcess  = requestProcess;
     _responseProcess = responseProcess;
 }