Skip to content

Commit

Permalink
apprunstate util functions
Browse files Browse the repository at this point in the history
  • Loading branch information
crc-32 committed Sep 19, 2024
1 parent 4f2c586 commit fc1285e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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<AppRunStateMessage>(Channel.BUFFERED)
Expand All @@ -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))
}

}

0 comments on commit fc1285e

Please sign in to comment.