From fc1285e93cc5d82c79bb96e33dc60858510959ca Mon Sep 17 00:00:00 2001 From: crc-32 Date: Thu, 19 Sep 2024 16:37:38 +0100 Subject: [PATCH] apprunstate util functions --- gradle.properties | 2 +- .../services/app/AppRunStateService.kt | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 78acc19..62500e3 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,7 +1,7 @@ kotlin.code.style=official group=io.rebble.libpebblecommon -version=0.1.22 +version=0.1.23 org.gradle.jvmargs=-Xms128M -Xmx1G -XX:ReservedCodeCacheSize=200M kotlin.native.binary.memoryModel=experimental kotlin.mpp.androidSourceSetLayoutVersion=2 diff --git a/src/commonMain/kotlin/io/rebble/libpebblecommon/services/app/AppRunStateService.kt b/src/commonMain/kotlin/io/rebble/libpebblecommon/services/app/AppRunStateService.kt index 58b59a4..72e05bf 100644 --- a/src/commonMain/kotlin/io/rebble/libpebblecommon/services/app/AppRunStateService.kt +++ b/src/commonMain/kotlin/io/rebble/libpebblecommon/services/app/AppRunStateService.kt @@ -1,11 +1,14 @@ package io.rebble.libpebblecommon.services.app +import com.benasher44.uuid.Uuid import io.rebble.libpebblecommon.ProtocolHandler import io.rebble.libpebblecommon.packets.AppRunStateMessage import io.rebble.libpebblecommon.protocolhelpers.PebblePacket import io.rebble.libpebblecommon.protocolhelpers.ProtocolEndpoint import io.rebble.libpebblecommon.services.ProtocolService import kotlinx.coroutines.channels.Channel +import kotlinx.coroutines.flow.first +import kotlinx.coroutines.flow.receiveAsFlow class AppRunStateService(private val protocolHandler: ProtocolHandler) : ProtocolService { val receivedMessages = Channel(Channel.BUFFERED) @@ -26,4 +29,12 @@ class AppRunStateService(private val protocolHandler: ProtocolHandler) : Protoco receivedMessages.trySend(packet) } + suspend fun startApp(uuid: Uuid) { + send(AppRunStateMessage.AppRunStateStart(uuid)) + } + + suspend fun stopApp(uuid: Uuid) { + send(AppRunStateMessage.AppRunStateStop(uuid)) + } + } \ No newline at end of file