@@ -164,20 +164,87 @@ internal final class InternalDefaultRealtimeObjects: Sendable, LiveMapObjectPool
164164 }
165165 }
166166
167- internal func createMap( entries _: [ String : LiveMapValue ] ) async throws ( ARTErrorInfo) -> any LiveMap {
168- notYetImplemented ( )
167+ internal func createMap( entries: [ String : LiveMapValue ] , coreSDK: CoreSDK ) async throws ( ARTErrorInfo) -> any LiveMap {
168+ do {
169+ let internalEntries : [ String : InternalLiveMapValue ] = entries. mapValues { . init( liveMapValue: $0) }
170+
171+ // RTO11f
172+ // TODO: This is a stopgap; change to use server time per RTO11f5
173+ let timestamp = clock. now
174+ let creationOperation = ObjectCreationHelpers . creationOperationForLiveMap (
175+ entries: internalEntries,
176+ timestamp: timestamp,
177+ )
178+
179+ // RTO11g
180+ try await coreSDK. sendObject ( objectMessages: [ creationOperation. objectMessage] )
181+
182+ // RTO11h
183+ let internalMap = mutex. withLock {
184+ mutableState. objectsPool. getOrCreateMap (
185+ creationOperation: creationOperation,
186+ logger: logger,
187+ userCallbackQueue: userCallbackQueue,
188+ clock: clock,
189+ )
190+ }
191+
192+ return PublicObjectsStore . shared. getOrCreateMap (
193+ proxying: internalMap,
194+ creationArgs: . init(
195+ coreSDK: coreSDK,
196+ delegate: self ,
197+ logger: logger,
198+ ) ,
199+ )
200+ } catch {
201+ throw error. toARTErrorInfo ( )
202+ }
169203 }
170204
171- internal func createMap( ) async throws ( ARTErrorInfo) -> any LiveMap {
172- notYetImplemented ( )
205+ internal func createMap( coreSDK: CoreSDK ) async throws ( ARTErrorInfo) -> any LiveMap {
206+ // RTO11f4b
207+ try await createMap ( entries: [ : ] , coreSDK: coreSDK)
173208 }
174209
175- internal func createCounter( count _: Double ) async throws ( ARTErrorInfo) -> any LiveCounter {
176- notYetImplemented ( )
210+ internal func createCounter( count: Double , coreSDK: CoreSDK ) async throws ( ARTErrorInfo) -> any LiveCounter {
211+ do {
212+ // RTO12f
213+ // TODO: This is a stopgap; change to use server time per RTO12f5
214+ let timestamp = clock. now
215+ let creationOperation = ObjectCreationHelpers . creationOperationForLiveCounter (
216+ count: count,
217+ timestamp: timestamp,
218+ )
219+
220+ // RTO12g
221+ try await coreSDK. sendObject ( objectMessages: [ creationOperation. objectMessage] )
222+
223+ // RTO12h
224+ let internalCounter = mutex. withLock {
225+ mutableState. objectsPool. getOrCreateCounter (
226+ creationOperation: creationOperation,
227+ logger: logger,
228+ userCallbackQueue: userCallbackQueue,
229+ clock: clock,
230+ )
231+ }
232+
233+ return PublicObjectsStore . shared. getOrCreateCounter (
234+ proxying: internalCounter,
235+ creationArgs: . init(
236+ coreSDK: coreSDK,
237+ logger: logger,
238+ ) ,
239+ )
240+ } catch {
241+ throw error. toARTErrorInfo ( )
242+ }
177243 }
178244
179- internal func createCounter( ) async throws ( ARTErrorInfo) -> any LiveCounter {
180- notYetImplemented ( )
245+ internal func createCounter( coreSDK: CoreSDK ) async throws ( ARTErrorInfo) -> any LiveCounter {
246+ // RTO12f2a
247+ try await createCounter ( count: 0 , coreSDK: coreSDK)
181248 }
182249
183250 internal func batch( callback _: sending BatchCallback) async throws {
0 commit comments