package com.adealink.weparty.hardware

import java.util.UUID
import kotlin.math.max
import kotlin.math.min

class ResourceRequest(
    val hardware: Hardware,
    @JvmField val client: HardwareClient,
    priority: HardwarePriority,
    @JvmField val callback: HardwareRequestCallback? = null
) {
    private val requestId: String = UUID.randomUUID().toString()

    @JvmField
    val priority: Int = min(HardwarePriority.HIGH.priority, max(0, priority.priority)) // 0-10, 越高优先级越高
    private val requestTime = System.currentTimeMillis()

    val waitDuration: Long
        get() = System.currentTimeMillis() - requestTime
}

abstract class HardwareClient(
    @JvmField val clientId: String,
    @JvmField val clientDesc: String,
) {
    abstract fun isActive(): Boolean
}

enum class HardwareClientId(val id: String) {
    ROOM("Room"),
    CALL_1V1("Call1v1")
}