Sobes.tech
Junior — Senior

Deferred saving and retrieving device session

livecode

Task condition

It is necessary to implement a system that will save and provide a session obtained from an external library that gathers information about the device. This session will be used for user identification on the server side.

  1. Launch the initialization of the DeviceScrapingLibrary, and after it is ready, save the obtained session.
  2. Ensure the ability to retrieve the saved session through the SessionStorage layer.
  3. Access to the session should only be possible after successful completion of initialization.
class DeviceScrapingLibraryInitializer(
    private val sessionRepo: DeviceScrapingSessionRepository
) {
    fun initialize() {
        val builder = DeviceScrapingLibrary.Builder()
            .onSessionReady { session ->
                sessionRepo.save(session)
            }
            .build()
        DeviceScrapingLibrary.initialize(builder)
    }
}

class DeviceScrapingSessionRepository {
    fun save(session: Session) {
        // TODO store session
    }

    suspend fun retrieve(): Session {
        // TODO suspend until session is available
    }
}