Class: Protocol::HTTP2::PingFrame
- Includes:
- Acknowledgement
- Defined in:
- lib/protocol/http2/ping_frame.rb
Overview
The PING frame is a mechanism for measuring a minimal round-trip time from the sender, as well as determining whether an idle connection is still functional. PING frames can be sent from any endpoint.
--------------------------------------------------------------- | | | Opaque Data (64) | | | ---------------------------------------------------------------
Constant Summary collapse
- TYPE =
0x6
Constants inherited from Frame
Frame::HEADER_FORMAT, Frame::LENGTH_HISHIFT, Frame::LENGTH_LOMASK, Frame::STREAM_ID_MASK, Frame::VALID_LENGTH, Frame::VALID_STREAM_ID
Instance Attribute Summary
Attributes inherited from Frame
#flags, #length, #payload, #stream_id, #type
Instance Method Summary collapse
-
#acknowledge ⇒ Object
Create an acknowledgement PING frame with the same payload.
-
#apply(connection) ⇒ Object
Apply this PING frame to a connection for processing.
-
#connection? ⇒ Boolean
Check if this frame applies to the connection level.
-
#read_payload(stream) ⇒ Object
Read and validate the PING frame payload.
Methods included from Acknowledgement
#acknowledgement!, #acknowledgement?
Methods inherited from Frame
#<=>, #clear_flags, #flag_set?, #header, #initialize, #inspect, #pack, parse_header, #read, #read_header, #set_flags, #to_ary, #unpack, #valid_type?, #write, #write_header, #write_payload
Constructor Details
This class inherits a constructor from Protocol::HTTP2::Frame
Instance Method Details
#acknowledge ⇒ Object
Create an acknowledgement PING frame with the same payload.
65 66 67 68 69 70 71 |
# File 'lib/protocol/http2/ping_frame.rb', line 65 def acknowledge frame = super frame.pack self.unpack return frame end |
#apply(connection) ⇒ Object
Apply this PING frame to a connection for processing.
59 60 61 |
# File 'lib/protocol/http2/ping_frame.rb', line 59 def apply(connection) connection.receive_ping(self) end |
#connection? ⇒ Boolean
Check if this frame applies to the connection level.
53 54 55 |
# File 'lib/protocol/http2/ping_frame.rb', line 53 def connection? true end |
#read_payload(stream) ⇒ Object
Read and validate the PING frame payload.
76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/protocol/http2/ping_frame.rb', line 76 def read_payload(stream) super if @stream_id != 0 raise ProtocolError, "Settings apply to connection only, but stream_id was given" end if @length != 8 raise FrameSizeError, "Invalid frame length: #{@length} != 8!" end end |