File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -72,5 +72,12 @@ def send(connection, **options)
7272 connection . send_binary ( @buffer , **options )
7373 end
7474 end
75+
76+ # Represents a ping message that can be sent over a WebSocket connection.
77+ class PingMessage < Message
78+ def send ( connection )
79+ connection . send_ping ( @buffer )
80+ end
81+ end
7582 end
7683end
Original file line number Diff line number Diff line change 336336 connection . write ( "Hello World!" . b )
337337
338338 frame = client . read_frame
339+ expect ( frame ) . to be_a ( Protocol ::WebSocket ::BinaryFrame )
339340 expect ( frame . unpack ) . to be == "Hello World!" . b
340341 end
341342
344345 connection . write ( message )
345346
346347 frame = client . read_frame
348+ expect ( frame ) . to be_a ( Protocol ::WebSocket ::TextFrame )
349+ expect ( frame . unpack ) . to be == "Hello World!"
350+ end
351+
352+ it "can send ping mmessages" do
353+ message = Protocol ::WebSocket ::PingMessage . new ( "Hello World!" )
354+ connection . write ( message )
355+
356+ frame = client . read_frame
357+ expect ( frame ) . to be_a ( Protocol ::WebSocket ::PingFrame )
347358 expect ( frame . unpack ) . to be == "Hello World!"
348359 end
349360 end
You can’t perform that action at this time.
0 commit comments