Class: Protocol::WebSocket::PingFrame

Inherits:
Frame
  • Object
show all
Defined in:
lib/protocol/websocket/ping_frame.rb

Overview

Represents a ping frame that is sent or received by a WebSocket connection.

Constant Summary collapse

OPCODE =
0x9

Constants inherited from Frame

Frame::RESERVED, Frame::RSV1, Frame::RSV2, Frame::RSV3

Instance Attribute Summary

Attributes inherited from Frame

#finished, #flags, #length, #mask, #opcode, #payload

Instance Method Summary collapse

Methods inherited from Frame

#<=>, #continued?, #control?, #data?, #finished?, #flag?, #initialize, #pack, parse_header, read, #to_ary, #unpack, #write

Constructor Details

This class inherits a constructor from Protocol::WebSocket::Frame

Instance Method Details

#apply(connection) ⇒ Object

Apply this frame to the specified connection.



22
23
24
# File 'lib/protocol/websocket/ping_frame.rb', line 22

def apply(connection)
  connection.receive_ping(self)
end

#reply(**options) ⇒ Object

Generate a suitable reply.



17
18
19
# File 'lib/protocol/websocket/ping_frame.rb', line 17

def reply(**options)
  PongFrame.new(true, **options).pack(self.unpack)
end