多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
# online消息类型 发送消息的统一 function 统一到了server中的 Websocket消息 src/Utils/WebSocket.ts ```javascrip sendSignal(message) { if (!window.N2WSignal) { return alert("socket unavailable!"); } N2WSignal(message) } ``` ## 所有发送的消息 1.MESSAGE_TAG_BROADCAST = 40010001 公共参数 ```javascript { messageTag: MESSAGE_TAG_BROADCAST, messageId: uuidv1(), subTag: "enableControl", //子功能tag periodId, userId, toUserId: userId, } subTag功能 //是否学生允许操作 turnControl enableControl enabled: 0 //0关闭 1开启 //学生点击智齿反馈, help sendHelpStatus enabled:isOpen //0开启中 1关闭了 //设置学生端 笔画的颜色 setUserColor setColor color: color //是否开麦 turnMic enableSpeak enabled: 0 //0关闭 1开启 //老师上下台 turnVideo stage enabled: 1 //0关闭 1开启 x: 0 y: 0 //奖励 加星 sendStar award role:1, //角色信息 STUDENT:1, TEACHER:2, GUEST:3, ASSIST:4 total:5, //数量 ``` #### 2. MESSAGE_TAG_ENTER_ROOM = 10010001 进入房间 enterRoom ``` { messageTag: MESSAGE_TAG_ENTER_ROOM, messageId: uuidv1(), periodId, role, //角色信息 userId, token, p:KKSDK.instance.platform } ``` #### 3.MESSAGE_TAG_LEAVE_ROOM = 10010002 离开房间 leaveRoom ``` { messageTag: MESSAGE_TAG_LEAVE_ROOM, messageId: uuidv1(), periodId, role, userId, token, type:role == 0 ?1:isStopClass } ``` #### 4.MESSAGE_TAG_LESSON_STATE = 10030001 老师点击开始上课按钮 开始课程/结束课程 startLesson/stopLesson ``` { messageTag:MESSAGE_TAG_LESSON_STATE, messageId:uuidv1(), periodId, userId, eventType:1 // 1 startLesson 2stopLesson } ``` ## 所有接收的消息 case MESSAGE_TAG_BROADCAST 40010001 message.subTag == "enableControl" 是否学生允许操作 (自己发的) message.subTag == "enableSpeak" 是否开麦 (自己发的) message.subTag == "stage" 上台 (自己发的) message.subTag == "setColor" 设置画笔颜色 (自己发的) case MESSAGE_TAG_BROADCAST_LEAVE 30010002 用户离开教师 case MESSAGE_TAG_USER_STATE 30030002 用户状态 case MESSAGE_TAG_STAGE_STATE 30030003 舞台状态 老师上下台后 服务端广播 messageId: "1dab7660-a796-11e9-801c-89740897e617" messageTag: 30030003 periodId: 511187 sendMsgType: 2 case MESSAGE_TAG_TEACHER_INFO 30030004 老师进入课堂 服务端推送的教师信息 messageTag: 30030004 periodId: 511187 sendMsgType: 2 teacherId: 220241 teacherName: "炎炎老师" teacherPortrait: "https://img.kktalkee.com/aliyun/student_default