class PingFrame
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) | | | +---------------------------------------------------------------+
Definitions
def connection?
Check if this frame applies to the connection level.
Signature
-
returns
Boolean
Always returns true for PING frames.
Implementation
def connection?
true
end
def apply(connection)
Apply this PING frame to a connection for processing.
Signature
-
parameter
connection
Connection
The connection to apply the frame to.
Implementation
def apply(connection)
connection.receive_ping(self)
end
def acknowledge
Create an acknowledgement PING frame with the same payload.
Signature
-
returns
PingFrame
A new PING frame marked as an acknowledgement.
Implementation
def acknowledge
frame = super
frame.pack self.unpack
return frame
end
def read_payload(stream)
Read and validate the PING frame payload.
Signature
-
parameter
stream
IO
The stream to read from.
-
raises
ProtocolError
If validation fails.
Implementation
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