Method: Protocol::HTTP2::Connection#receive_ping

Defined in:
lib/protocol/http2/connection.rb

#receive_ping(frame) ⇒ Object



308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
# File 'lib/protocol/http2/connection.rb', line 308

def receive_ping(frame)
  if @state != :closed
    if frame.stream_id != 0
      raise ProtocolError, "Ping received for non-zero stream!"
    end
    
    unless frame.acknowledgement?
      reply = frame.acknowledge
      
      write_frame(reply)
    end
  else
    raise ProtocolError, "Cannot receive ping in state #{@state}"
  end
end