예제 #1
0
 public Task WritePingAsync(Http2PingFrameFlags flags, ReadOnlySpan <byte> payload)
 {
     lock (_writeLock)
     {
         _outgoingFrame.PreparePing(Http2PingFrameFlags.ACK);
         payload.CopyTo(_outgoingFrame.Payload);
         return(WriteAsync(_outgoingFrame.Raw));
     }
 }
예제 #2
0
        /* https://tools.ietf.org/html/rfc7540#section-6.7
         +---------------------------------------------------------------+
         |                                                               |
         |                      Opaque Data (64)                         |
         |                                                               |
         +---------------------------------------------------------------+
         */
        public Task WritePingAsync(Http2PingFrameFlags flags, ReadOnlySequence <byte> payload)
        {
            lock (_writeLock)
            {
                if (_completed)
                {
                    return(Task.CompletedTask);
                }

                _outgoingFrame.PreparePing(Http2PingFrameFlags.ACK);
                Debug.Assert(payload.Length == _outgoingFrame.PayloadLength); // 8
                WriteHeaderUnsynchronized();
                foreach (var segment in payload)
                {
                    _outputWriter.Write(segment.Span);
                }

                return(TimeFlushUnsynchronizedAsync());
            }
        }