private async Task HandshakeReading() { var result = await _handshakePipe.Reader.ReadAsync(); var buffer = result.Buffer; try { ReadableBuffer messageBuffer; Handshake.HandshakeType handshakeType; while (Handshake.HandshakeProcessor.TryGetFrame(ref buffer, out messageBuffer, out handshakeType)) { var outBuffer = _lowerConnection.Output.Alloc(); _state.HandleHandshakeMessage(handshakeType, messageBuffer, ref outBuffer); if (outBuffer.BytesWritten == 0) { outBuffer.Commit(); } else { await outBuffer.FlushAsync(); } } } catch { _logger?.LogInformation("Handshake reading finished with an error"); } finally { _handshakePipe.Reader.Advance(buffer.Start, buffer.End); } }
private async Task HandshakeReading() { var result = await _handshakePipe.ReadAsync(); var buffer = result.Buffer; try { ReadableBuffer messageBuffer; Handshake.HandshakeType handshakeType; while (Handshake.HandshakeProcessor.TryGetFrame(ref buffer, out messageBuffer, out handshakeType)) { await _state.HandleHandshakeMessage(handshakeType, messageBuffer, _handshakeOutpipe); } } finally { _handshakePipe.AdvanceReader(buffer.Start, buffer.End); } }