@@ -41,6 +41,11 @@ internal class DefaultLiveObjects(private val channelName: String, internal val
4141 private val sequentialScope =
4242 CoroutineScope (Dispatchers .Default .limitedParallelism(1 ) + CoroutineName (channelName) + SupervisorJob ())
4343
44+ /* *
45+ * Coroutine scope for handling callbacks asynchronously.
46+ */
47+ private val callbackScope = CoroutineScope (Dispatchers .Default + CoroutineName (" LiveObjectsCallback-$channelName " ))
48+
4449 /* *
4550 * Event bus for handling incoming object messages sequentially.
4651 */
@@ -51,11 +56,12 @@ internal class DefaultLiveObjects(private val channelName: String, internal val
5156 incomingObjectsHandler = initializeHandlerForIncomingObjectMessages()
5257 }
5358
54- /* *
55- * @spec RTO1 - Returns the root LiveMap object with proper validation and sync waiting
56- */
5759 override fun getRoot (): LiveMap {
58- TODO (" Not yet implemented" )
60+ return runBlocking { getRootAsync() }
61+ }
62+
63+ override fun getRootAsync (callback : Callback <LiveMap >) {
64+ callbackScope.with (callback) { getRootAsync() }
5965 }
6066
6167 override fun createMap (liveMap : LiveMap ): LiveMap {
@@ -70,10 +76,6 @@ internal class DefaultLiveObjects(private val channelName: String, internal val
7076 TODO (" Not yet implemented" )
7177 }
7278
73- override fun getRootAsync (callback : Callback <LiveMap >) {
74- TODO (" Not yet implemented" )
75- }
76-
7779 override fun createMapAsync (liveMap : LiveMap , callback : Callback <LiveMap >) {
7880 TODO (" Not yet implemented" )
7981 }
@@ -94,6 +96,14 @@ internal class DefaultLiveObjects(private val channelName: String, internal val
9496 TODO (" Not yet implemented" )
9597 }
9698
99+ private suspend fun getRootAsync (): LiveMap {
100+ return sequentialScope.async {
101+ adapter.throwIfInvalidAccessApiConfiguration(channelName)
102+ // TODO - wait for state in synced state
103+ objectsPool.get(ROOT_OBJECT_ID ) as LiveMap
104+ }.await()
105+ }
106+
97107 /* *
98108 * Handles a ProtocolMessage containing proto action as `object` or `object_sync`.
99109 * @spec RTL1 - Processes incoming object messages and object sync messages
0 commit comments