Skip to content

Commit

Permalink
Merge pull request #372 from ably/fix-rtp8a
Browse files Browse the repository at this point in the history
RTP8a, RTL7f: attach first to avoid race condition.
  • Loading branch information
ricardopereira committed Apr 5, 2016
2 parents c543e39 + cbf948d commit accf1f4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
19 changes: 11 additions & 8 deletions Spec/RealtimeClientChannel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1325,16 +1325,19 @@ class RealtimeClientChannel: QuickSpec {
let channel2 = client2.channels.get("test")

waitUntil(timeout: testTimeout) { done in
channel1.subscribe { message in
expect(message.data as? String).to(equal("message"))
delay(1.0) { done() }
}
channel1.attach { err in
expect(err).to(beNil())
channel1.subscribe { message in
expect(message.data as? String).to(equal("message"))
delay(1.0) { done() }
}

channel2.subscribe { message in
fail("Shouldn't receive the message")
}
channel2.subscribe { message in
fail("Shouldn't receive the message")
}

channel2.publish(nil, data: "message")
channel2.publish(nil, data: "message")
}
}
}

Expand Down
13 changes: 8 additions & 5 deletions Spec/RealtimeClientPresence.swift
Original file line number Diff line number Diff line change
Expand Up @@ -287,12 +287,15 @@ class RealtimeClientPresence: QuickSpec {
let channel2 = client2.channels.get("test")

waitUntil(timeout: testTimeout) { done in
channel1.presence.subscribe(.Enter) { member in
expect(member.clientId).to(equal(options.clientId))
expect(member.data as? NSObject).to(equal("online"))
done()
channel1.attach { err in
expect(err).to(beNil())
channel1.presence.subscribe(.Enter) { member in
expect(member.clientId).to(equal(options.clientId))
expect(member.data as? NSObject).to(equal("online"))
done()
}
channel2.presence.enter("online")
}
channel2.presence.enter("online")
}
}

Expand Down

0 comments on commit accf1f4

Please sign in to comment.