Skip to content

Commit c686b8f

Browse files
authored
Merge pull request #1195 from ably/AIT-208/protocol-v6
[AIT-208] feat: update LiveObjects messages fields to support protocol v6
2 parents 25f9a2a + 85fe001 commit c686b8f

28 files changed

Lines changed: 911 additions & 732 deletions

‎lib/src/main/java/io/ably/lib/transport/Defaults.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public class Defaults {
1212
* spec: G4
1313
* </p>
1414
*/
15-
public static final String ABLY_PROTOCOL_VERSION = "5";
15+
public static final String ABLY_PROTOCOL_VERSION = "6";
1616

1717
public static final String ABLY_AGENT_VERSION = String.format("%s/%s", "ably-java", BuildConfig.VERSION);
1818

‎lib/src/test/java/io/ably/lib/test/realtime/RealtimeHttpHeaderTest.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public void realtime_websocket_param_test() {
8181
* Defaults.ABLY_VERSION_PARAM, as ultimately the request param has been derived from those values.
8282
*/
8383
assertEquals("Verify correct version", requestParameters.get("v"),
84-
Collections.singletonList("5"));
84+
Collections.singletonList("6"));
8585

8686
/* Spec RSC7d3
8787
* This test should not directly validate version against Defaults.ABLY_AGENT_VERSION, nor

‎lib/src/test/java/io/ably/lib/test/rest/HttpHeaderTest.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public void header_lib_channel_publish() {
8181
* from those values.
8282
*/
8383
Assert.assertNotNull("Expected headers", headers);
84-
Assert.assertEquals(headers.get("x-ably-version"), "5");
84+
Assert.assertEquals(headers.get("x-ably-version"), "6");
8585
Assert.assertEquals(headers.get("ably-agent"), expectedAblyAgentHeader);
8686
// RSA7e2
8787
Assert.assertNull("Shouldn't include 'x-ably-clientid' if `clientId` is not specified", headers.get("x-ably-clientid"));

‎lib/src/test/java/io/ably/lib/transport/DefaultsTest.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public class DefaultsTest {
99

1010
@Test
1111
public void protocol_version_CSV2() {
12-
assertThat(Defaults.ABLY_PROTOCOL_VERSION, is("5"));
12+
assertThat(Defaults.ABLY_PROTOCOL_VERSION, is("6"));
1313
}
1414

1515
@Test

‎liveobjects/src/main/kotlin/io/ably/lib/objects/DefaultRealtimeObjects.kt‎

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,10 @@ internal class DefaultRealtimeObjects(internal val channelName: String, internal
112112
throw invalidInputError("Map keys should not be empty")
113113
}
114114

115-
// RTO11f4 - Create initial value operation
115+
// RTO11f14 - Create initial value operation
116116
val initialMapValue = DefaultLiveMap.initialValue(entries)
117117

118-
// RTO11f5 - Create initial value JSON string
118+
// RTO11f15 - Create initial value JSON string
119119
val initialValueJSONString = gson.toJson(initialMapValue)
120120

121121
// RTO11f8 - Create object ID from initial value
@@ -126,9 +126,11 @@ internal class DefaultRealtimeObjects(internal val channelName: String, internal
126126
operation = ObjectOperation(
127127
action = ObjectOperationAction.MapCreate,
128128
objectId = objectId,
129-
map = initialMapValue.map,
130-
nonce = nonce,
131-
initialValue = initialValueJSONString,
129+
mapCreateWithObjectId = MapCreateWithObjectId(
130+
nonce = nonce,
131+
initialValue = initialValueJSONString,
132+
derivedFrom = initialMapValue,
133+
),
132134
)
133135
)
134136

@@ -148,9 +150,9 @@ internal class DefaultRealtimeObjects(internal val channelName: String, internal
148150
throw invalidInputError("Counter value should be a valid number")
149151
}
150152

151-
// RTO12f2
153+
// RTO12f12
152154
val initialCounterValue = DefaultLiveCounter.initialValue(initialValue)
153-
// RTO12f3 - Create initial value operation
155+
// RTO12f13 - Create initial value operation
154156
val initialValueJSONString = gson.toJson(initialCounterValue)
155157

156158
// RTO12f6- Create object ID from initial value
@@ -161,9 +163,11 @@ internal class DefaultRealtimeObjects(internal val channelName: String, internal
161163
operation = ObjectOperation(
162164
action = ObjectOperationAction.CounterCreate,
163165
objectId = objectId,
164-
counter = initialCounterValue.counter,
165-
nonce = nonce,
166-
initialValue = initialValueJSONString
166+
counterCreateWithObjectId = CounterCreateWithObjectId(
167+
nonce = nonce,
168+
initialValue = initialValueJSONString,
169+
derivedFrom = initialCounterValue,
170+
),
167171
)
168172
)
169173

‎liveobjects/src/main/kotlin/io/ably/lib/objects/Helpers.kt‎

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -161,26 +161,4 @@ internal fun ObjectsAdapter.throwIfEchoMessagesDisabled() {
161161
}
162162
}
163163

164-
internal class Binary(val data: ByteArray) {
165-
override fun equals(other: Any?): Boolean {
166-
if (this === other) return true
167-
if (other !is Binary) return false
168-
return data.contentEquals(other.data)
169-
}
170-
171-
override fun hashCode(): Int {
172-
return data.contentHashCode()
173-
}
174-
}
175-
176-
internal fun Binary.size(): Int {
177-
return data.size
178-
}
179-
180-
internal data class CounterCreatePayload(
181-
val counter: ObjectsCounter
182-
)
183164

184-
internal data class MapCreatePayload(
185-
val map: ObjectsMap
186-
)

0 commit comments

Comments
 (0)