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
master
...
20170922-1
20171019-1
20171120-1w
dev
letv-20170426
ly20170622
ly20170622-2
ly20170622-3
ly20170627-2
ly20170706-1
ly20170708-2
ly20170708-3
ly20170710-1
ly20170717-1
ly20170719-1
ly20170723-1
ly20170724-2
ly20170726-1
ly20170731-1
ly20170731-2
ly20170801-2
ly20170802-1
ly20170818-1
ly20170818-2
ly20170820-1
ly20170821-1
ly20170824-1
ly20170829-1
ly20170925-1
ly20170926-1
ly20170927-1
ly20170929-1
ly20171011-1
ly20171013-1
ly20171013-2
ly20171016-1
ly20171021-1
ly20171023-1
ly20171024-1w
ly20171025-1w
ly20171026-1w
ly20171027-1w
ly20171030-1
ly20171030-2w
ly20171107-1
ly20171110-1w
ly20171113-1w
ly20171204-1w
ly20171208-1w
ly20171211-1w
ly20171211-2w
ly20171214-1w
mcuClientBranch
webRtc-dev
v2.38.13.20171216
v2.38.11.20171214
v2.38.3.201712011
v2.38.1.201712011
v2.36.11.20171204
v2.36.8.20171206
v2.36.4.20171201
v2.35.11.20171130
v2.34.16.20171128
v2.34.5.20171127
v2.33.6.20171123
v2.32.1.20171123
v2.31.12.20171122
v2.31.10.20171122
v2.30.5.20171117
v2.30.2.20171117
v2.29.5.20171114
v2.28.1.20171110
v2.27.11.20171109
v2.26.9.20171107
v2.26.6.20171103
v2.26.2.20171102
v2.25.7.20171031
v2.25.6.20171031
v2.25.0.20171030
v2.24.2.20171030
v2.23.0.20171030
v2.22.7.20171026
v2.20.5.20171023
v2.20.0.20171021
v2.19.8.20171020
v2.18.14.20171020
v2.18.10.20171019
v2.17.11.20171014
v2.16.8.20171012
v2.16.5.20171012
v2.15.5.20171001
v2.15.3.20170929
v2.14.5.20170927
v2.13.5.20170927
v2.12.14.20170927
v2.12.8.20170926
v2.12.6.20170925
v2.11.13.20170925
v2.10.7.20170921
v2.10.6.20170921
v2.10.5.20170920
v2.10.4.20170920
v2.9.3.20170919
v2.8.17.20170918
v2.8.8.20170917
v2.8.2.20170916
v2.6.2.20170915
v2.5.12.20170915
v2.5.6.20170914
v2.5.5.20170914
v2.4.4.20170908
v2.4.2.20170908
v2.4.0.20170907
v2.3.6.20170907
v2.2.16.20170905
v2.1.22.20170904
v1.84.0.20170912
v1.83.2.20170831
v1.82.11.20170829
v1.81.19.20170828
v1.80.2.20170824
v1.79.6.20170822
v1.79.5.20170821
v1.79.4.20170821
v1.79.3.20170821
v1.78.4.20170820
v1.77.4.20170819
v1.76.2.20170818
v1.75.0.20170815
v1.74.0.20170814
v1.73.2.20170814
v1.73.1.20170814
v1.71.0.20170813
v1.70.5.20170812
v1.68.2.20170812
v1.66.1.20170809
v1.65.25.20170808
v1.65.24.20170806
v1.63.1.20170731
v1.62.3.20170731
v1.61.0.20170729
v1.60.0.20170729
v1.59.0.20170729
v1.58.0.20170729
v1.57.0.20170727
v1.56.1.20170727
v1.56.0.20170727
v1.52.1.20170726
v1.51.0.20170724
v1.50.7.20170724
v1.49.1.20170724
v1.48.2.20170723
v1.46.1.20170722
v1.45.1.20170717
v1.43.1.20170711
v1.42.1.20170708
v1.41.0.20170708
v1.40.0.20170706
v1.39.2.20170706
v1.39.1.20170705
v1.38.4.20170629
v1.37.5.20170627
v1.37.2.20170622
v1.36.7.20170620
v1.36.4.20170620
v1.36.1.20170619
v1.35.4.20170619
v1.34.2.20170615
v1.33.2.20170615
v1.32.1.20170614
v1.31.11.20170613
v1.30.20.20170607
v1.30.7.20170606
v1.30.6.20170606
v1.30.5.20170605
v1.30.3.20170602
v1.29.8.20170601
v1.28.0.201705031
v1.27.16.201705027
v1.27.14.201705027
v1.27.10.201705026
v1.25.2.201705025
v1.23.5.201705023
v1.23.4.201705018
v1.21.1.201705017
v1.20.1.201705015
v1.19.1.201705012
v1.19.0.201705011
v1.18.0.201705010
v1.16.1.201705010
v1.15.2.20170507
v1.14.1.20170505
v1.13.0.20170504
v1.11.3.20170504
v1.10.2.20170428
v1.10.0.20170427
v1.9.20.20170426
v1.9.19.20170425
v1.9.18.20170425
v1.9.17.20170421
v1.9.16.20170420
v1.9.15.20170420
v1.9.11.20170419
v1.9.6.20170418
v1.9.4.20170417
v.1.9.2.20170413
v.1.9.0.20170411
v.1.8.22.20170411
v.1.8.19.20170411
v.1.8.16.20170410
v.1.8.13.20170409
v.1.8.10.20170407
v.1.8.9.20170407
v1.8.8.20170406
v.1.8.7.20170405-1
v.1.8.6.20170401-2
v.1.8.5.20170331-1
v.1.8.3.20170329-4
v1.8.1.20170321
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
;
...
...
请
注册
或
登录
后发表评论