public override string ToString() { var sb = new StringBuilder(); if (Unknown.Any()) { sb.Append(string.Join(", ", Unknown.Select(x => x.Name))); } if (Incoming.Any()) { if (sb.Length > 0) { sb.Append("; "); } sb.Append("Incoming: "); sb.Append(string.Join(", ", Incoming.Select(x => x.Name))); } if (Outgoing.Any()) { if (sb.Length > 0) { sb.Append("; "); } sb.Append("Outgoing: "); sb.Append(string.Join(", ", Outgoing.Select(x => x.Name))); } return(sb.ToString()); }
public async Task ReceiveAsync( PipeWriter writer, CancellationToken cancellationToken) { while (!cancellationToken.IsCancellationRequested && !Incoming.Any()) { await Task.Delay(100, cancellationToken); } if (cancellationToken.IsCancellationRequested) { return; } GenericOperationMessage message = Incoming.Dequeue(); string json = JsonConvert.SerializeObject(message); byte[] buffer = Encoding.UTF8.GetBytes(json); Memory <byte> memory = writer.GetMemory(buffer.Length); for (int i = 0; i < buffer.Length; i++) { memory.Span[i] = buffer[i]; } writer.Advance(buffer.Length); await writer .FlushAsync(cancellationToken) .ConfigureAwait(false); }
public async Task ReceiveMessageAsync( Stream messageStream, CancellationToken cancellationToken) { while (!cancellationToken.IsCancellationRequested && !Incoming.Any()) { await Task.Delay(100, cancellationToken); } if (cancellationToken.IsCancellationRequested) { return; } GenericOperationMessage message = Incoming.Dequeue(); string json = JsonConvert.SerializeObject(message); byte[] buffer = Encoding.UTF8.GetBytes(json); messageStream.Write(buffer, 0, buffer.Length); }
public bool IsNotFirst() { return(Incoming.Any()); }