zbzt-live-sdk 0.0.2

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.
Files changed (80) hide show
  1. package/.babelrc +8 -0
  2. package/.editorconfig +13 -0
  3. package/.eslintrc.js +29 -0
  4. package/CHANGELOG.md +16 -0
  5. package/README.md +32 -0
  6. package/dist/zbzt-live-sdk.cjs.js +51 -0
  7. package/dist/zbzt-live-sdk.esm.js +51 -0
  8. package/dist/zbzt-live-sdk.umd.js +52 -0
  9. package/dist/zbzt-live-sdk.umd.js.map +1 -0
  10. package/example/app.js +133 -0
  11. package/example/bootstrap-3.4.1/css/bootstrap-theme.css +587 -0
  12. package/example/bootstrap-3.4.1/css/bootstrap-theme.css.map +1 -0
  13. package/example/bootstrap-3.4.1/css/bootstrap-theme.min.css +6 -0
  14. package/example/bootstrap-3.4.1/css/bootstrap-theme.min.css.map +1 -0
  15. package/example/bootstrap-3.4.1/css/bootstrap.css +6834 -0
  16. package/example/bootstrap-3.4.1/css/bootstrap.css.map +1 -0
  17. package/example/bootstrap-3.4.1/css/bootstrap.min.css +6 -0
  18. package/example/bootstrap-3.4.1/css/bootstrap.min.css.map +1 -0
  19. package/example/bootstrap-3.4.1/fonts/glyphicons-halflings-regular.eot +0 -0
  20. package/example/bootstrap-3.4.1/fonts/glyphicons-halflings-regular.svg +288 -0
  21. package/example/bootstrap-3.4.1/fonts/glyphicons-halflings-regular.ttf +0 -0
  22. package/example/bootstrap-3.4.1/fonts/glyphicons-halflings-regular.woff +0 -0
  23. package/example/bootstrap-3.4.1/fonts/glyphicons-halflings-regular.woff2 +0 -0
  24. package/example/bootstrap-3.4.1/js/bootstrap.js +2580 -0
  25. package/example/bootstrap-3.4.1/js/bootstrap.min.js +6 -0
  26. package/example/bootstrap-3.4.1/js/npm.js +13 -0
  27. package/example/css/style.css +18 -0
  28. package/example/index.html +59 -0
  29. package/example/js/jquery-3.7.1.min.js +2 -0
  30. package/example/js/utils.js +25 -0
  31. package/example/js/variables.js +14 -0
  32. package/example/js/zegoApi.js +229 -0
  33. package/example/style.css +25 -0
  34. package/example/test.html +100 -0
  35. package/package.json +60 -0
  36. package/release.js +33 -0
  37. package/rollup-plugin-http.js +49 -0
  38. package/src/channel/getSendMsgParams.js +66 -0
  39. package/src/channel/index.js +135 -0
  40. package/src/channel/pomelo/index.js +182 -0
  41. package/src/channel/pomelo/latestQueue.js +150 -0
  42. package/src/channel/pomelo/polemo.js +730 -0
  43. package/src/channel/pomelo/util.js +54 -0
  44. package/src/channel/sdk-cb.js +73 -0
  45. package/src/channel/stream-msg.js +97 -0
  46. package/src/channel/zbzt/index.js +74 -0
  47. package/src/channel/zbzt/interactWithChannel.js +4 -0
  48. package/src/channel/zbzt/interactWithChannelControl.js +1568 -0
  49. package/src/channel/zbzt/interactWithChannelEntry.js +318 -0
  50. package/src/config/config.js +226 -0
  51. package/src/default/base.js +71 -0
  52. package/src/default/extend.js +36 -0
  53. package/src/default/index.js +10 -0
  54. package/src/live/base.js +43 -0
  55. package/src/live/call-method.js +10 -0
  56. package/src/live/extend.js +53 -0
  57. package/src/live/index.js +10 -0
  58. package/src/network/api.js +56 -0
  59. package/src/network/commonFetch.js +66 -0
  60. package/src/network/dataReport.js +448 -0
  61. package/src/notice.js +418 -0
  62. package/src/tool/base.js +74 -0
  63. package/src/tool/call-method.js +10 -0
  64. package/src/tool/extend.js +42 -0
  65. package/src/tool/index.js +10 -0
  66. package/src/util/bridge.js +87 -0
  67. package/src/util/bridge1.js +46 -0
  68. package/src/util/dict.js +51 -0
  69. package/src/util/sessionStorage.js +29 -0
  70. package/src/util/sha256.js +483 -0
  71. package/src/util/util.js +329 -0
  72. package/src/zbzt-av-sdk/default-sdk.js +192 -0
  73. package/src/zbzt-av-sdk/device.js +86 -0
  74. package/src/zbzt-av-sdk/rtc-sdk.js +2854 -0
  75. package/src/zbzt-av-sdk/talrtc-sdk.js +2620 -0
  76. package/src/zbzt-av-sdk/trtc-sdk.js +1802 -0
  77. package/src/zbzt-av-sdk/zbzt-av-sdk.js +2121 -0
  78. package/src/zbzt-av-sdk/zego-sdk.js +1718 -0
  79. package/src/zbzt-av-sdk/zego-sdk.js.bak +3133 -0
  80. package/src/zbzt-live-sdk.js +1484 -0
