lib/websocket/eventmachine/client.rb in websocket-eventmachine-client-1.2.0 vs lib/websocket/eventmachine/client.rb in websocket-eventmachine-client-1.3.0
- old
+ new
@@ -21,10 +21,11 @@
# @option args [Integer] :port The port to connect too(default = 80)
# @option args [String] :uri Full URI for server(optional - use instead of host/port combination)
# @option args [Integer] :version Version of protocol to use(default = 13)
# @option args [Hash] :headers HTTP headers to use in the handshake
# @option args [Boolean] :ssl Force SSL/TLS connection
+ # @option args [Hash] :tls TLS options hash to be passed to EM start_tls
def self.connect(args = {})
host = nil
port = nil
if args[:uri]
uri = URI.parse(args[:uri])
@@ -33,10 +34,12 @@
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
@@ -81,10 +84,10 @@
# Sends handshake to server or starts SSL/TLS
# Eventmachine internal
# @private
def connection_completed
if @args[:ssl]
- start_tls
+ start_tls @args[:tls]
else
send(@handshake.to_s, :type => :plain)
end
end