MosaicNetworkImpl

class MosaicNetworkImpl(baseUrl: String, httpClient: HttpClient, networkParametersHolder: NetworkParametersHolder, mosaicSerializer: MosaicSerializer, fileSystem: MosaicFileSystem) : MosaicNetwork

Constructors

Link copied to clipboard
constructor(baseUrl: String, httpClient: HttpClient, networkParametersHolder: NetworkParametersHolder, mosaicSerializer: MosaicSerializer, fileSystem: MosaicFileSystem)

Functions

Link copied to clipboard
open suspend override fun downloadFile(url: String, headers: Map<String, String>?, body: Any?, httpMethod: HttpMethod, targetFileName: String, mimeType: String?, onProgress: suspend (Float) -> Unit, onDownloadFinished: suspend () -> Unit, onDownloadFailure: suspend (Throwable) -> Unit): Result<Unit>

Downloads a file into the device's public/general storage (system Downloads location). Behavior is platform-specific — see dev.catbit.mosaic.core.data.schemas.event.events.networking.DownloadFileEventSchema.

Link copied to clipboard
open suspend override fun downloadFileToDisk(url: String, headers: Map<String, String>?, body: Any?, httpMethod: HttpMethod, targetFileName: String, onProgress: suspend (Float) -> Unit, onDownloadFinished: suspend () -> Unit, onDownloadFailure: suspend (Throwable) -> Unit): Result<Unit>

Streams the response body straight to targetFileName, without ever holding the full file in memory.

Link copied to clipboard
open suspend override fun downloadFileToMemory(url: String, headers: Map<String, String>?, body: Any?, httpMethod: HttpMethod, onProgress: suspend (Float) -> Unit, onDownloadFinished: suspend (ByteArray) -> Unit, onDownloadFailure: suspend (Throwable) -> Unit): Result<Unit>
Link copied to clipboard
open suspend override fun getInitialGraph(): Result<GraphResponse>
Link copied to clipboard
open suspend override fun getScreen(screenId: String, headers: Map<String, String>?, body: Any?, httpMethod: HttpMethod, timeoutMillis: Long?): Result<ScreenResponse>
Link copied to clipboard
open suspend override fun getVersion(): Result<VersionResponse>

Short-timeout version check meant to run before getInitialGraph at startup without blocking it.

Link copied to clipboard
open suspend override fun hasInternetConnection(): Boolean

Probes whether the device currently has an active internet connection by issuing a lightweight GET to a captive-portal-style endpoint. Any exception (no connection, DNS failure, timeout) is treated as "no connection" rather than propagated.

Link copied to clipboard
open suspend override fun sendHttpRequest(url: String, headers: Map<String, String>?, body: Any?, httpMethod: HttpMethod, timeoutMillis: Long?): Result<HttpResponse>
Link copied to clipboard
open suspend override fun uploadFile(url: String?, headers: Map<String, String>?, httpMethod: HttpMethod, contentType: String?, platformFile: PlatformFile, onProgress: suspend (Float) -> Unit): Result<UploadResult>