class Async::WebSocket::Server
Public Class Methods
new(delegate, protocols: [], handler: Connection)
click to toggle source
Calls superclass method
# File lib/async/websocket/server.rb, line 31 def initialize(delegate, protocols: [], handler: Connection) super(delegate) @protocols = protocols @handler = handler end
Public Instance Methods
call(request) { |call| ... }
click to toggle source
Calls superclass method
# File lib/async/websocket/server.rb, line 47 def call(request) if request.protocol == PROTOCOL # Select websocket sub-protocol: protocol = select_protocol(request) # request.headers = nil Response.for(request, headers, protocol: protocol, **options) do |stream| framer = Protocol::WebSocket::Framer.new(stream) yield handler.call(framer, protocol) end else super end end
response(request)
click to toggle source
# File lib/async/websocket/server.rb, line 44 def response(request) end
select_protocol(request)
click to toggle source
# File lib/async/websocket/server.rb, line 38 def select_protocol(request) if requested_protocol = request.headers[SEC_WEBSOCKET_PROTOCOL] return (requested_protocol & @protocols).first end end