lib/faye/websocket/api.rb in faye-websocket-0.10.0 vs lib/faye/websocket/api.rb in faye-websocket-0.10.1
- old
+ new
@@ -16,23 +16,25 @@
def_delegators :@driver, :version
attr_reader :url, :ready_state, :buffered_amount
def initialize(options = {})
+ @ready_state = CONNECTING
super()
::WebSocket::Driver.validate_options(options, [:headers, :extensions, :max_length, :ping, :proxy, :tls])
+ @driver = yield
+
if headers = options[:headers]
headers.each { |name, value| @driver.set_header(name, value) }
end
[*options[:extensions]].each do |extension|
@driver.add_extension(extension)
end
@ping = options[:ping]
@ping_id = 0
- @ready_state = CONNECTING
@buffered_amount = 0
@driver.on(:open) { |e| open }
@driver.on(:message) { |e| receive_message(e.data) }
@driver.on(:close) { |e| begin_close(e.reason, e.code) }