lib/faye/websocket/client.rb in faye-websocket-0.5.0 vs lib/faye/websocket/client.rb in faye-websocket-0.6.0

- old
+ new

@@ -2,18 +2,26 @@ class WebSocket class Client include API - def initialize(url, protocols = nil) + attr_reader :headers, :status + + def initialize(url, protocols = nil, options = {}) @url = url @uri = URI.parse(url) @driver = ::WebSocket::Driver.client(self, :protocols => protocols) - super() + [:open, :error].each do |event| + @driver.on(event) do + @headers = @driver.headers + @status = @driver.status + end + end - port = @uri.port || (@uri.scheme == 'wss' ? 443 : 80) + super(options) + port = @uri.port || (@uri.scheme == 'wss' ? 443 : 80) EventMachine.connect(@uri.host, port, Connection) do |conn| @stream = conn conn.parent = self end end