lib/blather/stream.rb in blather-0.4.2 vs lib/blather/stream.rb in blather-0.4.3

- old
+ new

@@ -2,11 +2,12 @@ class Stream < EventMachine::Connection class NoConnection < RuntimeError; end STREAM_NS = 'http://etherx.jabber.org/streams' - attr_accessor :jid, :password + attr_accessor :password + attr_reader :jid ## # Start the stream between client and server # [client] must be an object that will respond to #call and #jid= # [jid] must be a valid argument for JID.new (see JID) @@ -23,13 +24,11 @@ Resolv::DNS.open { |dns| srv = dns.getresources("_xmpp-client._tcp.#{jid.domain}", Resolv::DNS::Resource::IN::SRV) } if srv.empty? connect jid.domain, port, self, client, jid, pass else srv.sort! { |a,b| (a.priority != b.priority) ? (a.priority <=> b.priority) : (b.weight <=> a.weight) } - conn = nil - srv.each { |r| break unless (conn = connect(r.target.to_s, r.port, self, client, jid, pass)) === false } - conn + srv.each { |r| break unless connect(r.target.to_s, r.port, self, client, jid, pass) === false } end end end ## @@ -137,11 +136,10 @@ ## # Ensure the JID gets attached to the client def jid=(new_jid) # :nodoc: Blather.logger.debug "NEW JID: #{new_jid}" @jid = JID.new new_jid - @client.jid = @jid end protected ## # Stop the stream @@ -158,9 +156,9 @@ end def ready! @state = :started @receiver = @client - @client.post_init + @client.post_init self, @jid end end end