package com.adealink.frame.room.data

import android.os.Parcelable
import com.google.gson.annotations.JsonAdapter
import com.google.gson.annotations.Must
import com.google.gson.annotations.SerializedName
import kotlinx.parcelize.Parcelize


data class RoomMemberOnlineInfo(
    @SerializedName("onlinePersons") val onlineMemberCount: Long, //非必需，join room时不会返回，notify会
    @Must
    @SerializedName("ownerInRoom") val ownerInRoom: Int,
    @Must
    @SerializedName("onlineInfoVersion") val version: Long,
)

@Parcelize
data class CpRoomInfo(
    @SerializedName("roomId") val roomId: Long = 0,
    @SerializedName("owner") val owner: Long = 0,
    @SerializedName("name") val name: String? = null,
    @SerializedName("picurl") val picurl: String? = null,
    @SerializedName("userAvatarUrl") val userAvatarUrl: String? = null,
    @SerializedName("setPassword") val setPassword: Boolean = false,
    @SerializedName("persons") val persons: Int = 0,
    @SerializedName("isNew") val isNew: Boolean = false,
): Parcelable

@Parcelize
data class TagInfo(
    @SerializedName("expireTime")
    val expireTime: Long,
    @SerializedName("rank")
    val rank: Int,
    @SerializedName("tagId")
    val tagId: Int,
    @SerializedName("time")
    val time: Int,
    @SerializedName("type")
    val type: Int
): Parcelable

/**
 * 进房结果
 */
data class JoinRoomReq(
    val roomId: Long,
    val from: String, /*进房来源*/
    val password: String? = null,
    val reconnectJoinRoom: Boolean = false,
    @SerializedName("invisibleJoin") val invisibleJoin: Boolean? = null,
)

/**
 * 退房请求
 */
data class LeaveRoomReq(
    val roomId: Long,
    val reason: LeaveRoomReason,
)

enum class LeaveRoomReason(val reason: String) {
    JOIN_CHANNEL_FAILED("join_channel_failed"),
    INITIATIVE("initiative"),
    KICK_OUT("kick_out"),
    ENTER_OTHER_ROOM("enter_other_room"),
    LOGOUT("logout"),
    //REJOIN("rejoin"), //切换协程后,重进房不会退房
    ENTER_OTHER_MEDIA("enter_other_media"),

    GUARD_TREASURE_FAIL("guard_treasure_fail"),
    GUARD_TREASURE_SUCCESS("guard_treasure_success"),
    GUARD_TREASURE_NOT_PARTNER("guard_treasure_not_partner"),
}

enum class JoinChannelReason(val reason: String) {
    ON_LINE_MEMBER_GT_1("on_line_member_gt_1"),
    MIC_ON_MEMBER_GT_1("mic_on_member_gt_1"),
    REJOIN_RUNNABLE("rejoin_runnable"),
    PLAY_MUSIC("play_music"),
    RTC_CHANGED("rtc_changed"),
    SOCKET_RECONNECTED("socket_reconnected"),
}

enum class LeaveChannelReason(val reason: String) {
    ON_LINE_MEMBER_LE_1("on_line_member_le_1"),
    JOIN_CHANNEL_ROOM_SWITCH("join_channel_room_switch"),
    INITIATIVE("initiative"),
    CLOSE_MUSIC("close_music"),
    RTC_CHANGED("rtc_changed"),
    SOCKET_CLOSED("socket_closed"),
}