class Plum::ServerConnection
Public Class Methods
new(writer, local_settings = {})
click to toggle source
Calls superclass method
Plum::Connection::new
# File lib/plum/server/connection.rb, line 4 def initialize(writer, local_settings = {}) super(writer, local_settings) @state = :waiting_preface end
Public Instance Methods
reserve_stream(**args)
click to toggle source
Reserves a new stream to server push. @param args [Hash] The argument to pass to Stram.new.
# File lib/plum/server/connection.rb, line 12 def reserve_stream(**args) next_id = @max_stream_ids[0] + 2 stream = stream(next_id) stream.set_state(:reserved_local) stream.update_dependency(**args) stream end
Private Instance Methods
consume_buffer()
click to toggle source
Calls superclass method
Plum::Connection#consume_buffer
# File lib/plum/server/connection.rb, line 21 def consume_buffer if @state == :waiting_preface negotiate! end super end
negotiate!()
click to toggle source
# File lib/plum/server/connection.rb, line 29 def negotiate! unless CLIENT_CONNECTION_PREFACE.start_with?(@buffer.byteslice(0, 24)) raise RemoteConnectionError.new(:protocol_error) # (MAY) send GOAWAY. sending. end if @buffer.bytesize >= 24 @buffer.byteshift(24) settings(@local_settings) @state = :waiting_settings end end