lib/blather/stream.rb in blather-0.2.3 vs lib/blather/stream.rb in blather-0.3.0
- old
+ new
@@ -95,27 +95,27 @@
# Called by the parser with parsed nodes
def receive(node) # :nodoc:
LOG.debug "RECEIVING (#{node.element_name}) #{node}"
@node = node
+ if @node.find_first('//stream:error', :stream => 'http://etherx.jabber.org/streams')
+ handle_stream_error
+ return
+ end
+
case @node.element_name
- when 'stream:stream'
+ when 'stream'
@state = :ready if @state == :stopped
when 'stream:end'
stop
- when 'stream:features'
+ when 'features'
@features = @node.children
@state = :features
dispatch
- when 'stream:error'
- @error = StreamError.import @node
- stop
- @state = :error
-
else
dispatch
end
end
@@ -161,9 +161,15 @@
##
# Called when @state == :ready
# Simply passes the stanza to the client
def ready
@client.call @node.to_stanza
+ end
+
+ def handle_stream_error
+ @error = StreamError.import @node
+ stop
+ @state = :error
end
##
# Called when @state == :features
# Runs through the list of features starting each one in turn