@@ -98,19 +98,19 @@ internal class DefaultLiveObjects(internal val channelName: String, internal val
9898 }
9999
100100 private suspend fun createMapAsync (entries : MutableMap <String , LiveMapValue >): LiveMap {
101- adapter.throwIfInvalidWriteApiConfiguration(channelName)
101+ adapter.throwIfInvalidWriteApiConfiguration(channelName) // RTO11c, RTO11d, RTO11e
102102
103- if (entries.keys.any { it.isEmpty() }) {
104- throw objectError (" Map keys should not be empty" )
103+ if (entries.keys.any { it.isEmpty() }) { // RTO11f2
104+ throw invalidInputError (" Map keys should not be empty" )
105105 }
106106
107- // Create initial value operation
107+ // RTO11f4 - Create initial value operation
108108 val initialMapValue = DefaultLiveMap .initialValue(entries)
109109
110- // Create initial value JSON string
110+ // RTO11f5 - Create initial value JSON string
111111 val initialValueJSONString = gson.toJson(initialMapValue)
112112
113- // Create object ID from initial value
113+ // RTO11f8 - Create object ID from initial value
114114 val (objectId, nonce) = getObjectIdStringWithNonce(ObjectType .Map , initialValueJSONString)
115115
116116 // Create ObjectMessage with the operation
@@ -124,28 +124,29 @@ internal class DefaultLiveObjects(internal val channelName: String, internal val
124124 )
125125 )
126126
127- // Publish the message
127+ // RTO11g - Publish the message
128128 publish(arrayOf(msg))
129129
130- // Check if object already exists in pool, otherwise create a zero-value object using the sequential scope
130+ // RTO11h - Check if object already exists in pool, otherwise create a zero-value object using the sequential scope
131131 return objectsPool.get(objectId) as ? LiveMap ? : withContext(sequentialScope.coroutineContext) {
132132 objectsPool.createZeroValueObjectIfNotExists(objectId) as LiveMap
133133 }
134134 }
135135
136136 private suspend fun createCounterAsync (initialValue : Number ): LiveCounter {
137- adapter.throwIfInvalidWriteApiConfiguration(channelName)
137+ adapter.throwIfInvalidWriteApiConfiguration(channelName) // RTO12c, RTO12d, RTO12e
138138
139139 // Validate input parameter
140140 if (initialValue.toDouble().isNaN() || initialValue.toDouble().isInfinite()) {
141- throw objectError (" Counter value should be a valid number" )
141+ throw invalidInputError (" Counter value should be a valid number" )
142142 }
143143
144+ // RTO12f2
144145 val initialCounterValue = DefaultLiveCounter .initialValue(initialValue)
145- // Create initial value operation
146+ // RTO12f3 - Create initial value operation
146147 val initialValueJSONString = gson.toJson(initialCounterValue)
147148
148- // Create object ID from initial value
149+ // RTO12f6- Create object ID from initial value
149150 val (objectId, nonce) = getObjectIdStringWithNonce(ObjectType .Counter , initialValueJSONString)
150151
151152 // Create ObjectMessage with the operation
@@ -159,15 +160,18 @@ internal class DefaultLiveObjects(internal val channelName: String, internal val
159160 )
160161 )
161162
162- // Publish the message
163+ // RTO12g - Publish the message
163164 publish(arrayOf(msg))
164165
165- // Check if object already exists in pool, otherwise create a zero-value object using the sequential scope
166+ // RTO12h - Check if object already exists in pool, otherwise create a zero-value object using the sequential scope
166167 return objectsPool.get(objectId) as ? LiveCounter ? : withContext(sequentialScope.coroutineContext) {
167168 objectsPool.createZeroValueObjectIfNotExists(objectId) as LiveCounter
168169 }
169170 }
170171
172+ /* *
173+ * Spec: RTO11f8, RTO12f6
174+ */
171175 private suspend fun getObjectIdStringWithNonce (objectType : ObjectType , initialValue : String ): Pair <String , String > {
172176 val nonce = generateNonce()
173177 val msTimestamp = ServerTime .getCurrentTime(adapter) // RTO16 - Get server time for nonce generation
0 commit comments