Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into fix/1848-refactoring-…
Browse files Browse the repository at this point in the history
…presence

# Conflicts:
#	Ably.xcodeproj/project.pbxproj
#	Source/ARTPresenceMap.m
#	Source/ARTRealtimeChannel.m
#	Source/PrivateHeaders/Ably/ARTPresenceMap.h
#	Source/PrivateHeaders/Ably/ARTRealtimeChannel+Private.h
#	Source/PrivateHeaders/Ably/ARTRealtimePresence+Private.h
#	Test/Tests/ARTDefaultTests.swift
#	Test/Tests/RealtimeClientPresenceTests.swift
  • Loading branch information
maratal committed Feb 24, 2024
2 parents f412a00 + 913659d commit ddf12a4
Show file tree
Hide file tree
Showing 12 changed files with 53 additions and 18 deletions.
1 change: 1 addition & 0 deletions Ably.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1135,6 +1135,7 @@
21113B5829DCA4C700652C86 /* DataGatherer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DataGatherer.swift; sourceTree = "<group>"; };
21113B5E29DDDDD000652C86 /* LogAdapterTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LogAdapterTests.swift; sourceTree = "<group>"; };
21113B6229DDF7E800652C86 /* ARTInternalLogTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ARTInternalLogTests.m; sourceTree = "<group>"; };
21113B5829DCA4C700652C86 /* DataGatherer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DataGatherer.swift; sourceTree = "<group>"; };
211A60DA29D726F800D169C5 /* ARTConnectionStateChangeParams.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = ARTConnectionStateChangeParams.h; path = PrivateHeaders/Ably/ARTConnectionStateChangeParams.h; sourceTree = "<group>"; };
211A60DE29D7272000D169C5 /* ARTConnectionStateChangeParams.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ARTConnectionStateChangeParams.m; sourceTree = "<group>"; };
211A60FA29D8ABCF00D169C5 /* ARTChannelStateChangeParams.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = ARTChannelStateChangeParams.h; path = PrivateHeaders/Ably/ARTChannelStateChangeParams.h; sourceTree = "<group>"; };
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Change Log

## [1.2.25](https://github.com/ably/ably-cocoa/tree/1.2.25)

[Full Changelog](https://github.com/ably/ably-cocoa/compare/1.2.24...1.2.25)

**Implemented features:**

- Realtime protocol v2 implementation (with no `connectionSerial`) [\#1494](https://github.com/ably/ably-cocoa/issues/1494)

## [1.2.24](https://github.com/ably/ably-cocoa/tree/1.2.24)

[Full Changelog](https://github.com/ably/ably-cocoa/compare/1.2.23...1.2.24)
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ You can install Ably for iOS and macOS through Package Manager, CocoaPods, Carth
- [This apple guide](https://developer.apple.com/documentation/swift_packages/adding_package_dependencies_to_your_app) explains the steps in more detail.
- To install the `ably-cocoa` package in another **Swift Package**, then add the following to your `Package.Swift`:
```swift
.package(url: "https://github.com/ably/ably-cocoa", from: "1.2.24"),
.package(url: "https://github.com/ably/ably-cocoa", from: "1.2.25"),
```
### Installing through [CocoaPods](https://cocoapods.org/)

Expand Down Expand Up @@ -101,7 +101,7 @@ If you see, for example, a `dyld: Library not loaded: @rpath/AblyDeltaCodec.fram

### Manual installation

1. Get the code from GitHub [from the release page](https://github.com/ably/ably-cocoa/releases/tag/1.2.24), or clone it to get the latest, unstable and possibly underdocumented version: `git clone [email protected]:ably/ably-cocoa.git`
1. Get the code from GitHub [from the release page](https://github.com/ably/ably-cocoa/releases/tag/1.2.25), or clone it to get the latest, unstable and possibly underdocumented version: `git clone [email protected]:ably/ably-cocoa.git`
2. Drag the directory `ably-cocoa/ably-cocoa` into your project as a group.
3. Ably depends on our [MessagePack Fork](https://github.com/ably-forks/msgpack-objective-C) 0.2.0; get it [from the releases page](https://github.com/ably-forks/msgpack-objective-C/releases/tag/0.2.0-ably-1) and link it into your project.

Expand Down
2 changes: 1 addition & 1 deletion Scripts/jazzy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jazzy \
--objc \
--clean \
--author Ably \
--module-version 1.2.24 \
--module-version 1.2.25 \
--umbrella-header Source/include/Ably/Ably.h \
--framework-root Source \
--module Ably \
Expand Down
2 changes: 1 addition & 1 deletion Source/ARTClientInformation.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#import <sys/utsname.h>

NSString *const ARTClientInformationAgentNotVersioned = @"ARTClientInformationAgentNotVersioned";
NSString *const ARTClientInformation_libraryVersion = @"1.2.24";
NSString *const ARTClientInformation_libraryVersion = @"1.2.25";
static NSString *const _libraryName = @"ably-cocoa";

// NSOperatingSystemVersion has NSInteger as version components for some reason, so mitigate it here.
Expand Down
2 changes: 1 addition & 1 deletion Test/Tests/ARTDefaultTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ class ARTDefaultTests: XCTestCase {

func testVersions() {
XCTAssertEqual(ARTDefault.apiVersion(), "2")
XCTAssertEqual(ARTDefault.libraryVersion(), "1.2.24")
XCTAssertEqual(ARTDefault.libraryVersion(), "1.2.25")
}
}
6 changes: 3 additions & 3 deletions Test/Tests/ClientInformationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ final class ClientInformationTests: XCTestCase {

XCTAssertEqual(agents.keys.count, 2)

XCTAssertEqual(agents["ably-cocoa"], "1.2.24")
XCTAssertEqual(agents["ably-cocoa"], "1.2.25")

#if os(iOS)
XCTAssertTrue(agents.keys.contains("iOS"))
Expand All @@ -27,7 +27,7 @@ final class ClientInformationTests: XCTestCase {
// CR3, CR3b
func testAgentIdentifierWithAdditionalAgents_withNilAdditionalAgents() {
let expectedIdentifier = [
"ably-cocoa/1.2.24",
"ably-cocoa/1.2.25",
ARTDefault.platformAgent()
].sorted().joined(separator: " ")

Expand All @@ -42,7 +42,7 @@ final class ClientInformationTests: XCTestCase {
]

let expectedIdentifier = [
"ably-cocoa/1.2.24",
"ably-cocoa/1.2.25",
"demolib/0.0.1",
"morelib",
ARTDefault.platformAgent()
Expand Down
2 changes: 1 addition & 1 deletion Test/Tests/RealtimeClientConnectionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ class RealtimeClientConnectionTests: XCTestCase {
done()
case .connected:
if let transport = client.internal.transport as? TestProxyTransport, let query = transport.lastUrl?.query {
expect(query).to(haveParam("agent", hasPrefix: "ably-cocoa/1.2.24"))
expect(query).to(haveParam("agent", hasPrefix: "ably-cocoa/1.2.25"))
} else {
XCTFail("MockTransport isn't working")
}
Expand Down
21 changes: 16 additions & 5 deletions Test/Tests/RealtimeClientPresenceTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2872,7 +2872,7 @@ class RealtimeClientPresenceTests: XCTestCase {
}
}

// RTP17f, RTP17g
// RTP17i, RTP17g
func test__200__Presence__PresenceMap_should_perform_re_entry_whenever_a_channel_moves_into_the_attached_state_and_presence_message_consists_of_enter_action_with_client_id_and_data() throws {
let test = Test()
let options = try AblyTests.commonAppSetup(for: test)
Expand Down Expand Up @@ -2917,21 +2917,32 @@ class RealtimeClientPresenceTests: XCTestCase {

expect(client.connection.state).toEventually(equal(ARTRealtimeConnectionState.connected), timeout: testTimeout)

// RTP17f
// RTP17i

expect(channel.state).toEventually(equal(ARTRealtimeChannelState.attached), timeout: testTimeout)
expect(channel.internal.presence.localMembers).to(haveCount(2))

let newTransport = client.internal.transport as! TestProxyTransport
expect(newTransport).toNot(beIdenticalTo(transport))

let sentPresenceMessages = newTransport.protocolMessagesSent.filter({ $0.action == .presence }).compactMap { $0.presence?.first }
var sentPresenceMessages = newTransport.protocolMessagesSent.filter({ $0.action == .presence }).compactMap { $0.presence?.first }

expect(sentPresenceMessages).to(haveCount(2))

let client1PresenceMessage = try! XCTUnwrap(sentPresenceMessages.first(where: { $0.clientId == firstClient }))
let client2PresenceMessage = try! XCTUnwrap(sentPresenceMessages.first(where: { $0.clientId == secondClient }))
let client1PresenceMessage = try XCTUnwrap(sentPresenceMessages.first(where: { $0.clientId == firstClient }))
let client2PresenceMessage = try XCTUnwrap(sentPresenceMessages.first(where: { $0.clientId == secondClient }))

// RTP17i - already attached with resume flag set

let attachedMessage = ARTProtocolMessage()
attachedMessage.action = .attached
attachedMessage.channel = channel.name
attachedMessage.flags = 4 // resume flag

newTransport.receive(attachedMessage)
sentPresenceMessages = newTransport.protocolMessagesSent.filter({ $0.action == .presence }).compactMap { $0.presence?.first }
expect(sentPresenceMessages).to(haveCount(2)) // no changes in sentPresenceMessages => no presense messages sent

// RTP17g

expect(client1PresenceMessage.id).to(equal(firstMsgId))
Expand Down
19 changes: 17 additions & 2 deletions Test/Tests/RestClientChannelTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1635,13 +1635,28 @@ class RestClientChannelTests: XCTestCase {
done()
}
}
waitUntil(timeout: testTimeout) { done in

func checkMetrics(completion: @escaping (ARTChannelDetails) -> ()) {
restChannel.status { details, error in
XCTAssertNil(error)
guard let details = details else {
fail("Channel details are empty"); done()
fail("Channel details are empty");
return
}
if details.status.occupancy.metrics.presenceMembers == 1 {
completion(details)
}
else {
// `presenceMembers` is updated with a delay, so we poll every second until it's fulfilled by the realtime
delay(1.0) {
checkMetrics(completion: completion)
}
}
}
}

waitUntil(timeout: testTimeout) { done in
checkMetrics { details in
XCTAssertEqual(details.status.occupancy.metrics.connections, 1) // CHM2a
XCTAssertEqual(details.status.occupancy.metrics.publishers, 1) // CHM2e
XCTAssertEqual(details.status.occupancy.metrics.subscribers, 1) // CHM2f
Expand Down
2 changes: 1 addition & 1 deletion Test/Tests/RestClientTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1736,7 +1736,7 @@ class RestClientTests: XCTestCase {
let headerAgent = testHTTPExecutor.requests.first!.allHTTPHeaderFields?["Ably-Agent"]
let ablyAgent = ARTClientInformation.agentIdentifier(withAdditionalAgents: options.agents)
XCTAssertEqual(headerAgent, ablyAgent)
XCTAssertTrue(headerAgent!.hasPrefix("ably-cocoa/1.2.24"))
XCTAssertTrue(headerAgent!.hasPrefix("ably-cocoa/1.2.25"))
done()
}
}
Expand Down
2 changes: 1 addition & 1 deletion Version.xcconfig
Original file line number Diff line number Diff line change
@@ -1 +1 @@
CURRENT_PROJECT_VERSION = 1.2.24
CURRENT_PROJECT_VERSION = 1.2.25

0 comments on commit ddf12a4

Please sign in to comment.