You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

28 lines
714 B

package net.aiterp.git.ykonsole2.infrastructure.drivers
import kotlinx.coroutines.delay
import net.aiterp.git.ykonsole2.domain.runtime.*
import net.aiterp.git.ykonsole2.infrastructure.drivers.abstracts.ActiveDriver
import kotlin.time.Duration.Companion.seconds
class Skipper : ActiveDriver() {
private var enabled: Boolean = false
override suspend fun onCommand(command: Command, output: FlowBus<Event>) {
if (command is ConnectCommand) {
enabled = true
}
if (command is DisconnectCommand) {
enabled = false
}
if (command is SkipCommand && enabled) {
output.emit(Skipped)
}
}
override suspend fun onTick(output: FlowBus<Event>) {
delay(10.seconds)
}
}