package com.adealink.weparty.room.data

import com.adealink.frame.aab.util.getCompatString
import com.adealink.frame.base.IError
import com.adealink.weparty.room.R


const val APPLY_MIC_ONLY_HOST_ERROR = 50001


data class SeatAudioLockError(override val msg: String = getCompatString(R.string.room_err_seat_audio_locked)) : IError()

data class ApplyMicOnlyHostError(
    override var serverCode: Int = APPLY_MIC_ONLY_HOST_ERROR,
    override val msg: String = getCompatString(R.string.room_request_host_mic_fail_for_no_host_permission)
) : IError()


/**
 * 腾讯 RTC Live错误码
 * https://trtc.io/zh/document/60027?product=live&menulabel=core%20sdk&platform=ios#19824d9a-21d7-4656-9594-694e2eeb481a
 */
//const val TRTC_ROOM_ERROR_100001 = 100001 //服务器内部错误，请重试
//const val TRTC_ROOM_ERROR_100002 = 100002 //参数非法，请根据错误描述检查请求是否正确
//const val TRTC_ROOM_ERROR_100003 = 100003 //房间ID 已被使用，请选择别的房间ID
const val TRTC_ROOM_ERROR_100004 = 100004 //房间不存在，或者曾经存在过，但是目前已经被解散。
const val TRTC_ROOM_ERROR_100005 = 100005 //非房间成员
const val TRTC_ROOM_ERROR_100006 = 100006 //操作权限不足

//const val TRTC_ROOM_ERROR_100007 = 100007 //无付费信息，需在控制台购买套餐包(需要特殊上报)
const val TRTC_ROOM_ERROR_100008 = 100008 //房间成员已满
const val TRTC_ROOM_ERROR_100009 = 100009 //标签数量超上限

//const val TRTC_ROOM_ERROR_100010 = 100010 //房间 ID 已被使用，并且操作者为房主，可以直接使用
//const val TRTC_ROOM_ERROR_100011 = 100011 //房间 ID 已被 Chat 占用，可以换一个房间 ID 使用，或者先通过 Chat 接口解散该群
//const val TRTC_ROOM_ERROR_100012 = 100012 //频率超过限制，例如创建房间频率超限，同一房间 ID， 1秒内只能创建一次
//const val TRTC_ROOM_ERROR_100013 = 100013 //超过付费上限，例如麦位数，pk场次房间数量等超过付费限制
//const val TRTC_ROOM_ERROR_100015 = 100015 //无效的房间类型
const val TRTC_ROOM_ERROR_100016 = 100016 //该成员已经被封禁
const val TRTC_ROOM_ERROR_100017 = 100017 //该成员已经被禁言
const val TRTC_ROOM_ERROR_100018 = 100018 //当前房间需要密码才能进入
const val TRTC_ROOM_ERROR_100019 = 100019 //进房密码错误
const val TRTC_ROOM_ERROR_100020 = 100029 //管理员数量超过上限

fun getError(code: Int, desc: String): IError {
    return when (code) {
        TRTC_ROOM_ERROR_100004 -> IError(msg = getCompatString(R.string.room_trtc_error_100004), serverCode = code)
        TRTC_ROOM_ERROR_100005 -> IError(msg = getCompatString(R.string.room_trtc_error_100005), serverCode = code)
        TRTC_ROOM_ERROR_100006 -> IError(msg = getCompatString(R.string.room_trtc_error_100006), serverCode = code)
        TRTC_ROOM_ERROR_100008 -> IError(msg = getCompatString(R.string.room_trtc_error_100008), serverCode = code)
        TRTC_ROOM_ERROR_100009 -> IError(msg = getCompatString(R.string.room_trtc_error_100009), serverCode = code)
        TRTC_ROOM_ERROR_100016 -> IError(msg = getCompatString(R.string.room_trtc_error_100016), serverCode = code)
        TRTC_ROOM_ERROR_100017 -> IError(msg = getCompatString(R.string.room_trtc_error_100017), serverCode = code)
        TRTC_ROOM_ERROR_100018 -> IError(msg = getCompatString(R.string.room_trtc_error_100018), serverCode = code)
        TRTC_ROOM_ERROR_100019 -> IError(msg = getCompatString(R.string.room_trtc_error_100019), serverCode = code)
        TRTC_ROOM_ERROR_100020 -> IError(msg = getCompatString(R.string.room_trtc_error_100020), serverCode = code)
        else -> IError(msg = desc, serverCode = code)
    }
}