79 分钟以前 0be509d1d1485b4d8593da8ef125cca3d079d235
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package cn.iocoder.yudao.module.im.enums.rtc;
 
import cn.hutool.core.collection.ListUtil;
import cn.iocoder.yudao.framework.common.core.ArrayValuable;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
 
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
 
/**
 * IM 通话状态枚举(主表 status)
 * <p>
 * 状态机:CREATED → RUNNING → ENDED;CREATED 直接到 ENDED 表示无人接听 / 主叫取消
 *
 * @author 芋道源码
 */
@RequiredArgsConstructor
@Getter
public enum ImRtcCallStatusEnum implements ArrayValuable<Integer> {
 
    CREATED(10, "创建"), // 通话已创建;私聊:等被叫接听;群聊:发起人已进房,等其他人加入
    RUNNING(20, "进行中"), // 第一个非发起人接通后进入
    ENDED(30, "已结束"); // 任一方挂断 / 主叫 cancel / Webhook 兜底
 
    public static final Integer[] ARRAYS = Arrays.stream(values()).map(ImRtcCallStatusEnum::getStatus).toArray(Integer[]::new);
 
    /**
     * 活跃状态集合;通话未结束(CREATED / RUNNING)
     */
    public static final List<Integer> ACTIVE_STATUSES = ListUtil.of(CREATED.getStatus(), RUNNING.getStatus());
 
    /**
     * 状态值
     */
    private final Integer status;
    /**
     * 状态名
     */
    private final String name;
 
    @Override
    public Integer[] array() {
        return ARRAYS;
    }
 
    public static boolean isCreated(Integer status) {
        return Objects.equals(CREATED.status, status);
    }
 
    public static boolean isRunning(Integer status) {
        return Objects.equals(RUNNING.status, status);
    }
 
    public static boolean isEnded(Integer status) {
        return Objects.equals(ENDED.status, status);
    }
 
}