EngineEntrance.js
4.5 KB
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
import Emiter from './Emiter';
import Sass from 'Sass';
import Mcu from 'mcu';
import MessageTypes from 'MessageTypes';
import Loger from 'Loger';
import ConferApe from 'apes/ConferApe';
import ChatApe from 'apes/ChatApe';
import VideoChat from 'apes/VideoApe';
import DocApe from 'apes/DocApe';
import WhiteBoardApe from 'apes/WhiteBoardApe';
import EngineUtils from "EngineUtils";
let loger = Loger.getLoger('MessageEntrance');
let info={"version":"v1.0.0","author":"3mang"};
let confInfo={};
let sass;
let mcu ;
let confer_ape;
let chat_ape;
let video_ape;
let doc_ape;
let wb_ape;
export default class MessageEntrance extends Emiter {
constructor() {
super();
this.info=info;
// 应用层会议信息
confInfo = {};
// Sass平台层
sass = Sass;
sass.on('*', (type, data) => this._emit(type, data));
sass.on(sass.SUCCESS, this._h5SassSuccessHandler.bind(this));
// 底层MCU消息层
mcu = Mcu;
mcu.on('*', (type, data) => this._emit(type, data));
mcu.on(MessageTypes.CONFERENCE_JOIN_SUCCESS, this._conferenceJoinSuccessHandler.bind(this));
// 注册所有应用Ape
confer_ape = new ConferApe();
confer_ape.on('*', (type, data) => this._emit(type, data));
confer_ape.on(MessageTypes.DOC_SWITCH, this.docSwitchHandler.bind(this));
chat_ape = new ChatApe();
chat_ape.on('*', (type, data) => this._emit(type, data));
video_ape = new VideoChat();
video_ape.on('*', (type, data) => this._emit(type, data));
doc_ape = new DocApe();
doc_ape.on('*', (type, data) => this._emit(type, data));
doc_ape.on(MessageTypes.DOC_UPDATE, this.docUpdateHandler.bind(this));
doc_ape.on(MessageTypes.DOC_DEL, this.docDeleteHandler.bind(this));
wb_ape = new WhiteBoardApe();
wb_ape.on('*', (type, data) => this._emit(type, data));
wb_ape.on(MessageTypes.ANNO_UPDATE, this.annoUpdateHandler.bind(this));
this.on(MessageTypes.DOC_SHOW, this.docShowHandler.bind(this));
this.sendChatMsg=this._sendChatMsg;
this.joinClass=this._joinClass;
}
// 进入会议
_joinClass(_confInfo) {
confInfo = _confInfo||{};
if(confInfo===null||EngineUtils.isEmptyObject(confInfo)){
loger.log('不能进入会议,传递的参数不对.',_confInfo);
return ;
}
if(sass){
sass.sassChecking(_confInfo);
}
}
// 离开会议
leaveClass() {
if(mcu){
mcu.leaveMCU();
}
}
// 通过SASS平台验证
_h5SassSuccessHandler() {
loger.log('加入底层MCU会议.'+confInfo.toString());
if(mcu){
mcu.joinMCU(confInfo);
}
}
// MCU 会议成功
_conferenceJoinSuccessHandler() {
if(sass){
sass.getClassDetail();//会议信息
sass.getMeetingParm();//会议参数大全
}
}
// 参会处理
conferenceHandler(msg_type) {
var msg = {
type: msg_type,
data: null
};
this._emit(msg.type, msg);
}
// 发送聊天消息
/* _sendChatMsg(to, msg) {
if (chat_ape) {
chat_ape.sendChatMsg(to, msg);
}
}*/
_sendChatMsg(_messageInfo) {
if(_messageInfo===null||EngineUtils.isEmptyObject(_messageInfo)){
loger.log('sendChatMsg 传递的参数不对',_messageInfo);
return ;
}
if (chat_ape) {
chat_ape.sendChatMsg(_messageInfo);
}
}
// 白板笔记更新
annoUpdateHandler(annoInfo) {
const activeDocId = confer_ape.activeDocId;
const docItem = doc_ape.docList[activeDocId];
if (docItem && annoInfo.id == docItem.wbid) {
this._emit(MessageTypes.DOC_ANNO, annoInfo);
}
}
// 文档变更-笔记处理
docShowHandler(docItem) {
loger.log('Doc Show ->' + docItem.id + '|' + docItem.curPageNo);
const annoInfo = wb_ape.annoInfos[docItem.wbid];
if (annoInfo) {
this._emit(MessageTypes.DOC_ANNO, annoInfo);
} else {
this._emit(MessageTypes.DOC_ANNO);
}
}
// 文档切换
docSwitchHandler() {
const activeDocId = confer_ape.activeDocId;
loger.log('Switch Doc Active -> ' + activeDocId);
const docItem = doc_ape.docList[activeDocId];
if (docItem) {
this._emit(MessageTypes.DOC_SHOW, docItem);
}
}
// 文档变更
docUpdateHandler(docItem) {
loger.log('Doc UpdateId ->' + docItem.id + '| activeDocId ->' + confer_ape.activeDocId);
if (docItem.id == confer_ape.activeDocId) {
this._emit(MessageTypes.DOC_SHOW, docItem);
}
}
//文档删除
docDeleteHandler(docItem){
if (docItem.id == confer_ape.activeDocId) {
this._emit(MessageTypes.DOC_DEL, docItem);
}
}
}
//MessageEntrance.MessageTypes = MessageTypes;