Toggle navigation
Toggle navigation
此项目
正在载入...
Sign in
李勇
/
McuClient
转到一个项目
Toggle navigation
项目
群组
代码片段
帮助
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
李勇
7 years ago
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
7ede4042551a6259b8bf0b8b2a21853ad24ca5c2
7ede4042
1 parent
e31bb7eb
1.修改文档伴音和媒体模块自动同步的逻辑;2,优化
隐藏空白字符变更
内嵌
并排对比
正在显示
6 个修改的文件
包含
96 行增加
和
98 行删除
src/EngineEntrance.js
src/EngineUtils.js
src/EverSocket.js
src/apes/DocApe.js
src/apes/MediaSharedApe.js
src/apes/MusicSharedApe.js
src/EngineEntrance.js
查看文件 @
7ede404
...
...
@@ -63,7 +63,7 @@ export default class MessageEntrance extends Emiter {
super
();
this
.
lastClassActiveTime
=
0
;
//最后一次课堂激活的时间戳
//sdk 信息
GlobalConfig
.
sdkVersion
=
"v2.31.1
0
.20171122"
;
GlobalConfig
.
sdkVersion
=
"v2.31.1
2
.20171122"
;
loger
.
warn
(
"sdkVersion:"
+
GlobalConfig
.
sdkVersion
);
console
.
log
(
"sdkVersion:"
+
GlobalConfig
.
sdkVersion
);
//设置
...
...
@@ -2571,54 +2571,6 @@ export default class MessageEntrance extends Emiter {
}
}
//文档加入频道成功,同步到MCU服务器上的数据
docJoinChannelSuccess
()
{
let
interval
=
new
Date
().
getTime
()
-
parseInt
(
this
.
lastClassActiveTime
);
interval
=
interval
/
1000
;
//loger.log("最后一次记录的时间->"+this.lastClassActiveTime,"当前时间:"+new Date().getTime(),"间隔:"+interval+"秒");
loger
.
log
(
"文档加入频道成功->isHost="
,
GlobalConfig
.
isHost
,
"当前总人数:"
,
GlobalConfig
.
rosterNumber
,
"sassDoclength="
,
GlobalConfig
.
docListPrepare
.
length
);
/* //20171114 服务端已经做了处理,客户端不需要再做判断
//如果当前课堂内只有自己或者离开上次课堂的时间大于8分钟,需要停止服务端的视频录制,设备不是H5
if(GlobalConfig.rosterNumber<=1&&interval>=(6*60)&&GlobalConfig.deviceType!=3){
setTimeout(()=>{
//延迟3秒,检测一下当前是否有人在开着视频,如果有开启的就不能再停止了
loger.log("当前开启音视频的人数->"+GlobalConfig.getPublishUser());
if(GlobalConfig.getPublishUser()<1){
loger.log("调用服务端音视频停止录制->interval:"+interval);
this._mediaRecordControl({"status": WebRtcApe.RECORD_STATUS_2});
}
},3000);
}*/
//如果是主持人,那么需要判断一下文档模块同步的数据和从sass获取的文档数据是否相同,如果mcu服务器不存在的,需要上传
if
(
GlobalConfig
.
docListPrepare
&&
GlobalConfig
.
docListPrepare
.
length
>
0
)
{
//如果当前身份是老师或者当前课堂内只有一个人并且不是H5,有权限同步文档到MCU
if
(
GlobalConfig
.
isHost
||
(
GlobalConfig
.
rosterNumber
<=
1
&&
GlobalConfig
.
deviceType
!=
GlobalConfig
.
deviceH5
))
{
for
(
let
i
=
0
;
i
<
GlobalConfig
.
docListPrepare
.
length
;
i
++
)
{
let
value
=
GlobalConfig
.
docListPrepare
[
i
];
if
(
value
)
{
//loger.log("判断是否需要把提前上传的文档上传到mcu", value);
let
paramInfo
=
{
"pageNum"
:
value
.
pdfSize
||
value
.
pageNum
,
"fileName"
:
value
.
name
,
"fileType"
:
value
.
type
||
value
.
fileType
,
"relativeUrl"
:
value
.
relativeLocation
||
value
.
relativeUrl
,
"url"
:
value
.
absoluteLocation
||
value
.
url
,
"creatUserId"
:
value
.
createUserID
||
0
,
"docId"
:
value
.
id
||
value
.
docId
,
"md5"
:
value
.
MD5
||
""
,
"visible"
:
false
,
"itemIdx"
:
value
.
itemIdx
||
0
};
this
.
_sendDocumentUpload
(
paramInfo
);
}
}
}
}
}
//媒体共享模块的接口
//上传
_sendMediaSharedUpload
(
_param
)
{
...
...
@@ -2784,32 +2736,66 @@ export default class MessageEntrance extends Emiter {
}
}
//文档加入频道成功,同步到MCU服务器上的数据
docJoinChannelSuccess
()
{
let
interval
=
new
Date
().
getTime
()
-
parseInt
(
this
.
lastClassActiveTime
);
interval
=
interval
/
1000
;
//loger.log("最后一次记录的时间->"+this.lastClassActiveTime,"当前时间:"+new Date().getTime(),"间隔:"+interval+"秒");
loger
.
log
(
"文档加入频道成功->isHost="
,
GlobalConfig
.
isHost
,
"当前总人数:"
,
GlobalConfig
.
rosterNumber
,
"sassDoclength="
,
GlobalConfig
.
docListPrepare
.
length
);
//如果是主持人,那么需要判断一下文档模块同步的数据和从sass获取的文档数据是否相同,如果mcu服务器不存在的,需要上传
if
(
GlobalConfig
.
docListPrepare
&&
GlobalConfig
.
docListPrepare
.
length
>
0
)
{
//如果当前身份是老师或者当前课堂内只有一个人并且不是H5,有权限同步文档到MCU
if
(
GlobalConfig
.
isHost
||
(
GlobalConfig
.
rosterNumber
<=
1
&&
GlobalConfig
.
deviceType
!=
GlobalConfig
.
deviceH5
))
{
for
(
let
i
=
0
;
i
<
GlobalConfig
.
docListPrepare
.
length
;
i
++
)
{
let
value
=
GlobalConfig
.
docListPrepare
[
i
];
if
(
value
)
{
//loger.log("判断是否需要把提前上传的文档上传到mcu", value);
let
paramInfo
=
{
"pageNum"
:
value
.
pdfSize
||
value
.
pageNum
,
"fileName"
:
value
.
name
,
"fileType"
:
value
.
type
||
value
.
fileType
,
"relativeUrl"
:
value
.
relativeLocation
||
value
.
relativeUrl
,
"url"
:
value
.
absoluteLocation
||
value
.
url
,
"creatUserId"
:
value
.
createUserID
||
0
,
"docId"
:
value
.
id
||
value
.
docId
,
"md5"
:
value
.
MD5
||
""
,
"visible"
:
false
,
"itemIdx"
:
value
.
itemIdx
||
0
};
this
.
_sendDocumentUpload
(
paramInfo
);
}
}
}
}
}
//音乐共享模块加入频道成功,同步到MCU服务器上的数据
musicShareApeJoinChannelSuccess
()
{
//loger.log("伴音MUSIC模块加入频道成功->isHost=", GlobalConfig.isHost, "length=", GlobalConfig.musicListPrepare.length);
//console.log("伴音MUSIC模块共享模数据->", GlobalConfig.musicListPrepare);
//如果是主持人,那么需要判断一下文档模块同步的数据和从sass获取的文档数据是否相同,如果mcu服务器不存在的,需要上传
if
(
GlobalConfig
.
isHost
&&
GlobalConfig
.
musicListPrepare
.
length
>
0
&&
GlobalConfig
.
deviceType
!=
GlobalConfig
.
deviceH5
)
{
for
(
let
i
=
0
;
i
<
GlobalConfig
.
musicListPrepare
.
length
;
i
++
)
{
let
value
=
GlobalConfig
.
musicListPrepare
[
i
];
if
(
value
)
{
let
paramInfo
=
{
"status"
:
0
,
"creatUserId"
:
value
.
creatUserId
,
"creatUserName"
:
value
.
createUserName
,
"url"
:
value
.
url
||
value
.
absoluteLocation
,
//伴音上传的接口有差异,课堂内上传返回的是url字段,后台带入的字段是absoluteLocation
"fileType"
:
value
.
type
,
"fileId"
:
""
+
value
.
id
,
"fileName"
:
value
.
name
,
"seek"
:
0
,
"duration"
:
parseInt
(
value
.
duration
)
||
0
};
//外部接口上传的伴音文件返回的地址有的不正确,需要特殊处理,检测是否有DocSharing目录
if
(
paramInfo
.
url
&&
paramInfo
.
url
.
indexOf
(
"/DocSharing/"
)
<
0
){
loger
.
log
(
"替换MP3路径地址"
,
paramInfo
.
url
);
paramInfo
.
url
=
paramInfo
.
url
.
replace
(
"/data/"
,
"/DocSharing/data/"
);
if
(
GlobalConfig
.
musicListPrepare
&&
GlobalConfig
.
musicListPrepare
.
length
>
0
)
{
if
(
GlobalConfig
.
isHost
||
(
GlobalConfig
.
rosterNumber
<=
1
&&
GlobalConfig
.
deviceType
!=
GlobalConfig
.
deviceH5
))
{
for
(
let
i
=
0
;
i
<
GlobalConfig
.
musicListPrepare
.
length
;
i
++
)
{
let
value
=
GlobalConfig
.
musicListPrepare
[
i
];
if
(
value
)
{
let
paramInfo
=
{
"status"
:
0
,
"creatUserId"
:
value
.
creatUserId
,
"creatUserName"
:
value
.
createUserName
,
"url"
:
value
.
url
||
value
.
absoluteLocation
,
//伴音上传的接口有差异,课堂内上传返回的是url字段,后台带入的字段是absoluteLocation
"fileType"
:
value
.
type
,
"fileId"
:
""
+
value
.
id
,
"fileName"
:
value
.
name
,
"seek"
:
0
,
"duration"
:
parseInt
(
value
.
duration
)
||
0
};
//外部接口上传的伴音文件返回的地址有的不正确,需要特殊处理,检测是否有DocSharing目录
if
(
paramInfo
.
url
&&
paramInfo
.
url
.
indexOf
(
"/DocSharing/"
)
<
0
){
paramInfo
.
url
=
paramInfo
.
url
.
replace
(
"/data/"
,
"/DocSharing/data/"
);
}
loger
.
log
(
"MP3路径地址:"
+
paramInfo
.
url
,
"fileId:"
+
paramInfo
.
fileId
);
this
.
_sendMusicSharedUpload
(
paramInfo
);
}
this
.
_sendMusicSharedUpload
(
paramInfo
);
}
}
}
...
...
@@ -2817,33 +2803,34 @@ export default class MessageEntrance extends Emiter {
//媒体共享模块加入频道成功,同步到MCU服务器上的数据
mediaShareApeJoinChannelSuccess
()
{
//loger.log("媒体共享模块加入频道成功->isHost=", GlobalConfig.isHost, "length=", GlobalConfig.sharedMediaList.length);
//console.log("媒体共享模数据->", GlobalConfig.sharedMediaList);
//如果是主持人,那么需要判断一下文档模块同步的数据和从sass获取的文档数据是否相同,如果mcu服务器不存在的,需要上传
if
(
GlobalConfig
.
isHost
&&
GlobalConfig
.
sharedMediaList
.
length
>
0
&&
GlobalConfig
.
deviceType
!=
GlobalConfig
.
deviceH5
)
{
for
(
let
i
=
0
;
i
<
GlobalConfig
.
sharedMediaList
.
length
;
i
++
)
{
let
value
=
GlobalConfig
.
sharedMediaList
[
i
];
if
(
value
)
{
let
paramInfo
=
{
"status"
:
0
,
"creatUserId"
:
value
.
creatUserId
,
"creatUserName"
:
value
.
createUserName
,
"url"
:
value
.
url
,
"fileType"
:
value
.
type
,
"fileId"
:
""
+
value
.
id
,
"fileName"
:
value
.
name
,
"seek"
:
0
,
"duration"
:
parseInt
(
value
.
duration
)
||
0
};
//外部接口上传的伴音文件返回的地址有的不正确,需要特殊处理,检测是否有DocSharing目录
if
(
paramInfo
.
url
&&
paramInfo
.
url
.
indexOf
(
"/DocSharing/"
)
<
0
){
loger
.
log
(
"替换MP4路径地址"
,
paramInfo
.
url
);
paramInfo
.
url
=
paramInfo
.
url
.
replace
(
"/data/"
,
"/DocSharing/data/"
);
if
(
GlobalConfig
.
sharedMediaList
&&
GlobalConfig
.
sharedMediaList
.
length
>
0
)
{
if
(
GlobalConfig
.
isHost
||
(
GlobalConfig
.
rosterNumber
<=
1
&&
GlobalConfig
.
deviceType
!=
GlobalConfig
.
deviceH5
))
{
for
(
let
i
=
0
;
i
<
GlobalConfig
.
sharedMediaList
.
length
;
i
++
)
{
let
value
=
GlobalConfig
.
sharedMediaList
[
i
];
if
(
value
)
{
let
paramInfo
=
{
"status"
:
0
,
"creatUserId"
:
value
.
creatUserId
,
"creatUserName"
:
value
.
createUserName
,
"url"
:
value
.
url
,
"fileType"
:
value
.
type
,
"fileId"
:
""
+
value
.
id
,
"fileName"
:
value
.
name
,
"seek"
:
0
,
"duration"
:
parseInt
(
value
.
duration
)
||
0
};
//外部接口上传的伴音文件返回的地址有的不正确,需要特殊处理,检测是否有DocSharing目录
if
(
paramInfo
.
url
&&
paramInfo
.
url
.
indexOf
(
"/DocSharing/"
)
<
0
){
paramInfo
.
url
=
paramInfo
.
url
.
replace
(
"/data/"
,
"/DocSharing/data/"
);
}
loger
.
log
(
"MP4路径地址:"
+
paramInfo
.
url
,
"fileId:"
+
paramInfo
.
fileId
);
this
.
_sendMediaSharedUpload
(
paramInfo
);
}
this
.
_sendMediaSharedUpload
(
paramInfo
);
}
}
}
}
//录制回放相关的处理------------------------------------------------
...
...
src/EngineUtils.js
查看文件 @
7ede404
...
...
@@ -28,6 +28,17 @@ class EngineUtils{
return
[];
}
/*
* 生成随机数 _part 段数 默认3段; splitStr分隔符
* */
static
creatRandomNum
(
_part
=
3
,
splitStr
=
""
){
let
randNumStr
=
""
;
for
(
let
i
=
0
;
i
<
_part
;
i
++
){
randNumStr
+=
splitStr
+
parseInt
(
Math
.
random
()
*
1000
);
}
return
randNumStr
;
}
//生成时间戳后9位 保证唯一
static
creatSoleNumberFromTimestamp
(){
let
time
=
new
Date
().
getTime
();
...
...
src/EverSocket.js
查看文件 @
7ede404
...
...
@@ -98,7 +98,7 @@ class EverSocket extends Emiter {
* */
send2mcu
(
len
,
type
){
this
.
sendToMcuList
.
push
(
""
+
len
+
":"
+
type
);
if
(
this
.
sendToMcuList
.
length
>=
5
0
){
if
(
this
.
sendToMcuList
.
length
>=
10
0
){
loger
.
log
(
"发送到MCU数据统计->"
,
this
.
sendToMcuList
);
this
.
sendToMcuList
=
[];
}
...
...
@@ -111,7 +111,7 @@ class EverSocket extends Emiter {
* */
mcu2client
(
len
,
type
){
this
.
receiveFromMcuList
.
push
(
""
+
len
+
":"
+
type
);
if
(
this
.
receiveFromMcuList
.
length
>
5
0
){
if
(
this
.
receiveFromMcuList
.
length
>
10
0
){
loger
.
log
(
"收到MCU数据统计->"
,
this
.
receiveFromMcuList
);
this
.
receiveFromMcuList
=
[];
}
...
...
src/apes/DocApe.js
查看文件 @
7ede404
...
...
@@ -56,7 +56,7 @@ class DocApe extends Ape {
let
itemIdx
=
parseInt
(
paramInfo
.
itemIdx
||
0
);
//使用外部指定的itemIdx
if
(
itemIdx
<=
0
){
//外部指定的值无效就使用时间戳
itemIdx
=
EngineUtils
.
creatSoleNumberFromTimestamp
()
;
itemIdx
=
parseInt
(
EngineUtils
.
creatRandomNum
(
3
));
//生成唯一的标识 int32
;
}
let
docDataModelPdu
=
this
.
packPdu
(
paramInfo
,
itemIdx
);
//数据无效或地址无效的不做处理
...
...
src/apes/MediaSharedApe.js
查看文件 @
7ede404
...
...
@@ -42,7 +42,7 @@ class MediaSharedApe extends Ape {
return
;
}
let
itemIdx
=
EngineUtils
.
creatSoleNumberFromTimestamp
();
//
let
itemIdx
=
parseInt
(
EngineUtils
.
creatRandomNum
(
3
));
//生成唯一的标识 int32
let
pduDataModel
=
this
.
packPdu
(
paramInfo
,
itemIdx
);
if
(
pduDataModel
==
null
)
{
loger
.
log
(
'上传媒体文件->失败->数据无效'
);
...
...
src/apes/MusicSharedApe.js
查看文件 @
7ede404
...
...
@@ -43,7 +43,7 @@ class MusicSharedApe extends Ape {
return
;
}
let
itemIdx
=
EngineUtils
.
creatSoleNumberFromTimestamp
();
//
let
itemIdx
=
parseInt
(
EngineUtils
.
creatRandomNum
(
3
));
//生成唯一的标识 int32
let
pduDataModel
=
this
.
packPdu
(
paramInfo
,
itemIdx
);
if
(
pduDataModel
==
null
)
{
loger
.
log
(
'上传伴音文件->失败->数据无效'
);
...
...
请
注册
或
登录
后发表评论