class H2::Server
base H2
server, a Celluoid::IO
production
Constants
- DEFAULT_OPTIONS
Attributes
options[R]
Public Class Methods
new(server, **options, &on_connection)
click to toggle source
# File lib/h2/server.rb, line 25 def initialize server, **options, &on_connection @server = server @options = DEFAULT_OPTIONS.merge options @on_connection = on_connection @server.listen @options[:backlog] async.run end
Public Instance Methods
goaway(connection)
click to toggle source
async goaway
# File lib/h2/server.rb, line 61 def goaway connection sleep 0.25 connection.parser.goaway unless connection.closed? end
handle_connection(socket)
click to toggle source
build a new connection object, run it through the given block, and start reading from the socket if still attached
# File lib/h2/server.rb, line 41 def handle_connection socket connection = H2::Server::Connection.new socket: socket, server: self @on_connection[connection] connection.read if connection.attached? end
handle_push_promise(push_promise)
click to toggle source
async push promise
# File lib/h2/server.rb, line 55 def handle_push_promise push_promise push_promise.keep end
handle_stream(stream)
click to toggle source
async stream handling
# File lib/h2/server.rb, line 49 def handle_stream stream stream.connection.each_stream[stream] end
shutdown()
click to toggle source
# File lib/h2/server.rb, line 34 def shutdown @server.close if @server end