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) { 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) { delay(10.seconds) } }