zby-live-sdk 1.0.49-beta-talrtc1014 → 1.0.49-beta-1222-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.babelrc +5 -5
- package/.editorconfig +13 -13
- package/.eslintrc.js +29 -29
- package/CHANGELOG.md +419 -377
- package/README.md +276 -276
- package/dist/zby-live-sdk.cjs.js +3 -4
- package/dist/zby-live-sdk.esm.js +3 -4
- package/dist/zby-live-sdk.umd.js +3 -4
- package/package.json +1 -1
- package/src/channel/getSendMsgParams.js +66 -66
- package/src/channel/index.js +138 -138
- package/src/channel/pomelo/index.js +184 -184
- package/src/channel/pomelo/latestQueue.js +151 -151
- package/src/channel/pomelo/polemo.js +749 -749
- package/src/channel/pomelo/util.js +54 -54
- package/src/channel/sdk-cb.js +73 -73
- package/src/channel/stream-msg.js +97 -97
- package/src/channel/zby/index.js +74 -74
- package/src/channel/zby/interactWithChannel.js +4 -4
- package/src/channel/zby/interactWithChannelControl.js +1568 -1568
- package/src/channel/zby/interactWithChannelEntry.js +318 -318
- package/src/config/config.js +153 -153
- package/src/default/base.js +70 -70
- package/src/default/extend.js +36 -36
- package/src/default/index.js +9 -9
- package/src/live/base.js +42 -42
- package/src/live/call-method.js +9 -9
- package/src/live/extend.js +53 -53
- package/src/live/index.js +9 -9
- package/src/network/api.js +50 -50
- package/src/network/commonFetch.js +66 -66
- package/src/network/dataReport.js +429 -429
- package/src/notice.js +400 -394
- package/src/tool/base.js +74 -74
- package/src/tool/call-method.js +9 -9
- package/src/tool/extend.js +42 -42
- package/src/tool/index.js +9 -9
- package/src/util/bridge.js +87 -87
- package/src/util/bridge1.js +46 -46
- package/src/util/dict.js +51 -51
- package/src/util/sessionStorage.js +29 -29
- package/src/util/sha256.js +482 -482
- package/src/util/util.js +308 -308
- package/src/zby-av-sdk/agora-sdk.js +711 -711
- package/src/zby-av-sdk/device.js +145 -145
- package/src/zby-av-sdk/rtc-sdk.js +2845 -2839
- package/src/zby-av-sdk/talrtc-sdk.js +2394 -2392
- package/src/zby-av-sdk/trtc-sdk.js +1801 -1801
- package/src/zby-av-sdk/zby-av-sdk.js +1901 -1891
- package/src/zby-av-sdk/zego-sdk.js +3002 -2987
- package/src/zby-live-sdk.js +1564 -1561
|
@@ -1,318 +1,318 @@
|
|
|
1
|
-
/* eslint-disable */
|
|
2
|
-
/**
|
|
3
|
-
* 消息通道的入口,设置信息后进入房间
|
|
4
|
-
* willxue
|
|
5
|
-
* fbfbc-1@163.com
|
|
6
|
-
* 2016/08/16
|
|
7
|
-
**/
|
|
8
|
-
|
|
9
|
-
// (function () {
|
|
10
|
-
// var w = window;
|
|
11
|
-
import CONTROL from './interactWithChannelControl'
|
|
12
|
-
import bridge from '../../util/bridge'
|
|
13
|
-
let ENTRY = {
|
|
14
|
-
configInfoObj: null, //配置信息
|
|
15
|
-
roomInfoObj: '', //房间信息
|
|
16
|
-
enterMaxCount: 1, //尝试连接并进入房间的次数
|
|
17
|
-
msgindex: 0,
|
|
18
|
-
userid: '',
|
|
19
|
-
role: '',
|
|
20
|
-
logmode: 1,
|
|
21
|
-
channeltype: 1, //0=有所有通道;1=仅有control通道;2=仅有chat通道
|
|
22
|
-
|
|
23
|
-
istestFromhtml: 0, //是否是测试页
|
|
24
|
-
|
|
25
|
-
//public 第一步 设置配置信息,含用户信息等
|
|
26
|
-
setConfigInfo: function (configstr) {
|
|
27
|
-
// configstr = {"address":"http://fwef",
|
|
28
|
-
// "user":{"userid":"123","username":"san","token":"fwe","role":"teacher","avatar":"http:\\fwe","code":"1234"},
|
|
29
|
-
// "language":0,"logmode":0,"channeltype":0}
|
|
30
|
-
try {
|
|
31
|
-
this.recordLogToFile('info', 'channnel init params : ' + configstr);
|
|
32
|
-
this.configInfoObj = JSON.parse(configstr);
|
|
33
|
-
this.configInfoObj.encodetype = 'base64';
|
|
34
|
-
if (this.configInfoObj) {
|
|
35
|
-
this.configInfoObj.user.role = this.translateRole(this.configInfoObj.user.role);
|
|
36
|
-
this.userid = this.configInfoObj.user.userid;
|
|
37
|
-
this.role = this.configInfoObj.user.role;
|
|
38
|
-
this.logmode = this.configInfoObj.logmode;
|
|
39
|
-
var addresslenth = this.configInfoObj.address.length;
|
|
40
|
-
if (addresslenth > 0) {
|
|
41
|
-
if (this.configInfoObj.address[addresslenth - 1] != '\\' && this.configInfoObj.address[addresslenth - 1] != '/') {
|
|
42
|
-
this.configInfoObj.address = this.configInfoObj.address + '/';
|
|
43
|
-
}
|
|
44
|
-
} else {
|
|
45
|
-
this.recordLogToFile('error', 'server addrres is null');
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
if (this.configInfoObj.hasOwnProperty('channeltype')) {
|
|
49
|
-
this.channeltype = this.configInfoObj.channeltype;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
} catch (e) {
|
|
53
|
-
console.log(e);
|
|
54
|
-
}
|
|
55
|
-
},
|
|
56
|
-
|
|
57
|
-
//public 第二步 进入教室
|
|
58
|
-
enterRoom: function (roominfo, dealChannelMsg) {
|
|
59
|
-
// roominfo = {"roomid":"16","classmode":1,"playmode":1,"institutionid":545}
|
|
60
|
-
//此处传入的是客户端定义的课程类型
|
|
61
|
-
//0=无效模式;1=1对1模式;2=小组课模式;3=大班课模式;4=小班课模式,同小组课模式,只不过人数更多,最多20个;5=互动大班课
|
|
62
|
-
//6=口令互动大班课;1000=励模式的互动大班课(TODO: 太特化了,后面看是否能一般化)
|
|
63
|
-
try {
|
|
64
|
-
this.initpara();
|
|
65
|
-
this.msgindex = 0;
|
|
66
|
-
ENTRY.recordLogToFile('info', "enter room info" + roominfo);
|
|
67
|
-
this.roomInfoObj = JSON.parse(roominfo);
|
|
68
|
-
if (this.channeltype == 2) {
|
|
69
|
-
// w.CHAT.enterRoom();
|
|
70
|
-
} else {
|
|
71
|
-
CONTROL.enterRoom(dealChannelMsg);
|
|
72
|
-
}
|
|
73
|
-
} catch (e) {
|
|
74
|
-
console.log(e);
|
|
75
|
-
}
|
|
76
|
-
},
|
|
77
|
-
|
|
78
|
-
leaveRoom: function () {
|
|
79
|
-
if (this.channeltype == 2) {
|
|
80
|
-
if (w.CHAT) {
|
|
81
|
-
w.CHAT.leaveRoom();
|
|
82
|
-
}
|
|
83
|
-
} else {
|
|
84
|
-
CONTROL.leaveRoom();
|
|
85
|
-
}
|
|
86
|
-
},
|
|
87
|
-
|
|
88
|
-
//public 获取配置信息
|
|
89
|
-
getConfigInfo: function () {
|
|
90
|
-
return this.configInfoObj;
|
|
91
|
-
},
|
|
92
|
-
|
|
93
|
-
//public 获取房间信息
|
|
94
|
-
getRoomInfo: function () {
|
|
95
|
-
return this.roomInfoObj;
|
|
96
|
-
},
|
|
97
|
-
|
|
98
|
-
//转换一下用户角色的定义 用户角色 "1=teacher"/"2=student"/"3=assistant"/"4=parent"
|
|
99
|
-
translateRole: function (rolefore) {
|
|
100
|
-
var role = this.configInfoObj.user.role;
|
|
101
|
-
if (typeof rolefore == "string") {
|
|
102
|
-
if (rolefore == 'teacher') {
|
|
103
|
-
role = '1';
|
|
104
|
-
} else if (rolefore == 'student') {
|
|
105
|
-
role = '2';
|
|
106
|
-
} else if (rolefore == 'assistant') {
|
|
107
|
-
role = '3';
|
|
108
|
-
} else if (rolefore == 'parent') {
|
|
109
|
-
role = '4';
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
return role;
|
|
113
|
-
},
|
|
114
|
-
|
|
115
|
-
//转换一下用户角色的定义 用户角色 "1=teacher"/"2=student"/"3=assistant"/"4=parent"
|
|
116
|
-
translateRoleBack: function (rolelocal) {
|
|
117
|
-
if (typeof rolelocal == "string") {
|
|
118
|
-
if (rolelocal == '1') {
|
|
119
|
-
return 'teacher';
|
|
120
|
-
} else if (rolelocal == '2') {
|
|
121
|
-
return 'student';
|
|
122
|
-
} else if (rolelocal == '3') {
|
|
123
|
-
return 'assistant';
|
|
124
|
-
} else if (rolelocal == '4') {
|
|
125
|
-
return 'parent';
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
return '';
|
|
129
|
-
},
|
|
130
|
-
|
|
131
|
-
//判断是否是我自己的消息
|
|
132
|
-
isMyMsg: function (userid) {
|
|
133
|
-
if (this.configInfoObj && this.configInfoObj.user.userid == userid) {
|
|
134
|
-
return true;
|
|
135
|
-
}
|
|
136
|
-
return false;
|
|
137
|
-
},
|
|
138
|
-
|
|
139
|
-
//判断是否是大班课
|
|
140
|
-
isLargeClass: function () {
|
|
141
|
-
if (this.roomInfoObj) {
|
|
142
|
-
if (this.roomInfoObj.classmode == 3 || this.roomInfoObj.classmode == 5 || this.roomInfoObj.classmode == 6 || this.roomInfoObj.classmode == 1000) {
|
|
143
|
-
return true;
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
return false;
|
|
147
|
-
},
|
|
148
|
-
|
|
149
|
-
//获取课程类型,即将客户端传入的课程类型转换成数据库中定义的课程类型,传给信道
|
|
150
|
-
getClassTypeInDb: function () {
|
|
151
|
-
//客户端定义的课程类型
|
|
152
|
-
//0=无效模式;1=1对1模式;2=小组课模式;3=大班课模式;4=小班课模式,同小组课模式,只不过人数更多,最多20个;5=互动大班课
|
|
153
|
-
//6=口令互动大班课;1000=励模式的互动大班课
|
|
154
|
-
//数据库定义课程类型
|
|
155
|
-
//0=一对一';'3'=小组课';'1'=大班课(口令访问)';'2':'大班课(密码访问)';'6':'互动大班课(口令访问)';'5':'互动大班课(密码访问)'
|
|
156
|
-
var classtype = 1;
|
|
157
|
-
if (this.roomInfoObj) {
|
|
158
|
-
classtype = this.roomInfoObj.classmode;
|
|
159
|
-
if (this.roomInfoObj.classmode == 1) {
|
|
160
|
-
classtype = 0;
|
|
161
|
-
} else if (this.roomInfoObj.classmode == 2) {
|
|
162
|
-
classtype = 3;
|
|
163
|
-
} else if (this.roomInfoObj.classmode == 3) {
|
|
164
|
-
classtype = 1; //客户端把口令和密码方式的大班课都统一为了大班课
|
|
165
|
-
} else if (this.roomInfoObj.classmode == 4) {
|
|
166
|
-
classtype = 7; //客户端给的4是小班课
|
|
167
|
-
}
|
|
168
|
-
// 找出互动大班课
|
|
169
|
-
else if (this.roomInfoObj.classmode == 5 || this.roomInfoObj.classmode == 6) {
|
|
170
|
-
classtype = 5; //为了增加信道给麦加的判断
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
return classtype; //默认互动大班课吧
|
|
174
|
-
},
|
|
175
|
-
|
|
176
|
-
//判断是否是我自己的消息
|
|
177
|
-
getMsgIndex: function () {
|
|
178
|
-
this.msgindex++;
|
|
179
|
-
return this.msgindex;
|
|
180
|
-
},
|
|
181
|
-
|
|
182
|
-
//进入房间,初始化参数
|
|
183
|
-
initpara: function () {},
|
|
184
|
-
|
|
185
|
-
parseIntMySimple: function (strvar) {
|
|
186
|
-
var ret = 0;
|
|
187
|
-
for (var i = 0; i < strvar.length; ++i) {
|
|
188
|
-
ret *= 10;
|
|
189
|
-
var num1 = Number(strvar[i]);
|
|
190
|
-
ret += num1;
|
|
191
|
-
}
|
|
192
|
-
return ret;
|
|
193
|
-
},
|
|
194
|
-
|
|
195
|
-
getMsgKey: function (index) {
|
|
196
|
-
var time = new Date();
|
|
197
|
-
var key = this.userid + '_' + this.role + '_' + index + '_' + time.getTime();
|
|
198
|
-
return key;
|
|
199
|
-
},
|
|
200
|
-
|
|
201
|
-
//日志记录 msgtype:0:debug,1:info,2:warnning,3:error,4:critical
|
|
202
|
-
recordLogToFile: function (msgtype, msgbody, productName) {
|
|
203
|
-
try {
|
|
204
|
-
if (msgtype == 'f' && this.logmode == 0) {
|
|
205
|
-
return;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
if (this.channeltype == 0 || this.channeltype == 1) {
|
|
209
|
-
//日志级别,0:debug,1:info,2:warnning,3:error,4:critical
|
|
210
|
-
bridge.writeLog(msgtype, JSON.stringify(msgbody), productName)
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
if (this.channeltype == 2) {
|
|
214
|
-
if (w.chatobj && w.chatobj.onRecordJsLog) {
|
|
215
|
-
w.chatobj.onRecordJsLog(msgtype, msgbody);
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
} catch (e) {}
|
|
219
|
-
},
|
|
220
|
-
|
|
221
|
-
//上报提示信息
|
|
222
|
-
reportHintInfo: function (content) {
|
|
223
|
-
if (w.controlObj && w.controlObj.onSelfHealthReport) {
|
|
224
|
-
w.controlObj.onSelfHealthReport('report', content);
|
|
225
|
-
}
|
|
226
|
-
},
|
|
227
|
-
|
|
228
|
-
//记录try catch异常
|
|
229
|
-
recordException: function (e) {
|
|
230
|
-
try {
|
|
231
|
-
var logmsg = e.stack + '_' + e.message;
|
|
232
|
-
bridge.writeLog('e', logmsg)
|
|
233
|
-
|
|
234
|
-
} catch (e) {}
|
|
235
|
-
},
|
|
236
|
-
|
|
237
|
-
//获取bridge
|
|
238
|
-
setupWebViewJavascriptBridge: function (callback) {
|
|
239
|
-
if (window.WebViewJavascriptBridge) {
|
|
240
|
-
return callback(WebViewJavascriptBridge);
|
|
241
|
-
}
|
|
242
|
-
if (window.WVJBCallbacks) {
|
|
243
|
-
return window.WVJBCallbacks.push(callback);
|
|
244
|
-
}
|
|
245
|
-
window.WVJBCallbacks = [callback];
|
|
246
|
-
var WVJBIframe = document.createElement('iframe');
|
|
247
|
-
WVJBIframe.style.display = 'none';
|
|
248
|
-
WVJBIframe.src = 'wvjbscheme://__BRIDGE_LOADED__';
|
|
249
|
-
document.documentElement.appendChild(WVJBIframe);
|
|
250
|
-
setTimeout(function () {
|
|
251
|
-
document.documentElement.removeChild(WVJBIframe)
|
|
252
|
-
}, 0);
|
|
253
|
-
},
|
|
254
|
-
|
|
255
|
-
// //html模拟客户端调用
|
|
256
|
-
// htmlEnterRoom: function () {
|
|
257
|
-
// var roomid = document.getElementById("roomid").value;
|
|
258
|
-
// var userid = document.getElementById("username").value;
|
|
259
|
-
// var channel = document.getElementById("channeltype").value;
|
|
260
|
-
// var usercodeinput = document.getElementById("usercode").value;
|
|
261
|
-
// var serverurl = document.getElementById("serverurl").value;
|
|
262
|
-
// var tokeninput = document.getElementById("token").value;
|
|
263
|
-
// var instidinput = document.getElementById("instid").value;
|
|
264
|
-
// var username = userid;
|
|
265
|
-
|
|
266
|
-
// var config = {};
|
|
267
|
-
// //config.address = 'http://123.56.176.151:14081/';//开发
|
|
268
|
-
// //config.address = 'http://dev-im.weclassroom.com:14080/';//开发
|
|
269
|
-
// //config.address = 'https://test-im.weclassroom.com';//开发
|
|
270
|
-
// //config.address = 'http://123.56.176.151:14082/';//开发
|
|
271
|
-
|
|
272
|
-
// config.address = serverurl; //开发
|
|
273
|
-
|
|
274
|
-
// //config.address = 'http://123.56.193.134:10080/';
|
|
275
|
-
// config.language = 0;
|
|
276
|
-
// config.logmode = 2;
|
|
277
|
-
// config.user = {};
|
|
278
|
-
// config.user.userid = userid;
|
|
279
|
-
// config.user.username = username;
|
|
280
|
-
// if (usercodeinput != 0) {
|
|
281
|
-
// config.user.code = usercodeinput;
|
|
282
|
-
// config.user.token = '';
|
|
283
|
-
// } else {
|
|
284
|
-
// config.user.token = tokeninput;
|
|
285
|
-
// //config.user.token = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJyb2xlIjoiMiIsInN1YiI6MTAwMDg0LCJpc3MiOiJodHRwczpcL1wvdGVzdC1hcGkud2VjbGFzc3Jvb20uY29tXC91c2VyXC9sb2dpbiIsImlhdCI6MTQ4NzIxNzk0NCwiZXhwIjoxNDg5ODA5OTQ0LCJuYmYiOjE0ODcyMTc5NDQsImp0aSI6IjlmZDcwYzVmOGRkNjM2YTc0MzA2MjI4OGUxYmVlYmQ5In0.RgpquwjhqcYUKf1l3XjbGggbc8Y1jEY_45xZpfgnOIg';
|
|
286
|
-
// }
|
|
287
|
-
|
|
288
|
-
// if (username.indexOf("teacher") == 0) {
|
|
289
|
-
// config.user.role = 'teacher';
|
|
290
|
-
// } else if (username.indexOf('assistant') == 0) {
|
|
291
|
-
// config.user.role = 'assistant';
|
|
292
|
-
// } else {
|
|
293
|
-
// config.user.role = 'student';
|
|
294
|
-
// }
|
|
295
|
-
// config.channeltype = channel;
|
|
296
|
-
|
|
297
|
-
// config.user.avatar = 'http://www.qq1234.org/uploads/allimg/150709/8_150709170804_8.jpg';
|
|
298
|
-
// this.setConfigInfo(JSON.stringify(config));
|
|
299
|
-
|
|
300
|
-
// var roominfo = {};
|
|
301
|
-
// roominfo.roomid = roomid;
|
|
302
|
-
// roominfo.classmode = 5; //1=1对1模式;2=1对多模式;3=大班课模式;5=互动大班课密码;6=互动大班课口令
|
|
303
|
-
// roominfo.playmode = 1;
|
|
304
|
-
// roominfo.institutionid = instidinput;
|
|
305
|
-
// this.enterRoom(JSON.stringify(roominfo));
|
|
306
|
-
// this.istestFromhtml = 1;
|
|
307
|
-
|
|
308
|
-
// if (w.CHATEST) {
|
|
309
|
-
// w.CHATEST.checkorder = 1;
|
|
310
|
-
// }
|
|
311
|
-
// },
|
|
312
|
-
|
|
313
|
-
// htmlLeaveRoom: function () {
|
|
314
|
-
// CONTROL.leaveRoom();
|
|
315
|
-
// }
|
|
316
|
-
};
|
|
317
|
-
export default ENTRY
|
|
318
|
-
// })();
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
/**
|
|
3
|
+
* 消息通道的入口,设置信息后进入房间
|
|
4
|
+
* willxue
|
|
5
|
+
* fbfbc-1@163.com
|
|
6
|
+
* 2016/08/16
|
|
7
|
+
**/
|
|
8
|
+
|
|
9
|
+
// (function () {
|
|
10
|
+
// var w = window;
|
|
11
|
+
import CONTROL from './interactWithChannelControl'
|
|
12
|
+
import bridge from '../../util/bridge'
|
|
13
|
+
let ENTRY = {
|
|
14
|
+
configInfoObj: null, //配置信息
|
|
15
|
+
roomInfoObj: '', //房间信息
|
|
16
|
+
enterMaxCount: 1, //尝试连接并进入房间的次数
|
|
17
|
+
msgindex: 0,
|
|
18
|
+
userid: '',
|
|
19
|
+
role: '',
|
|
20
|
+
logmode: 1,
|
|
21
|
+
channeltype: 1, //0=有所有通道;1=仅有control通道;2=仅有chat通道
|
|
22
|
+
|
|
23
|
+
istestFromhtml: 0, //是否是测试页
|
|
24
|
+
|
|
25
|
+
//public 第一步 设置配置信息,含用户信息等
|
|
26
|
+
setConfigInfo: function (configstr) {
|
|
27
|
+
// configstr = {"address":"http://fwef",
|
|
28
|
+
// "user":{"userid":"123","username":"san","token":"fwe","role":"teacher","avatar":"http:\\fwe","code":"1234"},
|
|
29
|
+
// "language":0,"logmode":0,"channeltype":0}
|
|
30
|
+
try {
|
|
31
|
+
this.recordLogToFile('info', 'channnel init params : ' + configstr);
|
|
32
|
+
this.configInfoObj = JSON.parse(configstr);
|
|
33
|
+
this.configInfoObj.encodetype = 'base64';
|
|
34
|
+
if (this.configInfoObj) {
|
|
35
|
+
this.configInfoObj.user.role = this.translateRole(this.configInfoObj.user.role);
|
|
36
|
+
this.userid = this.configInfoObj.user.userid;
|
|
37
|
+
this.role = this.configInfoObj.user.role;
|
|
38
|
+
this.logmode = this.configInfoObj.logmode;
|
|
39
|
+
var addresslenth = this.configInfoObj.address.length;
|
|
40
|
+
if (addresslenth > 0) {
|
|
41
|
+
if (this.configInfoObj.address[addresslenth - 1] != '\\' && this.configInfoObj.address[addresslenth - 1] != '/') {
|
|
42
|
+
this.configInfoObj.address = this.configInfoObj.address + '/';
|
|
43
|
+
}
|
|
44
|
+
} else {
|
|
45
|
+
this.recordLogToFile('error', 'server addrres is null');
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (this.configInfoObj.hasOwnProperty('channeltype')) {
|
|
49
|
+
this.channeltype = this.configInfoObj.channeltype;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
} catch (e) {
|
|
53
|
+
console.log(e);
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
|
|
57
|
+
//public 第二步 进入教室
|
|
58
|
+
enterRoom: function (roominfo, dealChannelMsg) {
|
|
59
|
+
// roominfo = {"roomid":"16","classmode":1,"playmode":1,"institutionid":545}
|
|
60
|
+
//此处传入的是客户端定义的课程类型
|
|
61
|
+
//0=无效模式;1=1对1模式;2=小组课模式;3=大班课模式;4=小班课模式,同小组课模式,只不过人数更多,最多20个;5=互动大班课
|
|
62
|
+
//6=口令互动大班课;1000=励模式的互动大班课(TODO: 太特化了,后面看是否能一般化)
|
|
63
|
+
try {
|
|
64
|
+
this.initpara();
|
|
65
|
+
this.msgindex = 0;
|
|
66
|
+
ENTRY.recordLogToFile('info', "enter room info" + roominfo);
|
|
67
|
+
this.roomInfoObj = JSON.parse(roominfo);
|
|
68
|
+
if (this.channeltype == 2) {
|
|
69
|
+
// w.CHAT.enterRoom();
|
|
70
|
+
} else {
|
|
71
|
+
CONTROL.enterRoom(dealChannelMsg);
|
|
72
|
+
}
|
|
73
|
+
} catch (e) {
|
|
74
|
+
console.log(e);
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
|
|
78
|
+
leaveRoom: function () {
|
|
79
|
+
if (this.channeltype == 2) {
|
|
80
|
+
if (w.CHAT) {
|
|
81
|
+
w.CHAT.leaveRoom();
|
|
82
|
+
}
|
|
83
|
+
} else {
|
|
84
|
+
CONTROL.leaveRoom();
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
|
|
88
|
+
//public 获取配置信息
|
|
89
|
+
getConfigInfo: function () {
|
|
90
|
+
return this.configInfoObj;
|
|
91
|
+
},
|
|
92
|
+
|
|
93
|
+
//public 获取房间信息
|
|
94
|
+
getRoomInfo: function () {
|
|
95
|
+
return this.roomInfoObj;
|
|
96
|
+
},
|
|
97
|
+
|
|
98
|
+
//转换一下用户角色的定义 用户角色 "1=teacher"/"2=student"/"3=assistant"/"4=parent"
|
|
99
|
+
translateRole: function (rolefore) {
|
|
100
|
+
var role = this.configInfoObj.user.role;
|
|
101
|
+
if (typeof rolefore == "string") {
|
|
102
|
+
if (rolefore == 'teacher') {
|
|
103
|
+
role = '1';
|
|
104
|
+
} else if (rolefore == 'student') {
|
|
105
|
+
role = '2';
|
|
106
|
+
} else if (rolefore == 'assistant') {
|
|
107
|
+
role = '3';
|
|
108
|
+
} else if (rolefore == 'parent') {
|
|
109
|
+
role = '4';
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return role;
|
|
113
|
+
},
|
|
114
|
+
|
|
115
|
+
//转换一下用户角色的定义 用户角色 "1=teacher"/"2=student"/"3=assistant"/"4=parent"
|
|
116
|
+
translateRoleBack: function (rolelocal) {
|
|
117
|
+
if (typeof rolelocal == "string") {
|
|
118
|
+
if (rolelocal == '1') {
|
|
119
|
+
return 'teacher';
|
|
120
|
+
} else if (rolelocal == '2') {
|
|
121
|
+
return 'student';
|
|
122
|
+
} else if (rolelocal == '3') {
|
|
123
|
+
return 'assistant';
|
|
124
|
+
} else if (rolelocal == '4') {
|
|
125
|
+
return 'parent';
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return '';
|
|
129
|
+
},
|
|
130
|
+
|
|
131
|
+
//判断是否是我自己的消息
|
|
132
|
+
isMyMsg: function (userid) {
|
|
133
|
+
if (this.configInfoObj && this.configInfoObj.user.userid == userid) {
|
|
134
|
+
return true;
|
|
135
|
+
}
|
|
136
|
+
return false;
|
|
137
|
+
},
|
|
138
|
+
|
|
139
|
+
//判断是否是大班课
|
|
140
|
+
isLargeClass: function () {
|
|
141
|
+
if (this.roomInfoObj) {
|
|
142
|
+
if (this.roomInfoObj.classmode == 3 || this.roomInfoObj.classmode == 5 || this.roomInfoObj.classmode == 6 || this.roomInfoObj.classmode == 1000) {
|
|
143
|
+
return true;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
return false;
|
|
147
|
+
},
|
|
148
|
+
|
|
149
|
+
//获取课程类型,即将客户端传入的课程类型转换成数据库中定义的课程类型,传给信道
|
|
150
|
+
getClassTypeInDb: function () {
|
|
151
|
+
//客户端定义的课程类型
|
|
152
|
+
//0=无效模式;1=1对1模式;2=小组课模式;3=大班课模式;4=小班课模式,同小组课模式,只不过人数更多,最多20个;5=互动大班课
|
|
153
|
+
//6=口令互动大班课;1000=励模式的互动大班课
|
|
154
|
+
//数据库定义课程类型
|
|
155
|
+
//0=一对一';'3'=小组课';'1'=大班课(口令访问)';'2':'大班课(密码访问)';'6':'互动大班课(口令访问)';'5':'互动大班课(密码访问)'
|
|
156
|
+
var classtype = 1;
|
|
157
|
+
if (this.roomInfoObj) {
|
|
158
|
+
classtype = this.roomInfoObj.classmode;
|
|
159
|
+
if (this.roomInfoObj.classmode == 1) {
|
|
160
|
+
classtype = 0;
|
|
161
|
+
} else if (this.roomInfoObj.classmode == 2) {
|
|
162
|
+
classtype = 3;
|
|
163
|
+
} else if (this.roomInfoObj.classmode == 3) {
|
|
164
|
+
classtype = 1; //客户端把口令和密码方式的大班课都统一为了大班课
|
|
165
|
+
} else if (this.roomInfoObj.classmode == 4) {
|
|
166
|
+
classtype = 7; //客户端给的4是小班课
|
|
167
|
+
}
|
|
168
|
+
// 找出互动大班课
|
|
169
|
+
else if (this.roomInfoObj.classmode == 5 || this.roomInfoObj.classmode == 6) {
|
|
170
|
+
classtype = 5; //为了增加信道给麦加的判断
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
return classtype; //默认互动大班课吧
|
|
174
|
+
},
|
|
175
|
+
|
|
176
|
+
//判断是否是我自己的消息
|
|
177
|
+
getMsgIndex: function () {
|
|
178
|
+
this.msgindex++;
|
|
179
|
+
return this.msgindex;
|
|
180
|
+
},
|
|
181
|
+
|
|
182
|
+
//进入房间,初始化参数
|
|
183
|
+
initpara: function () {},
|
|
184
|
+
|
|
185
|
+
parseIntMySimple: function (strvar) {
|
|
186
|
+
var ret = 0;
|
|
187
|
+
for (var i = 0; i < strvar.length; ++i) {
|
|
188
|
+
ret *= 10;
|
|
189
|
+
var num1 = Number(strvar[i]);
|
|
190
|
+
ret += num1;
|
|
191
|
+
}
|
|
192
|
+
return ret;
|
|
193
|
+
},
|
|
194
|
+
|
|
195
|
+
getMsgKey: function (index) {
|
|
196
|
+
var time = new Date();
|
|
197
|
+
var key = this.userid + '_' + this.role + '_' + index + '_' + time.getTime();
|
|
198
|
+
return key;
|
|
199
|
+
},
|
|
200
|
+
|
|
201
|
+
//日志记录 msgtype:0:debug,1:info,2:warnning,3:error,4:critical
|
|
202
|
+
recordLogToFile: function (msgtype, msgbody, productName) {
|
|
203
|
+
try {
|
|
204
|
+
if (msgtype == 'f' && this.logmode == 0) {
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
if (this.channeltype == 0 || this.channeltype == 1) {
|
|
209
|
+
//日志级别,0:debug,1:info,2:warnning,3:error,4:critical
|
|
210
|
+
bridge.writeLog(msgtype, JSON.stringify(msgbody), productName)
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
if (this.channeltype == 2) {
|
|
214
|
+
if (w.chatobj && w.chatobj.onRecordJsLog) {
|
|
215
|
+
w.chatobj.onRecordJsLog(msgtype, msgbody);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
} catch (e) {}
|
|
219
|
+
},
|
|
220
|
+
|
|
221
|
+
//上报提示信息
|
|
222
|
+
reportHintInfo: function (content) {
|
|
223
|
+
if (w.controlObj && w.controlObj.onSelfHealthReport) {
|
|
224
|
+
w.controlObj.onSelfHealthReport('report', content);
|
|
225
|
+
}
|
|
226
|
+
},
|
|
227
|
+
|
|
228
|
+
//记录try catch异常
|
|
229
|
+
recordException: function (e) {
|
|
230
|
+
try {
|
|
231
|
+
var logmsg = e.stack + '_' + e.message;
|
|
232
|
+
bridge.writeLog('e', logmsg)
|
|
233
|
+
|
|
234
|
+
} catch (e) {}
|
|
235
|
+
},
|
|
236
|
+
|
|
237
|
+
//获取bridge
|
|
238
|
+
setupWebViewJavascriptBridge: function (callback) {
|
|
239
|
+
if (window.WebViewJavascriptBridge) {
|
|
240
|
+
return callback(WebViewJavascriptBridge);
|
|
241
|
+
}
|
|
242
|
+
if (window.WVJBCallbacks) {
|
|
243
|
+
return window.WVJBCallbacks.push(callback);
|
|
244
|
+
}
|
|
245
|
+
window.WVJBCallbacks = [callback];
|
|
246
|
+
var WVJBIframe = document.createElement('iframe');
|
|
247
|
+
WVJBIframe.style.display = 'none';
|
|
248
|
+
WVJBIframe.src = 'wvjbscheme://__BRIDGE_LOADED__';
|
|
249
|
+
document.documentElement.appendChild(WVJBIframe);
|
|
250
|
+
setTimeout(function () {
|
|
251
|
+
document.documentElement.removeChild(WVJBIframe)
|
|
252
|
+
}, 0);
|
|
253
|
+
},
|
|
254
|
+
|
|
255
|
+
// //html模拟客户端调用
|
|
256
|
+
// htmlEnterRoom: function () {
|
|
257
|
+
// var roomid = document.getElementById("roomid").value;
|
|
258
|
+
// var userid = document.getElementById("username").value;
|
|
259
|
+
// var channel = document.getElementById("channeltype").value;
|
|
260
|
+
// var usercodeinput = document.getElementById("usercode").value;
|
|
261
|
+
// var serverurl = document.getElementById("serverurl").value;
|
|
262
|
+
// var tokeninput = document.getElementById("token").value;
|
|
263
|
+
// var instidinput = document.getElementById("instid").value;
|
|
264
|
+
// var username = userid;
|
|
265
|
+
|
|
266
|
+
// var config = {};
|
|
267
|
+
// //config.address = 'http://123.56.176.151:14081/';//开发
|
|
268
|
+
// //config.address = 'http://dev-im.weclassroom.com:14080/';//开发
|
|
269
|
+
// //config.address = 'https://test-im.weclassroom.com';//开发
|
|
270
|
+
// //config.address = 'http://123.56.176.151:14082/';//开发
|
|
271
|
+
|
|
272
|
+
// config.address = serverurl; //开发
|
|
273
|
+
|
|
274
|
+
// //config.address = 'http://123.56.193.134:10080/';
|
|
275
|
+
// config.language = 0;
|
|
276
|
+
// config.logmode = 2;
|
|
277
|
+
// config.user = {};
|
|
278
|
+
// config.user.userid = userid;
|
|
279
|
+
// config.user.username = username;
|
|
280
|
+
// if (usercodeinput != 0) {
|
|
281
|
+
// config.user.code = usercodeinput;
|
|
282
|
+
// config.user.token = '';
|
|
283
|
+
// } else {
|
|
284
|
+
// config.user.token = tokeninput;
|
|
285
|
+
// //config.user.token = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJyb2xlIjoiMiIsInN1YiI6MTAwMDg0LCJpc3MiOiJodHRwczpcL1wvdGVzdC1hcGkud2VjbGFzc3Jvb20uY29tXC91c2VyXC9sb2dpbiIsImlhdCI6MTQ4NzIxNzk0NCwiZXhwIjoxNDg5ODA5OTQ0LCJuYmYiOjE0ODcyMTc5NDQsImp0aSI6IjlmZDcwYzVmOGRkNjM2YTc0MzA2MjI4OGUxYmVlYmQ5In0.RgpquwjhqcYUKf1l3XjbGggbc8Y1jEY_45xZpfgnOIg';
|
|
286
|
+
// }
|
|
287
|
+
|
|
288
|
+
// if (username.indexOf("teacher") == 0) {
|
|
289
|
+
// config.user.role = 'teacher';
|
|
290
|
+
// } else if (username.indexOf('assistant') == 0) {
|
|
291
|
+
// config.user.role = 'assistant';
|
|
292
|
+
// } else {
|
|
293
|
+
// config.user.role = 'student';
|
|
294
|
+
// }
|
|
295
|
+
// config.channeltype = channel;
|
|
296
|
+
|
|
297
|
+
// config.user.avatar = 'http://www.qq1234.org/uploads/allimg/150709/8_150709170804_8.jpg';
|
|
298
|
+
// this.setConfigInfo(JSON.stringify(config));
|
|
299
|
+
|
|
300
|
+
// var roominfo = {};
|
|
301
|
+
// roominfo.roomid = roomid;
|
|
302
|
+
// roominfo.classmode = 5; //1=1对1模式;2=1对多模式;3=大班课模式;5=互动大班课密码;6=互动大班课口令
|
|
303
|
+
// roominfo.playmode = 1;
|
|
304
|
+
// roominfo.institutionid = instidinput;
|
|
305
|
+
// this.enterRoom(JSON.stringify(roominfo));
|
|
306
|
+
// this.istestFromhtml = 1;
|
|
307
|
+
|
|
308
|
+
// if (w.CHATEST) {
|
|
309
|
+
// w.CHATEST.checkorder = 1;
|
|
310
|
+
// }
|
|
311
|
+
// },
|
|
312
|
+
|
|
313
|
+
// htmlLeaveRoom: function () {
|
|
314
|
+
// CONTROL.leaveRoom();
|
|
315
|
+
// }
|
|
316
|
+
};
|
|
317
|
+
export default ENTRY
|
|
318
|
+
// })();
|