Skip to content

Commit

Permalink
connection.id
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardopereira committed Dec 2, 2015
1 parent 512d523 commit b193b60
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
4 changes: 4 additions & 0 deletions ably-ios/ARTConnection.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
@class ARTRealtime;
@class ARTEventEmitter;

ART_ASSUME_NONNULL_BEGIN

@interface ARTConnection: NSObject

@property (readonly, getter=getId) NSString *id;
Expand All @@ -28,3 +30,5 @@
- (void)ping:(ARTRealtimePingCb)cb;

@end

ART_ASSUME_NONNULL_END
17 changes: 9 additions & 8 deletions ablySpec/RealtimeClient.connection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -336,17 +336,18 @@ class RealtimeClientConnection: QuickSpec {
it("should be null until connected") {
let options = AblyTests.commonAppSetup()
let client = ARTRealtime(options: options)
let connection = client.connection()

expect(client.connectionId()).to(beEmpty())
expect(connection.id).to(beEmpty())

waitUntil(timeout: testTimeout) { done in
client.eventEmitter.on { state, errorInfo in
connection.eventEmitter.on { state, errorInfo in
if state == .Connected && errorInfo == nil {
expect(client.connectionId()).toNot(beEmpty())
expect(connection.id).toNot(beEmpty())
done()
}
else if state == .Connecting {
expect(client.connectionId()).to(beEmpty())
expect(connection.id).to(beEmpty())
}
}
}
Expand All @@ -361,11 +362,11 @@ class RealtimeClientConnection: QuickSpec {

for _ in 1...max {
disposable.append(ARTRealtime(options: options))
let currentClient = disposable.last
currentClient!.eventEmitter.on { state, errorInfo in
let currentConnection = disposable.last?.connection()
currentConnection?.eventEmitter.on { state, errorInfo in
if state == .Connected {
expect(ids).toNot(contain(currentClient?.connectionId()))
ids.append(currentClient?.connectionId() ?? "")
expect(ids).toNot(contain(currentConnection?.id))
ids.append(currentConnection?.id ?? "")
}
}
}
Expand Down

0 comments on commit b193b60

Please sign in to comment.