lib/faye/websocket/api.rb in faye-websocket-0.1.0 vs lib/faye/websocket/api.rb in faye-websocket-0.1.1
- old
+ new
@@ -48,17 +48,17 @@
@parser.close(code, reason) if @parser.respond_to?(:close)
close.call
end
end
- def add_event_listener(type, listener, use_capture)
+ def add_event_listener(event_type, listener, use_capture = false)
@listeners ||= {}
list = @listeners[event_type] ||= []
list << listener
end
- def remove_event_listener(type, listener, use_capture)
+ def remove_event_listener(event_type, listener, use_capture = false)
return unless @listeners and @listeners[event_type]
return @listeners.delete(event_type) unless listener
@listeners[event_type].delete_if(&listener.method(:==))
end
@@ -68,12 +68,12 @@
event.event_phase = Event::AT_TARGET
callback = __send__("on#{ event.type }")
callback.call(event) if callback
- return unless @listeners and @listeners[event_type]
- @listeners[event_type].each do |listener|
- listener.call(*args)
+ return unless @listeners and @listeners[event.type]
+ @listeners[event.type].each do |listener|
+ listener.call(event)
end
end
end
class Event