Module: HTTPX::Plugins::Websocket::RequestMethods

Defined in:
lib/httpx/plugins/websocket.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#driverObject (readonly)

Returns the value of attribute driver.



40
41
42
# File 'lib/httpx/plugins/websocket.rb', line 40

def driver
  @driver
end

Instance Method Details

#init_websocket(connection) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
# File 'lib/httpx/plugins/websocket.rb', line 42

def init_websocket(connection)
  if connection.state == :open
    socket = connection.to_io
    @driver = WebSocket::Driver::HTTPX.new(socket, @headers, { masking: true })
  else
    connection.once(:open) do
      socket = connection.to_io
      @driver = WebSocket::Driver::HTTPX.new(socket, @headers, { masking: true })
    end
  end
end