@@ -0,0 +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
+ // })();
@@ -0,0 +1,226 @@
1
+ import {getInitParams} from '../network/api';
2
+
3
+ const prefix = {
4
+ dev : 'dev-',
5
+ test : 'test-',
6
+ pre : 'pre-',
7
+ online : ''
8
+ };
9
+
10
+ const urls = {
11
+ api : 'api.weclassroom.com',
12
+ report : 's.weclassroom.com'
13
+ };
14
+
15
+ export const version = 'zbzt_LIVE_SDK_VERSION';
16
+
17
+ export const liveExt = {
18
+ name: 'live',
19
+ version: '1.0.0.0'
20
+ };
21
+ export const toolExt = {
22
+ name: 'tool',
23
+ version: '1.0.0.0'
24
+ };
25
+ export const defaultExt = {
26
+ name: 'default_ext',
27
+ version: '1.0.0.0'
28
+ };
29
+ export const zegoExt = {
30
+ name: 'zego_ext',
31
+ version: '1.0.0.0'
32
+ };
33
+ export const utilitiesExt = {
34
+ name: 'utilities_ext',
35
+ version: '1.0.0.0'
36
+ };
37
+ export const talrtcExt = {
38
+ name: 'talrtc_ext',
39
+ version: '1.0.0.0'
40
+ };
41
+
42
+ // 小班=0,大班=1
43
+ export const classType = 0;
44
+ export const productName = 'zbzt-live-sdk';
45
+
46
+ export const zegoSdkName = 'zego';
47
+ export const talSdkName = 'Tal';
48
+ export const rtcSdkName = 'rtc';
49
+ export const tmSdkName = 'tm';
50
+ export const talrtcSdkName = 'talrtc';
51
+
52
+ export const extensionInfo = {
53
+ version:{
54
+ default_ext : '1.0.0.0'
55
+ // arora : '1.0.0.1',
56
+ // rtc : '1.0.0.0',
57
+ // zego : '1.0.0.0',
58
+ // tool : '1.0.0.0'
59
+ }
60
+ };
61
+
62
+ export const USER_LOCATION = {
63
+ MAINLAND: 'mainland',
64
+ OVERSEAS: 'overseas'
65
+ };
66
+
67
+ export let config = {
68
+ isHttps: true,
69
+ env: 'test',
70
+ weblog: true,
71
+ businessLinesType: 'saas', // saas | xes
72
+ userLocation: USER_LOCATION.MAINLAND,
73
+ };
74
+
75
+ export const getBaseUrl = (type='api') => {
76
+ const {isHttps,env} = config;
77
+ return `${isHttps ? 'https://' : 'http://'}${prefix[env ? env : 'online']}${urls[type]}`;
78
+ };
79
+
80
+ export const getCloudApiDomain = () => {
81
+ if (window.zbzt_sdk_cloud_api_domain) {
82
+ return window.zbzt_sdk_cloud_api_domain;
83
+ }
84
+ return getBaseUrl();
85
+ };
86
+
87
+ const reportUrls = {
88
+ // test: 'test-dp.weclassroom.com:10443/report',
89
+ // online: 'dp.weclassroom.com:443/report'
90
+ test: 'testdp-s.weclassroom.com/report',
91
+ online: 'dp-s.weclassroom.com/report '
92
+ };
93
+
94
+ const logAddressInit = {
95
+ test: 'live_test_log',
96
+ online: 'live_log'
97
+ };
98
+
99
+ // 从三方服务器获取时间戳
100
+ export const timestampUrl = {
101
+ suning: 'https://quan.suning.com/getSysTime.do',
102
+ taobao: 'https://api.m.taobao.com/rest/api3.do?api=mtop.common.getTimestamp'
103
+ };
104
+
105
+ // // 获取初始化数据
106
+ // const apiCloudUrl = {
107
+ // saas: {
108
+ // dev: '/saas/live-cloud-control',
109
+ // test: 'https://test-api-cloud-control-zhibo.saasp.vdyoo.com/live-cloud-control',
110
+ // online: 'https://api-cloud-control-zhibo.saasp.vdyoo.com/live-cloud-control'
111
+ // },
112
+ // xes: {
113
+ // dev: '/peiyou/live-cloud-control',
114
+ // test: 'https://test-api-cloud-control-zhibo.speiyou.com/live-cloud-control',
115
+ // online: 'https://api-cloud-control-zhibo.speiyou.com/live-cloud-control'
116
+ // }
117
+ // };
118
+
119
+ // //切换sdk类型
120
+ // const apiChangeSdkUrl = {
121
+ // saas: {
122
+ // dev: '/saas/cloud-platform',
123
+ // test: 'https://test-cloud-platform-live.saasp.vdyoo.com/cloud-platform',
124
+ // online: 'https://cloud-platform-live.saasp.vdyoo.com/cloud-platform'
125
+ // },
126
+ // xes: {
127
+ // dev: '/peiyou/cloud-platform',
128
+ // test: 'https://test-cloud-platform-live.speiyou.com/cloud-platform',
129
+ // online: 'https://cloud-platform-live.speiyou.com/cloud-platform'
130
+ // }
131
+ // };
132
+
133
+ const apiCloudUrl = {
134
+ saas: {
135
+ dev: '/saas/live-cloud-control',
136
+ test: 'https://8-140-113-148.eaydu.com/saas/live-cloud-control',
137
+ online: 'https://api-cloud-control-zhibo.saasp.vdyoo.com/live-cloud-control'
138
+ },
139
+ xes: {
140
+ dev: '/peiyou/live-cloud-control',
141
+ test: 'https://8-140-113-148.eaydu.com/peiyou/live-cloud-control',
142
+ online: 'https://api-cloud-control-zhibo.speiyou.com/live-cloud-control'
143
+ }
144
+ };
145
+
146
+ //切换sdk类型
147
+ const apiChangeSdkUrl = {
148
+ saas: {
149
+ dev: '/saas/cloud-platform',
150
+ test: 'https://8-140-113-148.eaydu.com/saas/cloud-platform',
151
+ online: 'https://cloud-platform-live.saasp.vdyoo.com/cloud-platform'
152
+ },
153
+ xes: {
154
+ dev: '/peiyou/cloud-platform',
155
+ test: 'https://8-140-113-148.eaydu.com/peiyou/cloud-platform',
156
+ online: 'https://cloud-platform-live.speiyou.com/cloud-platform'
157
+ }
158
+ };
159
+
160
+ const zegoGateway = {
161
+ [USER_LOCATION.MAINLAND]: {
162
+ dev: 'wss://webliveroom2251703116-api.zego.im/ws',
163
+ test: 'wss://webliveroom2251703116-api.zego.im/ws',
164
+ online: 'wss://webliveroom942270070-api.imzego.com/ws'
165
+ },
166
+ [USER_LOCATION.OVERSEAS]: {
167
+ dev: 'wss://webliveroom-test.zego.im/ws',
168
+ test: 'wss://webliveroom-test.zego.im/ws',
169
+ online: 'wss://webliveroom.zego.im/ws'
170
+ },
171
+ };
172
+
173
+ export const getApiCloudBaseUrl = () => {
174
+ const {env, businessLinesType} = config;
175
+ return apiCloudUrl[businessLinesType] && apiCloudUrl[businessLinesType][env];
176
+ };
177
+
178
+ export const getApiChangeSdkUrl = () => {
179
+ const {env, businessLinesType} = config;
180
+ return apiChangeSdkUrl[businessLinesType] && apiChangeSdkUrl[businessLinesType][env];
181
+ };
182
+
183
+ export let dabanReportUrl = '';
184
+ export let logAddress = '';
185
+
186
+ export const getReportBaseUrl = () => {
187
+ if (dabanReportUrl) {
188
+ return dabanReportUrl;
189
+ }
190
+ const {env} = config;
191
+ return `https://${reportUrls[env]}`;
192
+ };
193
+
194
+ export const getZegoGateway = () => {
195
+ const {env, userLocation} = config;
196
+ return zegoGateway[userLocation][env];
197
+ };
198
+ export const getLogAddress = () => {
199
+ const {env} = config;
200
+ defaultApi.writeLog(`logAddresshsghsg ${env} ${logAddressInit[env]}`);
201
+ logAddress = logAddressInit[env];
202
+ // return logAddress;
203
+ };
204
+
205
+ export const getAndSetInitParams = async (args) => {
206
+ const res = await getInitParams(args);
207
+ if (res && res.sdkInfo) {
208
+ defaultApi.writeLog(`云控请求返回参数正常 ${JSON.stringify(res)}, ${JSON.stringify(res.sdkInfo)}`);
209
+ return res.sdkInfo[0].sdkName;
210
+ } else {
211
+ defaultApi.writeLog(`云控请求返回参数错误 ${JSON.stringify(res)}`);
212
+ }
213
+
214
+ };
215
+
216
+ export const getapiChangeSdkUrl = () => {
217
+ const {env, businessLinesType} = config;
218
+ return apiChangeSdkUrl[businessLinesType] && apiChangeSdkUrl[businessLinesType][env];
219
+ };
220
+
221
+ export default {
222
+ version,
223
+ extensionInfo,
224
+ getBaseUrl,
225
+ config
226
+ };
@@ -0,0 +1,71 @@
1
+ /*
2
+ * @Author: why
3
+ * @Date: 2019-08-08 19:33:44
4
+ * @LastEditors: why
5
+ * @LastEditTime: 2019-09-11 15:35:34
6
+ * @Description:
7
+ */
8
+ import {defaultExt, classType} from '../config/config';
9
+ const EM = window.EM;
10
+ const cb = (extName) => {
11
+ // EM 是寄宿于端的,浏览器中并不存在,为防止报错需要先进行能力检测
12
+ if (EM) {
13
+ return function(name, args, sdkName){
14
+ const argsStr = typeof args === 'object' ? JSON.stringify({...args, classType}) : args;
15
+ return new Promise((resolve, reject) => {
16
+ EM.CallMethod(
17
+ extName,
18
+ name,
19
+ argsStr,
20
+ (code, msg) => {
21
+ const msgbody = `${extName}--action: ${sdkName || ''}--${name || name.charAt(0).toLowerCase() + name.slice(1)} Code: ${code}\nMessage: ${msg}\nparams:${JSON.stringify(args)}`;
22
+ if (code === 0) {
23
+ name !== 'WriteLog' && defaultApi.writeLog && defaultApi.writeLog(msgbody, productName);
24
+ resolve({
25
+ code,
26
+ msg: msg && /\{|\}/g.test(msg) && JSON.parse(msg)
27
+ });
28
+ } else {
29
+ name !== 'WriteLog' && defaultApi.writeLog && defaultApi.writeLog(msgbody, productName, 'error');
30
+ resolve({
31
+ code,
32
+ msg
33
+ });
34
+ }
35
+ });
36
+ }).catch(() => {
37
+ name !== 'WriteLog' && defaultApi.writeLog && defaultApi.writeLog(`${extName}--action: ${sdkName || ''}--${name || name.charAt(0).toLowerCase() + name.slice(1)} Code: ${code}\nMessage: ${msg}\nparams:${JSON.stringify(args)}`, productName, 'error');
38
+ });
39
+ };
40
+ }
41
+ };
42
+ const callMethod = cb(defaultExt.name);
43
+ export default {
44
+ // 初始化
45
+ init() {
46
+ // 加载扩展
47
+ if (EM) {
48
+ return new Promise(resolve => {
49
+ EM.Load(defaultExt.name, defaultExt.version, false, ()=>{
50
+ resolve();
51
+ });
52
+ });
53
+ }
54
+ },
55
+ writeLog(args) {
56
+ return callMethod('WriteLog', args);
57
+ },
58
+ /**
59
+ * @function 设置用户信息
60
+ * @param {string} userId 用户id
61
+ * @param {string} institutionId 机构id
62
+ * @return: void
63
+ */
64
+ setUserInfo(userId, institutionId) {
65
+ return callMethod('SetUserInfo', {
66
+ user_id: userId + '',
67
+ institution_id: institutionId + '',
68
+ description: ''
69
+ });
70
+ },
71
+ };
@@ -0,0 +1,36 @@
1
+ // import BASSAPI from './base';
2
+ import {config} from '../config/config';
3
+ import util from '../util/util';
4
+
5
+ export default {
6
+ /**
7
+ * @function 写日志
8
+ * @param {string} msgbody 内容
9
+ * @param {string} productName 产品名称
10
+ * @param {string} msgtype 类型
11
+ * @return: void
12
+ */
13
+ async writeLog (msgbody, productName='zbzt-live-sdk', msgtype = 'info') {
14
+ const logMap = {
15
+ debug : 0,
16
+ info : 1,
17
+ warnning : 2,
18
+ error : 3,
19
+ critical : 4
20
+ };
21
+ msgbody = typeof msgbody === 'string' ? msgbody : JSON.stringify(msgbody);
22
+ const args = {
23
+ //日志级别,0:debug,1:info,2:warnning,3:error,4:critical
24
+ 'type': logMap[msgtype],
25
+ 'msg': `${productName?'['+productName+']--':''} ${msgbody}`
26
+ };
27
+ // await BASSAPI.writeLog(args);
28
+ if (config.weblog === true) {
29
+ if (msgtype === 'info') {
30
+ console.log(`%c [${util.currentTimeString()}]--${args.msg}`, 'color:#60acfc');
31
+ } else {
32
+ console.log(`%c [${util.currentTimeString()}]--${args.msg}`, 'color:#f00');
33
+ }
34
+ }
35
+ }
36
+ };
@@ -0,0 +1,10 @@
1
+ /*
2
+ * @Author: why
3
+ * @Date: 2019-08-08 19:33:44
4
+ * @LastEditors: why
5
+ * @LastEditTime: 2019-09-09 15:02:54
6
+ * @Description:
7
+ */
8
+ import api from './extend';
9
+
10
+ export default api;