Skip to content

Commit fc1285e

Browse files
committed
apprunstate util functions
1 parent 4f2c586 commit fc1285e

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
kotlin.code.style=official
22

33
group=io.rebble.libpebblecommon
4-
version=0.1.22
4+
version=0.1.23
55
org.gradle.jvmargs=-Xms128M -Xmx1G -XX:ReservedCodeCacheSize=200M
66
kotlin.native.binary.memoryModel=experimental
77
kotlin.mpp.androidSourceSetLayoutVersion=2

src/commonMain/kotlin/io/rebble/libpebblecommon/services/app/AppRunStateService.kt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
package io.rebble.libpebblecommon.services.app
22

3+
import com.benasher44.uuid.Uuid
34
import io.rebble.libpebblecommon.ProtocolHandler
45
import io.rebble.libpebblecommon.packets.AppRunStateMessage
56
import io.rebble.libpebblecommon.protocolhelpers.PebblePacket
67
import io.rebble.libpebblecommon.protocolhelpers.ProtocolEndpoint
78
import io.rebble.libpebblecommon.services.ProtocolService
89
import kotlinx.coroutines.channels.Channel
10+
import kotlinx.coroutines.flow.first
11+
import kotlinx.coroutines.flow.receiveAsFlow
912

1013
class AppRunStateService(private val protocolHandler: ProtocolHandler) : ProtocolService {
1114
val receivedMessages = Channel<AppRunStateMessage>(Channel.BUFFERED)
@@ -26,4 +29,12 @@ class AppRunStateService(private val protocolHandler: ProtocolHandler) : Protoco
2629
receivedMessages.trySend(packet)
2730
}
2831

32+
suspend fun startApp(uuid: Uuid) {
33+
send(AppRunStateMessage.AppRunStateStart(uuid))
34+
}
35+
36+
suspend fun stopApp(uuid: Uuid) {
37+
send(AppRunStateMessage.AppRunStateStop(uuid))
38+
}
39+
2940
}

0 commit comments

Comments
 (0)