class WebSocket::EventMachine::Client

def self.connect(args = {})

Options Hash: (**args)
  • :tls (Hash) -- TLS options hash to be passed to EM start_tls
  • :ssl (Boolean) -- Force SSL/TLS connection
  • :headers (Hash) -- HTTP headers to use in the handshake
  • :version (Integer) -- Version of protocol to use(default = 13)
  • :uri (String) -- Full URI for server(optional - use instead of host/port combination)
  • :port (Integer) -- The port to connect too(default = 80)
  • :host (String) -- The host IP/DNS name

Parameters:
  • args (Hash) -- The request arguments
def self.connect(args = {})
  host = nil
  port = nil
  if args[:uri]
    uri = URI.parse(args[:uri])
    host = uri.host
    port = uri.port
    args[:ssl] = true if uri.scheme == 'wss'
  end
  host = args[:host] if args[:host]
  port = args[:port] if args[:port]
  if args[:ssl]
    args[:tls] ||= {}
    args[:tls][:sni_hostname] ||= host
    port ||= 443
  else
    port ||= 80
  end
  ::EventMachine.connect host, port, self, args
end