module Async::WebSocket::Adapters::Native
Public Class Methods
open(request, headers: [], protocols: [], handler: Connection, **options) { |call| ... }
click to toggle source
# File lib/pakyow/realtime/websocket.rb, line 140 def self.open(request, headers: [], protocols: [], handler: Connection, **options) if websocket?(request) && Array(request.protocol).include?(PROTOCOL) # Select websocket sub-protocol: if requested_protocol = request.headers[SEC_WEBSOCKET_PROTOCOL] protocol = (requested_protocol & protocols).first end Response.for(request, headers, protocol: protocol, **options) do |stream| framer = Protocol::WebSocket::Framer.new(stream) yield handler.call(framer, protocol) end else nil end end
websocket?(request)
click to toggle source
# File lib/pakyow/realtime/websocket.rb, line 136 def self.websocket?(request) request.headers.include?("upgrade") end