-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RTL1 #180
RTL1 #180
Changes from all commits
c9a84a3
bf316b8
b7cae3d
a7a81e2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,70 @@ class RealtimeClientChannel: QuickSpec { | |
override func spec() { | ||
describe("Channel") { | ||
|
||
// RTL1 | ||
it("should process all incoming messages and presence messages as soon as a Channel becomes attached") { | ||
let options = AblyTests.commonAppSetup() | ||
let client1 = ARTRealtime(options: options) | ||
defer { client1.close() } | ||
|
||
let channel1 = client1.channel("room") | ||
channel1.attach() | ||
|
||
waitUntil(timeout: testTimeout) { done in | ||
channel1.presence().enterClient("Client 1", data: nil) { status in | ||
expect(status.state).to(equal(ARTState.Ok)) | ||
done() | ||
} | ||
} | ||
|
||
options.clientId = "Client 2" | ||
let client2 = ARTRealtime(options: options) | ||
defer { client2.close() } | ||
|
||
let channel2 = client2.channel(channel1.name) | ||
channel2.attach() | ||
|
||
expect(channel2.presence().isSyncComplete()).to(beFalse()) | ||
|
||
expect(channel1.presenceMap.members).to(haveCount(1)) | ||
expect(channel2.presenceMap.members).to(haveCount(0)) | ||
|
||
expect(channel2.state).toEventually(equal(ARTRealtimeChannelState.Attached), timeout: testTimeout) | ||
|
||
expect(channel2.presence().isSyncComplete()).toEventually(beTrue(), timeout: testTimeout) | ||
|
||
expect(channel1.presenceMap.members).to(haveCount(1)) | ||
expect(channel2.presenceMap.members).to(haveCount(1)) | ||
|
||
// Check if receives incoming messages | ||
channel2.subscribeToName("Client 1") { message, errorInfo in | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Another API issue, but why do we have errorInfo here. When you subscribe to a message, you only ever get messages, never errors. Also, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Addressed here #183. |
||
expect(message.data as? String).to(equal("message")) | ||
} | ||
|
||
waitUntil(timeout: testTimeout) { done in | ||
channel1.publish("message", cb: { status in | ||
expect(status.state).to(equal(ARTState.Ok)) | ||
done() | ||
}) | ||
} | ||
|
||
waitUntil(timeout: testTimeout) { done in | ||
channel2.presence().enter(nil) { status in | ||
expect(status.state).to(equal(ARTState.Ok)) | ||
done() | ||
} | ||
} | ||
|
||
expect(channel1.presenceMap.members).to(haveCount(2)) | ||
expect(channel1.presenceMap.members).to(allKeysPass({ $0.hasPrefix("Client") })) | ||
expect(channel1.presenceMap.members).to(allValuesPass({ $0.action == .Enter })) | ||
|
||
expect(channel2.presenceMap.members).to(haveCount(2)) | ||
expect(channel2.presenceMap.members).to(allKeysPass({ $0.hasPrefix("Client") })) | ||
expect(channel2.presenceMap.members["Client 1"]!.action).to(equal(ARTPresenceAction.Present)) | ||
expect(channel2.presenceMap.members["Client 2"]!.action).to(equal(ARTPresenceAction.Enter)) | ||
} | ||
|
||
// RTL4 | ||
describe("attach") { | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no public members property in the API, only
get
, see http://docs.ably.io/client-lib-development-guide/features/#RSP3There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But this is related with the PresenceMap, not with the Presence himself. Maybe it isn't consistent with other clients.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The presence API is pretty broken anyway already. I see that you're only adding generics, which I think is OK. I'll get the API right.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, thanks @tcard, @ricardopereira ignore my comments tehne