lib/faye/websocket/client.rb in faye-websocket-0.9.1 vs lib/faye/websocket/client.rb in faye-websocket-0.9.2

- old
+ new

@@ -48,40 +48,38 @@ @driver.emit(:error, error) end end EventMachine.connect(endpoint.host, port, Connection) do |conn| - @stream = conn conn.parent = self end rescue => error - event = Event.create('error', :message => "Network error: #{url}: #{error.message}") - event.init_event('error', false, false) - dispatch_event(event) - finalize('', 1006) + emit_error("Network error: #{url}: #{error.message}") + finalize_close end private - def on_connect() + def on_connect(stream) + @stream = stream @stream.start_tls(@socket_tls) if @secure worker = @proxy || @driver worker.start end module Connection attr_accessor :parent def connection_completed - parent.__send__(:on_connect) + parent.__send__(:on_connect, self) end def receive_data(data) parent.__send__(:parse, data) end def unbind - parent.__send__(:finalize, '', 1006) + parent.__send__(:finalize_close) end def write(data) send_data(data) rescue nil end