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
李勇
8 years ago
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
90d2ba02dc3593e41f90fc609ff84a929ad4c1e2
90d2ba02
1 parent
ac58abbd
1.课堂初始化接口增加是否延迟接收消息的字段
2.sass接口中增加延迟消息的时间长度的字段,单位是秒 3.APE默认所有模块都支持延迟消息 3.mcu增加延迟消息判断
隐藏空白字符变更
内嵌
并排对比
正在显示
9 个修改的文件
包含
218 行增加
和
201 行删除
dist/McuClient.js
src/EngineEntrance.js
src/GlobalConfig.js
src/Sass.js
src/ServerCheck.js
src/apes/Ape.js
src/apes/DocApe.js
src/apes/WhiteBoardApe.js
src/mcu.js
dist/McuClient.js
查看文件 @
90d2ba0
此 diff 太大无法显示。
src/EngineEntrance.js
查看文件 @
90d2ba0
...
...
@@ -300,6 +300,9 @@ export default class MessageEntrance extends Emiter {
GlobalConfig
.
userId
=
_param
.
userId
||
"0"
;
GlobalConfig
.
userName
=
_param
.
userName
||
""
;
//客户端决定是否延迟接收消息
GlobalConfig
.
messageDelay
=
_param
.
messageDelay
||
false
;
//最长允许录制的时间
if
(
_param
.
allowRecordMaxTime
){
GlobalConfig
.
allowRecordMaxTime
=
parseInt
(
_param
.
allowRecordMaxTime
);
...
...
@@ -412,7 +415,7 @@ export default class MessageEntrance extends Emiter {
// console.log(_data);
//包含整个课堂最全的信息,储存数据
if
(
_data
)
{
GlobalConfig
.
mcuDelay
=
_data
.
mcuDelay
||
60
;
//mcu消息延迟,用于文档模块
GlobalConfig
.
mcuDelay
=
_data
.
h5Delay
||
0
;
//mcu消息延迟的时间间隔,单位(秒),结合客户端传的messageDelay的值使用
GlobalConfig
.
className
=
_data
.
meetingName
||
""
;
GlobalConfig
.
classBeginTime
=
_data
.
beginTime
||
""
;
GlobalConfig
.
classEndTime
=
_data
.
endTime
||
""
;
...
...
src/GlobalConfig.js
查看文件 @
90d2ba0
...
...
@@ -242,8 +242,10 @@ GlobalConfig.statusCode_4={"code":4,message:"未知状态"};
GlobalConfig
.
md5
=
""
;
GlobalConfig
.
msType
=
1
;
//目前固定用这个
GlobalConfig
.
mcuDelay
=
60
;
//默认的延迟时间 flash中使用的是3000毫秒
GlobalConfig
.
docDelay
=
1600
;
//文档模块加入成功之后延迟发送送成功的消息给主模块
GlobalConfig
.
messageDelay
=
false
;
//是否启用消息延迟
GlobalConfig
.
mcuDelay
=
0
;
//默认的延迟时间(单位-秒)
GlobalConfig
.
docDelay
=
1600
;
//文档模块加入成功之后延迟发送送成功的消息给主模块(sdk内部使用)
GlobalConfig
.
portal
=
"112.126.80.182:80"
;
//Sass IP
//GlobalConfig.ip="112.126.80.182";
...
...
src/Sass.js
查看文件 @
90d2ba0
...
...
@@ -201,7 +201,7 @@ class Sass extends Emiter {
// 获取课堂基本详情------------------------------------------------------------------------------------
getClassDetail
()
{
let
url
=
`
http
:
//${
confInfo.portal}/3m/meeting/getClassH5.do?classNumber=${confInfo
.classId}`;
let
url
=
`
http
:
//${
GlobalConfig.portal}/3m/meeting/getClassH5.do?classNumber=${GlobalConfig
.classId}`;
loger
.
log
(
'获取Class详情.'
,
url
);
fetch
(
url
,
{
timeout
:
5000
...
...
@@ -300,7 +300,7 @@ class Sass extends Emiter {
}
var
timestamp
=
new
Date
().
getTime
();
var
authId
=
MD5
(
_param
.
docId
+
""
+
_param
.
classId
+
""
+
timestamp
);
// docId+classId+timestamp的字符串,转成MD5
let
url
=
`
http
:
//${
confInfo.portal}/3m/api/document/deleteRelation.do?docId=${_param.docId}&classId=${confInfo
.classId}×tamp=${timestamp}&authId=${authId}`;
let
url
=
`
http
:
//${
GlobalConfig.portal}/3m/api/document/deleteRelation.do?docId=${_param.docId}&classId=${GlobalConfig
.classId}×tamp=${timestamp}&authId=${authId}`;
loger
.
log
(
'sassDeleteDocument'
,
url
);
fetch
(
url
,
{
...
...
@@ -350,16 +350,16 @@ class Sass extends Emiter {
}
//{"classStatusInfo":classStatusInfo}
var
timestamp
=
new
Date
().
getTime
();
var
authId
=
MD5
(
confInfo
.
classId
+
""
+
timestamp
);
// (classId+timestamp)的字符串,转成MD5
var
authId
=
MD5
(
GlobalConfig
.
classId
+
""
+
timestamp
);
// (classId+timestamp)的字符串,转成MD5
let
classStatusInfo
=
JSON
.
stringify
(
_param
.
classStatusInfo
);
let
url
=
`
http
:
//${
confInfo
.portal}/3m/api/meeting/saveInfo.do`;
let
url
=
`
http
:
//${
GlobalConfig
.portal}/3m/api/meeting/saveInfo.do`;
loger
.
log
(
'saveClassStatusInfo'
,
url
);
fetch
(
url
,
{
method
:
'POST'
,
headers
:
{
"Content-Type"
:
"application/x-www-form-urlencoded"
},
body
:
`
classId
=
$
{
confInfo
.
classId
}
&
info
=
$
{
classStatusInfo
}
&
timestamp
=
$
{
timestamp
}
&
authId
=
$
{
authId
}
`
,
body
:
`
classId
=
$
{
GlobalConfig
.
classId
}
&
info
=
$
{
classStatusInfo
}
&
timestamp
=
$
{
timestamp
}
&
authId
=
$
{
authId
}
`
,
timeout
:
5000
})
.
then
(
ret
=>
{
...
...
@@ -416,7 +416,7 @@ class Sass extends Emiter {
let
timestamp
=
new
Date
().
getTime
();
let
authId
=
MD5
(
key
+
siteID
+
meetingID
+
timestamp
);
let
url
=
`
http
:
//${
confInfo
.portal}/3m/recordingMeeting/insertRecordingMeeting.do?siteID=${siteID}&meetingID=${meetingID}&userID=${userID}&userName=${userName}&meetingName=${meetingName}&startTime=${startTime}&endTime=${endTime}&playUrl=${playUrl}&streamName=${streamName}&downloadUrl=${downloadUrl}&configFile=${confRecordFileName}×tamp=${timestamp}&recordTimestamp=${recordTimestamp}&authId=${authId}`;
let
url
=
`
http
:
//${
GlobalConfig
.portal}/3m/recordingMeeting/insertRecordingMeeting.do?siteID=${siteID}&meetingID=${meetingID}&userID=${userID}&userName=${userName}&meetingName=${meetingName}&startTime=${startTime}&endTime=${endTime}&playUrl=${playUrl}&streamName=${streamName}&downloadUrl=${downloadUrl}&configFile=${confRecordFileName}×tamp=${timestamp}&recordTimestamp=${recordTimestamp}&authId=${authId}`;
loger
.
log
(
'saveClassRecordContrlInfo'
,
url
);
fetch
(
url
,
{
...
...
src/ServerCheck.js
查看文件 @
90d2ba0
...
...
@@ -27,6 +27,8 @@ let speedTestPort = ':5555';//测速端口统一
let
checkMcuIpGroup
=
[];
//储存MCU需要查询的ip数组
let
checkMsIpGroup
=
[];
//储存MCU需要查询的ip数组
const
timeOutDelay
=
1000
;
//选点超时
class
ServerCheck
extends
Emiter
{
constructor
()
{
super
();
...
...
@@ -52,7 +54,7 @@ class ServerCheck extends Emiter {
loger
.
log
(
'获取IP信息 '
,
userIp
,
location
);
fetchJsonp
(
location
,
{
timeout
:
3000
,
timeout
:
timeOutDelay
,
}).
then
(
function
(
response
)
{
return
response
.
json
()
}).
then
(
function
(
json
)
{
...
...
@@ -168,7 +170,7 @@ class ServerCheck extends Emiter {
//loger.log('getBestMcuServer done -> ', fatest_ip_response);
this
.
_getBestMcuServerCallbackHandler
(
fatest_ip_response
)
}
}.
bind
(
this
),
3000
);
}.
bind
(
this
),
timeOutDelay
);
}
//获取最快的MS服务器地址,参数是一个ip数组
...
...
@@ -186,7 +188,7 @@ class ServerCheck extends Emiter {
//loger.log('getBestMsServer done -> ', fatest_ip_response);
this
.
_getBestMsServerCallbackHandler
(
fatest_ip_response
);
}
}.
bind
(
this
),
3000
);
}.
bind
(
this
),
timeOutDelay
);
}
_getBestMcuServerCallbackHandler
(
_data
)
{
...
...
src/apes/Ape.js
查看文件 @
90d2ba0
...
...
@@ -40,7 +40,7 @@ export default class Ape extends Emiter {
this
.
_adapter_pdu
=
new
pdu
[
'RCAdapterPdu'
];
this
.
_classInfo
=
null
;
this
.
_rCArrayBufferUtil
=
ArrayBufferUtil
;
this
.
_apeDelayed
=
fals
e
;
this
.
_apeDelayed
=
tru
e
;
this
.
_apeDelayedMsgs
=
[];
this
.
_apeDelayedTimer
=
0
;
...
...
@@ -75,15 +75,17 @@ export default class Ape extends Emiter {
// 消息处理
_pduMessageHandler
(
regBuffer
,
_seekTime
)
{
let
seekTime
=
_seekTime
||
0
;
//这个只有在录制回放的时候才有
//loger.log("RCPDU_REG_ADAPTER============seekTime",seekTime);
if
(
this
.
_apeDelayed
)
{
// this._apeDelayedMsgs.push(regBuffer);
// this._apeDelayedStart();
/* loger.warn('APE->收到消息处理->',GlobalConfig.mcuDelay,GlobalConfig.messageDelay);
//延迟处理消息(3个条件--->ape允许延迟&&客户端设置需要延迟&&Sass设置的延迟时间大于0)
if (this._apeDelayed&&GlobalConfig.messageDelay&&GlobalConfig.mcuDelay>0) {
loger.warn('延迟处理消息->',GlobalConfig.mcuDelay);
setTimeout(() => {
this._pduRegAdapterHandler(regBuffer,seekTime);
},
GlobalConfig
.
mcuDelay
||
2000
);
}, GlobalConfig.mcuDelay
*1000);//mcuDelay单位是秒,这里需要换算为毫秒
return;
}
*/
//不延迟,立即处理
this
.
_pduRegAdapterHandler
(
regBuffer
,
seekTime
);
}
...
...
@@ -164,7 +166,7 @@ export default class Ape extends Emiter {
let
tableUpdateItems
=
tableUpdateData
.
items
;
let
tableUpdateItemsLen
=
tableUpdateItems
.
length
;
//loger.log("RCRegistryTableUpdateItemPdu " + tableUpdateItemsLen);
loger
.
log
(
tableUpdateData
);
//
loger.log(tableUpdateData);
for
(
let
i
=
0
;
i
<
tableUpdateItemsLen
;
++
i
)
{
let
tableItem
=
tableUpdateItems
[
i
];
...
...
src/apes/DocApe.js
查看文件 @
90d2ba0
...
...
@@ -34,8 +34,6 @@ class DocApe extends Ape {
this
.
docList
=
{};
//记录文档的数组this.docList[itemIdx]=itemIdx的数据
//this.activeDocItemIdx =0;//当前激活的文档itemIdx
//this.activeDocCurPage=1;//当前激活的文档的当前页
// 延迟
this
.
_apeDelayed
=
false
;
// Ape Models
this
.
registerKey
(
this
.
_session_id
,
this
.
_session_name
,
this
.
_session_tag
,
new
ArrayBuffer
);
...
...
src/apes/WhiteBoardApe.js
查看文件 @
90d2ba0
...
...
@@ -43,8 +43,6 @@ class WhiteBoardApe extends Ape {
this
.
annoInfos
=
{};
//储存所有的标注数据
this
.
insertHistory
=
[];
//添加的白板记录,用于撤回操作
// 白板延迟
// this._apeDelayed = true;
//Ape Models
this
.
registerKey
(
this
.
_session_id
,
this
.
_session_name
,
this
.
_session_tag
,
new
ArrayBuffer
);
this
.
registerObj
(
pdu
.
RCPDU_REG_REGISTER_TABLE
,
ApeConsts
.
WHITEBOARD_OBJ_TABLE_ID
,
...
...
src/mcu.js
查看文件 @
90d2ba0
...
...
@@ -17,187 +17,199 @@ import EngineUtils from 'EngineUtils';
let
loger
=
Loger
.
getLoger
(
'MCU'
);
class
MCU
extends
Emiter
{
constructor
()
{
super
();
this
.
_apes
=
{};
this
.
_everSocket
=
everSocket
;
this
.
_everSocket
.
on
(
everSocket
.
OPEN
,
this
.
_everSocketOpenHandler
.
bind
(
this
));
this
.
_everSocket
.
on
(
everSocket
.
MESSAGE
,
this
.
_everSocketMsgReceivedHandler
.
bind
(
this
));
this
.
_everSocket
.
on
(
everSocket
.
CLOSED
,
this
.
_everSocketCloseHandler
.
bind
(
this
));
}
// 注册Ape
registerApe
(
ape
)
{
this
.
_apes
[
ape
.
_session_id
]
=
ape
;
}
// EverSocket建立通道完毕
_everSocketOpenHandler
()
{
this
.
_sendJoinClassRequest
();
}
// EverSocket连接断开
_everSocketCloseHandler
()
{
GlobalConfig
.
setCurrentStatus
(
GlobalConfig
.
statusCode_3
);
this
.
_emit
(
MessageTypes
.
MCU_ERROR
,
MessageTypes
.
ERR_SOCKET_DISCONNECT
);
}
//MCU-发送加入课堂请求
_sendJoinClassRequest
(){
//const classInfo = this.classInfo;
loger
.
log
(
'MCU-发送加入课堂请求.'
);
loger
.
log
(
this
.
classInfo
);
var
descriptorPdu
=
new
pdu
[
'RCConferenceDescriptorPdu'
];
descriptorPdu
.
id
=
this
.
classInfo
.
classId
;
descriptorPdu
.
name
=
this
.
classInfo
.
className
||
""
;
descriptorPdu
.
mode
=
0
;
descriptorPdu
.
capacity
=
1
;
var
joinRequestPdu
=
new
pdu
[
'RCConferenceJoinRequestPdu'
];
joinRequestPdu
.
type
=
2
;
joinRequestPdu
.
initiator
=
this
.
classInfo
.
nodeId
;
joinRequestPdu
.
nodeType
=
PduConsts
.
NT_TERMINAL
;
//normal
joinRequestPdu
.
classDescription
=
descriptorPdu
;
// classDescription
let
pduMsg
=
pdu
.
create_join_class_request_pdu
(
joinRequestPdu
.
type
,
this
.
classInfo
.
nodeId
,
this
.
classInfo
.
classId
,
0
,
ApeConsts
.
BROADCAST_CHANNEL_ID
,
true
,
PduConsts
.
DP_TOP
,
this
.
classInfo
.
topNodeID
,
PduConsts
.
SEG_ONCE
);
pduMsg
.
set
(
"site"
,
this
.
classInfo
.
siteId
);
//课堂号对应的名称
pduMsg
.
set
(
"userId"
,
this
.
classInfo
.
userId
);
pduMsg
.
set
(
"userName"
,
Base64
.
fromByteArray
(
ArrayBufferUtil
.
strToUint8Array
(
this
.
classInfo
.
userName
)));
pduMsg
.
set
(
"userRole"
,
this
.
classInfo
.
userRole
);
pduMsg
.
set
(
"deviceType"
,
""
+
GlobalConfig
.
deviceType
);
pduMsg
.
set
(
"data"
,
joinRequestPdu
.
toArrayBuffer
());
this
.
_everSocket
.
send
(
pduMsg
.
toArrayBuffer
());
}
// EverSocket底层消息处理
_everSocketMsgReceivedHandler
(
data
)
{
let
pduMsg
=
pdu
.
decode_pdu
(
data
);
let
pduType
=
pduMsg
.
get
(
"type"
);
let
pduData
=
pduMsg
.
get
(
"data"
);
//loger.data('MCU-FirstLayer封装消息', 'type', pdu.id2type(pduMsg.type), pduMsg.type, 'sessionId', ApeConsts(pduMsg.sessionId), pduMsg.sessionId);
//loger.log('MCU-FirstLayer封装消息', 'type', pdu.id2type(pduMsg.type), pduMsg.type, 'sessionId', ApeConsts(pduMsg.sessionId), pduMsg.sessionId);
switch
(
pduType
)
{
case
PduType
.
RCPDU_CONNECT_PROVIDER_RESPONSE
:
//加入课堂请求返回数据处理
let
joinConfPdu
=
pdu
[
'RCConferenceJoinResponsePdu'
].
decode
(
pduData
);
let
pduResultCode
=
joinConfPdu
.
result
;
loger
.
warn
(
'RCPDU_CONNECT_PROVIDER_RESPONSE ->pduResultCode:'
+
pduResultCode
);
switch
(
pduResultCode
)
{
case
PduConsts
.
RET_SUCCESS
:
//加入成功
this
.
_updateMCUConfInfoDescription
(
joinConfPdu
.
classDescription
);
this
.
_emit
(
MessageTypes
.
CLASS_JOIN_MCU_SUCCESS
,
this
.
classInfo
);
break
;
case
PduConsts
.
RET_FULL_CAPACITY
:
this
.
_emit
(
MessageTypes
.
MCU_ERROR
,
MessageTypes
.
ERR_CLASS_JOIN_FULL
);
//this._emit(MessageTypes.CLASS_JOIN_FAILED,MessageTypes.ERR_CLASS_JOIN_FULL);
//this._emit(MessageTypes.CLASS_JOIN_FULL);
break
;
default
:
loger
.
arn
(
'JoinConfPdu-未知类型-等待处理.'
,
pduResultCode
);
break
constructor
()
{
super
();
this
.
_apes
=
{};
this
.
_everSocket
=
everSocket
;
this
.
_everSocket
.
on
(
everSocket
.
OPEN
,
this
.
_everSocketOpenHandler
.
bind
(
this
));
this
.
_everSocket
.
on
(
everSocket
.
MESSAGE
,
this
.
_everSocketMsgReceivedHandler
.
bind
(
this
));
this
.
_everSocket
.
on
(
everSocket
.
CLOSED
,
this
.
_everSocketCloseHandler
.
bind
(
this
));
}
// 注册Ape
registerApe
(
ape
)
{
this
.
_apes
[
ape
.
_session_id
]
=
ape
;
}
// EverSocket建立通道完毕
_everSocketOpenHandler
()
{
this
.
_sendJoinClassRequest
();
}
// EverSocket连接断开
_everSocketCloseHandler
()
{
GlobalConfig
.
setCurrentStatus
(
GlobalConfig
.
statusCode_3
);
this
.
_emit
(
MessageTypes
.
MCU_ERROR
,
MessageTypes
.
ERR_SOCKET_DISCONNECT
);
}
//MCU-发送加入课堂请求
_sendJoinClassRequest
()
{
//const classInfo = this.classInfo;
loger
.
log
(
'MCU-发送加入课堂请求.'
);
loger
.
log
(
this
.
classInfo
);
var
descriptorPdu
=
new
pdu
[
'RCConferenceDescriptorPdu'
];
descriptorPdu
.
id
=
this
.
classInfo
.
classId
;
descriptorPdu
.
name
=
this
.
classInfo
.
className
||
""
;
descriptorPdu
.
mode
=
0
;
descriptorPdu
.
capacity
=
1
;
var
joinRequestPdu
=
new
pdu
[
'RCConferenceJoinRequestPdu'
];
joinRequestPdu
.
type
=
2
;
joinRequestPdu
.
initiator
=
this
.
classInfo
.
nodeId
;
joinRequestPdu
.
nodeType
=
PduConsts
.
NT_TERMINAL
;
//normal
joinRequestPdu
.
classDescription
=
descriptorPdu
;
// classDescription
let
pduMsg
=
pdu
.
create_join_class_request_pdu
(
joinRequestPdu
.
type
,
this
.
classInfo
.
nodeId
,
this
.
classInfo
.
classId
,
0
,
ApeConsts
.
BROADCAST_CHANNEL_ID
,
true
,
PduConsts
.
DP_TOP
,
this
.
classInfo
.
topNodeID
,
PduConsts
.
SEG_ONCE
);
pduMsg
.
set
(
"site"
,
this
.
classInfo
.
siteId
);
//课堂号对应的名称
pduMsg
.
set
(
"userId"
,
this
.
classInfo
.
userId
);
pduMsg
.
set
(
"userName"
,
Base64
.
fromByteArray
(
ArrayBufferUtil
.
strToUint8Array
(
this
.
classInfo
.
userName
)));
pduMsg
.
set
(
"userRole"
,
this
.
classInfo
.
userRole
);
pduMsg
.
set
(
"deviceType"
,
""
+
GlobalConfig
.
deviceType
);
pduMsg
.
set
(
"data"
,
joinRequestPdu
.
toArrayBuffer
());
this
.
_everSocket
.
send
(
pduMsg
.
toArrayBuffer
());
}
// EverSocket底层消息处理
_everSocketMsgReceivedHandler
(
data
)
{
let
pduMsg
=
pdu
.
decode_pdu
(
data
);
let
pduType
=
pduMsg
.
get
(
"type"
);
let
pduData
=
pduMsg
.
get
(
"data"
);
//loger.data('MCU-FirstLayer封装消息', 'type', pdu.id2type(pduMsg.type), pduMsg.type, 'sessionId', ApeConsts(pduMsg.sessionId), pduMsg.sessionId);
//loger.log('MCU-FirstLayer封装消息', 'type', pdu.id2type(pduMsg.type), pduMsg.type, 'sessionId', ApeConsts(pduMsg.sessionId), pduMsg.sessionId);
switch
(
pduType
)
{
case
PduType
.
RCPDU_CONNECT_PROVIDER_RESPONSE
:
//加入课堂请求返回数据处理
let
joinConfPdu
=
pdu
[
'RCConferenceJoinResponsePdu'
].
decode
(
pduData
);
let
pduResultCode
=
joinConfPdu
.
result
;
loger
.
warn
(
'RCPDU_CONNECT_PROVIDER_RESPONSE ->pduResultCode:'
+
pduResultCode
);
switch
(
pduResultCode
)
{
case
PduConsts
.
RET_SUCCESS
:
//加入成功
this
.
_updateMCUConfInfoDescription
(
joinConfPdu
.
classDescription
);
this
.
_emit
(
MessageTypes
.
CLASS_JOIN_MCU_SUCCESS
,
this
.
classInfo
);
break
;
case
PduConsts
.
RET_FULL_CAPACITY
:
this
.
_emit
(
MessageTypes
.
MCU_ERROR
,
MessageTypes
.
ERR_CLASS_JOIN_FULL
);
//this._emit(MessageTypes.CLASS_JOIN_FAILED,MessageTypes.ERR_CLASS_JOIN_FULL);
//this._emit(MessageTypes.CLASS_JOIN_FULL);
break
;
default
:
loger
.
arn
(
'JoinConfPdu-未知类型-等待处理.'
,
pduResultCode
);
break
}
break
;
case
PduType
.
RCPDU_SEND_DATA_REQUEST
:
//先判断当前消息属于哪个APE 根据 sessionId来判断
let
ape
=
this
.
_apes
[
pduMsg
.
sessionId
];
let
sessionLabel
=
ApeConsts
(
pduMsg
.
sessionId
);
if
(
ape
)
{
let
subTypeLabel
=
pdu
.
id2type
(
pduMsg
.
subType
);
//loger.log('MCU-SecondLayer封装消息', 'sessionId', sessionLabel, pduMsg.sessionId, 'subtype', subTypeLabel, pduMsg.subType);
loger
.
warn
(
'MCU->收到消息处理->'
,
GlobalConfig
.
mcuDelay
,
GlobalConfig
.
messageDelay
);
//延迟处理消息(3个条件--->ape允许延迟&&客户端设置需要延迟&&Sass设置的延迟时间大于0)
if
(
ape
.
_apeDelayed
&&
GlobalConfig
.
messageDelay
&&
GlobalConfig
.
mcuDelay
>
0
)
{
loger
.
warn
(
'延迟处理消息->'
,
GlobalConfig
.
mcuDelay
);
setTimeout
(()
=>
{
//this._pduRegAdapterHandler(regBuffer, seekTime);
ape
.
_emit
(
pduMsg
.
subType
,
pduMsg
.
data
);
},
GlobalConfig
.
mcuDelay
*
1000
);
//mcuDelay单位是秒,
// 这里需要换算为毫秒
return
;
}
ape
.
_emit
(
pduMsg
.
subType
,
pduMsg
.
data
);
}
else
{
loger
.
warn
(
sessionLabel
+
'尚未注册'
);
}
break
;
default
:
loger
.
warn
(
'PDU-未知类型-等待处理.'
,
pduType
);
}
break
;
case
PduType
.
RCPDU_SEND_DATA_REQUEST
:
//先判断当前消息属于哪个APE 根据 sessionId来判断
let
ape
=
this
.
_apes
[
pduMsg
.
sessionId
];
let
sessionLabel
=
ApeConsts
(
pduMsg
.
sessionId
);
if
(
ape
)
{
let
subTypeLabel
=
pdu
.
id2type
(
pduMsg
.
subType
);
//loger.log('MCU-SecondLayer封装消息', 'sessionId', sessionLabel, pduMsg.sessionId, 'subtype', subTypeLabel, pduMsg.subType);
//ape广播事件,只要ape中监听就能收到
ape
.
_emit
(
pduMsg
.
subType
,
pduMsg
.
data
);
}
else
{
loger
.
warn
(
sessionLabel
+
'尚未注册'
);
}
break
;
default
:
loger
.
warn
(
'PDU-未知类型-等待处理.'
,
pduType
);
}
}
_updateMCUConfInfoDescription
(
_data
)
{
// let _mcuConfDesc=new pdu['RCConferenceDescriptorPdu'].decode(mcuConfDesc);
loger
.
log
(
'_updateMCUConfInfoDescription.'
);
//let classDescription=new pdu['RCConferenceDescriptorPdu'].decode(_data);
loger
.
log
(
_data
);
//let info = this.mcuClassInfo.info;
//info._conference_name = ArrayBufferUtil.uint8ArrayToStr(mcuConfDesc.name, 0);
//info._capacity = mcuConfDesc.capacity;
//info._mode = mcuConfDesc.mode;
}
// MU服务是否连接
get
connected
()
{
if
(
this
.
_everSocket
&&
this
.
_everSocket
.
connected
)
return
true
;
return
false
;
}
// 课堂发送消息 -- 消息同意序列号
send
(
msg
)
{
if
(
this
.
connected
)
{
loger
.
log
(
'MCU-发送课堂数据....'
);
this
.
_everSocket
.
send
(
msg
.
toArrayBuffer
());
}
else
{
loger
.
log
(
'MCU-发送课堂数据失败,MCU底层通道不可用'
);
this
.
_emit
(
MessageTypes
.
MCU_ERROR
,
MessageTypes
.
ERR_SOCKET_DISCONNECT
);
_updateMCUConfInfoDescription
(
_data
)
{
// let _mcuConfDesc=new pdu['RCConferenceDescriptorPdu'].decode(mcuConfDesc);
loger
.
log
(
'_updateMCUConfInfoDescription.'
);
//let classDescription=new pdu['RCConferenceDescriptorPdu'].decode(_data);
loger
.
log
(
_data
);
//let info = this.mcuClassInfo.info;
//info._conference_name = ArrayBufferUtil.uint8ArrayToStr(mcuConfDesc.name, 0);
//info._capacity = mcuConfDesc.capacity;
//info._mode = mcuConfDesc.mode;
}
// MU服务是否连接
get
connected
()
{
if
(
this
.
_everSocket
&&
this
.
_everSocket
.
connected
)
return
true
;
return
false
;
}
// 课堂发送消息 -- 消息同意序列号
send
(
msg
)
{
if
(
this
.
connected
)
{
loger
.
log
(
'MCU-发送课堂数据....'
);
this
.
_everSocket
.
send
(
msg
.
toArrayBuffer
());
}
else
{
loger
.
log
(
'MCU-发送课堂数据失败,MCU底层通道不可用'
);
this
.
_emit
(
MessageTypes
.
MCU_ERROR
,
MessageTypes
.
ERR_SOCKET_DISCONNECT
);
}
}
// 主动断开MCU连接
leaveMCU
()
{
for
(
let
ape
in
this
.
_apes
)
{
this
.
_apes
[
ape
].
stopApe
();
}
loger
.
log
(
'leaveMCU'
);
GlobalConfig
.
setCurrentStatus
(
GlobalConfig
.
statusCode_3
);
this
.
_everSocket
.
end
();
}
// 主动建立MCU连接
joinMCU
(
_classInfo
)
{
loger
.
log
(
'开始建立EverSocket通道.'
);
loger
.
log
(
_classInfo
);
_classInfo
.
classId
=
parseInt
(
_classInfo
.
classId
);
// classId 必须整形
this
.
classInfo
=
_classInfo
;
// 创建刷新nodeId
this
.
classInfo
.
nodeId
=
EngineUtils
.
creatSoleNumberFromTimestamp
();
GlobalConfig
.
nodeId
=
this
.
classInfo
.
nodeId
;
//这是标识自己身份的id
let
nodeInfoRecordPdu
=
new
pdu
[
'RCNodeInfoRecordPdu'
];
nodeInfoRecordPdu
.
name
=
this
.
classInfo
.
userName
;
nodeInfoRecordPdu
.
nodeId
=
this
.
classInfo
.
nodeId
;
nodeInfoRecordPdu
.
userId
=
this
.
classInfo
.
userId
;
nodeInfoRecordPdu
.
role
=
ApeConsts
.
userTypesToId
[
this
.
classInfo
.
userRole
]
||
1
;
//NR_NORMAL用户的身份,根据用户登录时的身份设置
nodeInfoRecordPdu
.
level
=
0
;
let
conferenceRecord
=
{};
//RCConferenceRecord_T
conferenceRecord
.
_conference_id
=
this
.
classInfo
.
classId
;
conferenceRecord
.
_top_node_id
=
this
.
classInfo
.
topNodeID
;
this
.
mcuClassInfo
=
{};
//RCMeetingInfo_T
this
.
mcuClassInfo
.
self
=
nodeInfoRecordPdu
;
this
.
mcuClassInfo
.
info
=
conferenceRecord
;
// 内部mcuConfInfo
this
.
classInfo
.
mcuClassInfo
=
this
.
mcuClassInfo
;
//开启EverSocket
this
.
_everSocket
.
begin
(
this
.
classInfo
.
MCUServerIP
,
this
.
classInfo
.
MCUServerPort
);
}
}
// 主动断开MCU连接
leaveMCU
()
{
for
(
let
ape
in
this
.
_apes
)
{
this
.
_apes
[
ape
].
stopApe
();
}
loger
.
log
(
'leaveMCU'
);
GlobalConfig
.
setCurrentStatus
(
GlobalConfig
.
statusCode_3
);
this
.
_everSocket
.
end
();
}
// 主动建立MCU连接
joinMCU
(
_classInfo
)
{
loger
.
log
(
'开始建立EverSocket通道.'
);
loger
.
log
(
_classInfo
);
_classInfo
.
classId
=
parseInt
(
_classInfo
.
classId
);
// classId 必须整形
this
.
classInfo
=
_classInfo
;
// 创建刷新nodeId
this
.
classInfo
.
nodeId
=
EngineUtils
.
creatSoleNumberFromTimestamp
();
GlobalConfig
.
nodeId
=
this
.
classInfo
.
nodeId
;
//这是标识自己身份的id
let
nodeInfoRecordPdu
=
new
pdu
[
'RCNodeInfoRecordPdu'
];
nodeInfoRecordPdu
.
name
=
this
.
classInfo
.
userName
;
nodeInfoRecordPdu
.
nodeId
=
this
.
classInfo
.
nodeId
;
nodeInfoRecordPdu
.
userId
=
this
.
classInfo
.
userId
;
nodeInfoRecordPdu
.
role
=
ApeConsts
.
userTypesToId
[
this
.
classInfo
.
userRole
]
||
1
;
//NR_NORMAL用户的身份,根据用户登录时的身份设置
nodeInfoRecordPdu
.
level
=
0
;
let
conferenceRecord
=
{};
//RCConferenceRecord_T
conferenceRecord
.
_conference_id
=
this
.
classInfo
.
classId
;
conferenceRecord
.
_top_node_id
=
this
.
classInfo
.
topNodeID
;
this
.
mcuClassInfo
=
{};
//RCMeetingInfo_T
this
.
mcuClassInfo
.
self
=
nodeInfoRecordPdu
;
this
.
mcuClassInfo
.
info
=
conferenceRecord
;
// 内部mcuConfInfo
this
.
classInfo
.
mcuClassInfo
=
this
.
mcuClassInfo
;
//开启EverSocket
this
.
_everSocket
.
begin
(
this
.
classInfo
.
MCUServerIP
,
this
.
classInfo
.
MCUServerPort
);
}
}
export
default
new
MCU
;
...
...
请
注册
或
登录
后发表评论