Skip to content

Commit

Permalink
fix Stream.start to ensure a new stream object is returned when SRV r…
Browse files Browse the repository at this point in the history
…ecords get involved
  • Loading branch information
sprsquish committed Jun 4, 2009
1 parent fdb0d0e commit b8906c1
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 3 additions & 1 deletion lib/blather/stream.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ def self.start(client, jid, pass, host = nil, port = 5222)
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) }
srv.each { |r| break unless (connect(r.target.to_s, r.port, self, client, jid, pass) === false)}
conn = nil
srv.each { |r| break unless (conn = connect(r.target.to_s, r.port, self, client, jid, pass)) === false }
conn
end
end
end
Expand Down
6 changes: 3 additions & 3 deletions lib/blather/stream/features/session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ def receive_data(stanza)

private
def check_response
if @node[:type] == 'error'
fail!(StanzaError.import(@node))
if @node[:type] == 'result'
succeed!
else
succeed!
fail!(StanzaError.import(@node))
end
end

Expand Down
4 changes: 1 addition & 3 deletions spec/blather/stream/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def mocked_server(times = nil, &block)
parms[4].must_equal Blather::JID.new('n@d/r')
end

Blather::Stream::Client.start *(params)
Blather::Stream::Client.start *params
end

it 'attempts to find the SRV record if a host is not provided' do
Expand Down Expand Up @@ -156,7 +156,6 @@ def mocked_server(times = nil, &block)
it 'will be in the negotiating state during feature negotiations' do
state = nil
@client = mock()
@client.stubs(:post_init)
@client.expects(:receive_data).with do |n|
EM.stop
state.must_equal(:negotiated) && @stream.negotiating?.must_equal(false)
Expand Down Expand Up @@ -880,7 +879,6 @@ class Client; attr_accessor :jid; end
state = :completed
doc = parse_stanza val
doc.find('/iq[@type="set" and @to="d"]/sess_ns:session', :sess_ns => Blather::Stream::Session::SESSION_NS).wont_be_empty

server.send_data "<iq from='d' type='result' id='#{doc.find_first('iq')['id']}' />"
server.send_data "<stream:features><bind xmlns='urn:ietf:params:xml:ns:xmpp-bind' /></stream:features>"

Expand Down

0 comments on commit b8906c1

Please sign in to comment.