lib/blather/client/client.rb in blather-0.4.3 vs lib/blather/client/client.rb in blather-0.4.4

- old
+ new

@@ -78,10 +78,11 @@ def run raise 'not setup!' unless setup? klass = @setup[0].node ? Blather::Stream::Client : Blather::Stream::Component klass.start self, *@setup end + alias_method :connect, :run ## # Register a filter to be run before or after the handler chain is run. # * +type+ - the type of filter. Must be +:before+ or +:after+ # * +guards+ - guards that should be checked before the filter is called @@ -139,11 +140,11 @@ @jid = JID.new(jid) if jid self.jid.node ? client_post_init : ready! end def unbind # :nodoc: - EM.stop if EM.reactor_running? + call_handler_for(:disconnected, nil) || (EM.reactor_running? && EM.stop) end def receive_data(stanza) # :nodoc: catch(:halt) do run_filters :before, stanza @@ -174,20 +175,20 @@ Blather.logger.warn "Handler for type \"#{type}\" will never be called as it's not a registered type" unless current_handlers.include?(type) check_guards guards end def current_handlers - [:ready] + Stanza.handler_list + BlatherError.handler_list + [:ready, :disconnected] + Stanza.handler_list + BlatherError.handler_list end def setup_initial_handlers # :nodoc: register_handler :error do |err| raise err end - register_handler :iq, :type => [:get, :set] do |iq| - write StanzaError.new(iq, 'service-unavailable', :cancel).to_node - end + # register_handler :iq, :type => [:get, :set] do |iq| + # write StanzaError.new(iq, 'service-unavailable', :cancel).to_node + # end register_handler :status do |status| roster[status.from].status = status if roster[status.from] nil end