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
李勇
2017-08-13 11:29:00 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
b461b2059f494b1dcc232037a78c827349d7076b
b461b205
1 parent
ad911aa6
1.录制回放增加伴音模块;2.mcu根据https切换为ws或wss;3.使用https时所有80端口都替换掉,不使用
隐藏空白字符变更
内嵌
并排对比
正在显示
5 个修改的文件
包含
767 行增加
和
689 行删除
src/EngineEntrance.js
src/EverSocket.js
src/GlobalConfig.js
src/RecordPlayBackParse.js
src/apes/DocApe.js
src/EngineEntrance.js
查看文件 @
b461b20
...
...
@@ -58,16 +58,21 @@ export default class MessageEntrance extends Emiter {
constructor
()
{
super
();
//sdk 信息
GlobalConfig
.
sdkVersion
=
"v1.
68.2
.20170812"
;
GlobalConfig
.
sdkVersion
=
"v1.
70.5
.20170812"
;
loger
.
warn
(
"sdkVersion:"
+
GlobalConfig
.
sdkVersion
);
//设置
let
locationProtocol
=
location
.
protocol
;
if
(
locationProtocol
!=
"https:"
){
GlobalConfig
.
locationProtocol
=
"http://"
;
}
else
{
if
(
locationProtocol
==
"https:"
){
GlobalConfig
.
isHttps
=
true
;
GlobalConfig
.
locationProtocol
=
"https://"
;
GlobalConfig
.
websocketProtocol
=
"wss://"
;
}
else
{
GlobalConfig
.
isHttps
=
false
;
GlobalConfig
.
locationProtocol
=
"http://"
;
GlobalConfig
.
websocketProtocol
=
"ws://"
;
}
loger
.
warn
(
"protocol:"
+
GlobalConfig
.
locationProtocol
);
//获取设备和系统信息
SystemConfig
.
getSystemInfo
();
...
...
@@ -496,7 +501,12 @@ export default class MessageEntrance extends Emiter {
//保存参数
GlobalConfig
.
isRecordPlayBack
=
false
;
//设置为非录制回放状态
GlobalConfig
.
classId
=
parseInt
(
_param
.
classId
);
GlobalConfig
.
portal
=
_param
.
portal
;
GlobalConfig
.
portal
=
_param
.
portal
||
""
;
if
(
GlobalConfig
.
isHttps
==
true
){
//https的时候替换所有80端口
GlobalConfig
.
portal
=
GlobalConfig
.
portal
.
replace
(
":80"
,
""
);
}
GlobalConfig
.
userId
=
_param
.
userId
||
"0"
;
//H5处理
GlobalConfig
.
isH5
=
_param
.
isH5
||
false
;
//外部传入的参数,是否是H5
...
...
@@ -2279,7 +2289,12 @@ export default class MessageEntrance extends Emiter {
//保存参数
GlobalConfig
.
isRecordPlayBack
=
true
;
//设置为录制回放状态
GlobalConfig
.
classId
=
parseInt
(
_param
.
classId
);
GlobalConfig
.
portal
=
_param
.
portal
;
GlobalConfig
.
portal
=
_param
.
portal
||
""
;
if
(
GlobalConfig
.
isHttps
==
true
){
//https的时候替换所有80端口
GlobalConfig
.
portal
=
GlobalConfig
.
portal
.
replace
(
":80"
,
""
);
}
GlobalConfig
.
userRole
=
ApeConsts
.
normal
;
//*************很重要,录制回放的时候,身份模式是普通人********
GlobalConfig
.
userId
=
_param
.
userId
||
"0"
;
GlobalConfig
.
userName
=
_param
.
userName
||
""
;
...
...
@@ -2330,6 +2345,12 @@ export default class MessageEntrance extends Emiter {
if
(
_video_ape
)
{
_video_ape
.
clearData
();
}
if
(
_mediaShareApe
)
{
_mediaShareApe
.
clearData
();
}
if
(
_musicShareApe
)
{
_musicShareApe
.
clearData
();
}
}
//录制回放加入 课堂成功
...
...
src/EverSocket.js
查看文件 @
b461b20
...
...
@@ -14,6 +14,8 @@
import
Emiter
from
'Emiter'
;
import
Loger
from
'Loger'
;
import
GlobalConfig
from
'GlobalConfig'
;
let
loger
=
Loger
.
getLoger
(
'EverSocket'
);
const
MCU_MAX_RECONNECTION
=
4
;
//最多重连次数
class
EverSocket
extends
Emiter
{
...
...
@@ -33,7 +35,8 @@ class EverSocket extends Emiter {
loger
.
error
(
'开始MCU连接->MCU连接地址无效'
);
}
this
.
_enableEverSocket
=
true
;
this
.
wsURL
=
'ws://'
+
ip
+
':'
+
port
;
//this.wsURL = 'ws://' + ip + ':' + port;
this
.
wsURL
=
GlobalConfig
.
websocketProtocol
+
ip
+
':'
+
port
;
this
.
_newConnection
();
}
...
...
@@ -42,10 +45,15 @@ class EverSocket extends Emiter {
this
.
_clear
();
}
switchSocketIp
(
ip
,
port
)
{
if
(
port
){
/*
if(port){
this.wsURL = 'ws://' + ip + ':' + port;
}else {
this.wsURL = 'ws://' + ip;
}*/
if
(
port
){
this
.
wsURL
=
GlobalConfig
.
websocketProtocol
+
ip
+
':'
+
port
;
}
else
{
this
.
wsURL
=
GlobalConfig
.
websocketProtocol
+
ip
;
}
}
get
connected
()
{
...
...
src/GlobalConfig.js
查看文件 @
b461b20
...
...
@@ -352,7 +352,7 @@ GlobalConfig.messageDelay = false; //是否启用消息延迟
GlobalConfig
.
mcuDelay
=
0
;
//默认的延迟时间(单位-秒)
GlobalConfig
.
docDelay
=
1600
;
//文档模块加入成功之后延迟发送送成功的消息给主模块(sdk内部使用)
GlobalConfig
.
portal
=
"
112.126.80.182:80
"
;
//Sass IP
GlobalConfig
.
portal
=
""
;
//Sass IP
//从Sass获取的
GlobalConfig
.
country
=
""
;
//国家
...
...
@@ -535,5 +535,7 @@ GlobalConfig.explorerVersion="未知";//浏览器版本
GlobalConfig
.
os
=
"未知"
;
//系统
GlobalConfig
.
locationProtocol
=
"http://"
;
//https;或http:
GlobalConfig
.
websocketProtocol
=
"ws://"
;
//wss或ws
GlobalConfig
.
isHttps
=
false
;
//是否是https
export
default
GlobalConfig
;
...
...
src/RecordPlayBackParse.js
查看文件 @
b461b20
...
...
@@ -41,6 +41,7 @@ class RecordPlayBackParse extends Emiter {
this
.
_docApeMssages
=
{};
//文档数据
this
.
_whiteApeMssages
=
{};
//白板数据
this
.
_mediaShareApeMssages
=
{};
//媒体共享
this
.
_musicShareApeMssages
=
{};
//伴音媒体共享
this
.
_timerCounter
=
new
TimerCounter
();
//计时器
this
.
_timerCounter
.
addTimerCallBack
(
this
.
_timerCounterUptate
.
bind
(
this
),
1
);
}
...
...
@@ -171,6 +172,9 @@ class RecordPlayBackParse extends Emiter {
case
ApeConsts
.
MEDIA_SESSION_ID
:
this
.
saveParseData
(
data
,
timestamp
,
this
.
_mediaShareApeMssages
);
break
;
case
ApeConsts
.
MUSIC_SESSION_ID
:
this
.
saveParseData
(
data
,
timestamp
,
this
.
_musicShareApeMssages
);
break
;
case
ApeConsts
.
WHITEBOARD_SESSION_ID
:
this
.
saveParseData
(
data
,
timestamp
,
this
.
_whiteApeMssages
);
break
;
...
...
@@ -235,7 +239,8 @@ class RecordPlayBackParse extends Emiter {
this
.
_searchMessageFromTime
(
this
.
_recordPlaybackTimestamp
,
this
.
_conferApeMssages
,
"conferApe"
);
this
.
_searchMessageFromTime
(
this
.
_recordPlaybackTimestamp
,
this
.
_chatApeMssages
,
"chatApe"
);
this
.
_searchMessageFromTime
(
this
.
_recordPlaybackTimestamp
,
this
.
_docApeMssages
,
"docApe"
);
this
.
_searchMessageFromTime
(
this
.
_recordPlaybackTimestamp
,
this
.
_mediaShareApeMssages
,
"mediaShareApe"
)
this
.
_searchMessageFromTime
(
this
.
_recordPlaybackTimestamp
,
this
.
_mediaShareApeMssages
,
"mediaShareApe"
);
this
.
_searchMessageFromTime
(
this
.
_recordPlaybackTimestamp
,
this
.
_musicShareApeMssages
,
"musicShareApe"
);
this
.
_searchMessageFromTime
(
this
.
_recordPlaybackTimestamp
,
this
.
_whiteApeMssages
,
"whiteApe"
);
this
.
_searchMessageFromTime
(
this
.
_recordPlaybackTimestamp
,
this
.
_videoApeMssages
,
"videoAp"
);
this
.
_searchMessageFromTime
(
this
.
_recordPlaybackTimestamp
,
this
.
_audioApeMssages
,
"audioApe"
);
...
...
@@ -319,7 +324,9 @@ class RecordPlayBackParse extends Emiter {
}
GlobalConfig
.
recordPlaybackMaxTime
=
this
.
_recordPlaybackMaxTime
;
console
.
log
(
'MediaChannleList'
,
this
.
mediaChannleList
);
console
.
log
(
'音视频通话模块数据'
,
this
.
mediaChannleList
);
console
.
log
(
'媒体共享模块数据'
,
this
.
_mediaShareApeMssages
);
console
.
log
(
'伴音模块数据'
,
this
.
_musicShareApeMssages
);
loger
.
log
(
"录制回放数据解析完成,录制回放的总时间长为->"
,
this
.
_recordPlaybackMaxTime
);
this
.
_emit
(
RecordPlayBackParse
.
CLASS_JOIN_RECORD_PLAYBACK_SUCCESS
,
{
"recordPlaybackMaxTime"
:
this
.
_recordPlaybackMaxTime
});
}
...
...
@@ -403,6 +410,9 @@ class RecordPlayBackParse extends Emiter {
//媒体共享模块
this
.
searchMediaShareApeMessageKeyfram
(
this
.
_mediaShareApeMssages
);
//伴音共享模块
this
.
searchMusicShareApeMessageKeyfram
(
this
.
_musicShareApeMssages
);
//聊天模块、白板标注模块的比较特殊,消息是累计的,默认最多30条
this
.
_searchChatHistoryMessageKeyfram
(
this
.
_chatApeMssages
,
ApeConsts
.
CHAT_SESSION_ID
);
this
.
_searchWhiteboradHistoryMessageKeyfram
(
this
.
_whiteApeMssages
,
ApeConsts
.
WHITEBOARD_SESSION_ID
);
...
...
@@ -486,6 +496,28 @@ class RecordPlayBackParse extends Emiter {
loger
.
log
(
"SEEK->APE->媒体共享"
,
this
.
_recordPlaybackTimestamp
,
"没有查找到相连的数据"
);
}
//伴音共享模块查找关键帧时间戳的消息
searchMusicShareApeMessageKeyfram
(
_apeMessages
){
if
(
!
_apeMessages
){
return
;
}
let
messageItem
;
let
keyFrameSeekTime
=
0
;
for
(
let
i
=
this
.
_recordPlaybackTimestamp
;
i
>
0
;
i
--
)
{
messageItem
=
_apeMessages
[
i
];
if
(
messageItem
)
{
keyFrameSeekTime
=
(
this
.
_recordPlaybackTimestamp
-
i
)
loger
.
log
(
"SEEK->APE"
,
'伴音共享'
,
this
.
_recordPlaybackTimestamp
,
"查找到相连的timestamp->"
,
i
,
'需要seek->'
,
keyFrameSeekTime
,
"秒"
);
//把时间点对应的数据发送,同一秒内有存在多个数据的情况
for
(
let
k
=
0
;
k
<
messageItem
.
length
;
k
++
)
{
this
.
_everSocketMsgReceivedHandler
(
messageItem
[
k
].
byteData
,
keyFrameSeekTime
);
}
return
;
}
}
loger
.
log
(
"SEEK->APE->伴音共享"
,
this
.
_recordPlaybackTimestamp
,
"没有查找到相连的数据"
);
}
//查找聊天模块ape关键帧数据,聊天模块比较特殊,消息是累积的,当前时间戳之前的都需要显示
_searchChatHistoryMessageKeyfram
(
_apeMessages
)
{
if
(
!
_apeMessages
){
...
...
src/apes/DocApe.js
查看文件 @
b461b20
...
...
@@ -25,720 +25,735 @@ let loger = Loger.getLoger('DocApe');
//let itemIdx = 0;//table插入新数据的计数id,目前用时间戳
class
DocApe
extends
Ape
{
constructor
()
{
super
(
ApeConsts
.
DOCSHARING_SESSION_ID
,
ApeConsts
.
DOCSHARING_SESSION_NAME
,
ApeConsts
.
DOCSHARING_SESSION_TAG
);
this
.
docList
=
{};
//记录文档的数组this.docList[itemIdx]=itemIdx的数据
// Ape Models
this
.
registerKey
(
this
.
_session_id
,
this
.
_session_name
,
this
.
_session_tag
,
new
ArrayBuffer
);
this
.
registerObj
(
pdu
.
RCPDU_REG_REGISTER_TABLE
,
ApeConsts
.
DOCSHARING_OBJ_TABLE_ID
,
ApeConsts
.
DOCSHARING_OBJ_TABLE_NAME
,
ApeConsts
.
DOCSHARING_OBJ_TABLE_TAG
,
0
,
new
ArrayBuffer
);
}
/////////////发送数据操作//////////////////////////////////////////////////////
//上传文档
documentUpload
(
paramInfo
)
{
if
(
paramInfo
==
null
||
EngineUtils
.
isEmptyObject
(
paramInfo
))
{
loger
.
warn
(
'上传文档->失败->参数错误->'
,
paramInfo
);
this
.
_emit
(
MessageTypes
.
MCU_ERROR
,
MessageTypes
.
ERR_APE_INTERFACE_PARAM_WRONG
);
return
;
}
//判断文档是否已经存在,每个文档都有唯一的docId,如果已经同步的文档中存在相同的docId就不需要再同步
if
(
this
.
checkDocId
(
paramInfo
.
docId
))
{
//文档已经存在相同的docId,不需要同步上传
loger
.
warn
(
'上传文档->失败->文档档的docId无效或已经存在相同的docId不需要上传'
);
return
;
}
let
itemIdx
=
EngineUtils
.
creatSoleNumberFromTimestamp
();
//
let
docDataModelPdu
=
this
.
packPdu
(
paramInfo
,
itemIdx
);
if
(
docDataModelPdu
==
null
)
{
loger
.
log
(
'上传文档->失败->数据无效'
);
this
.
_emit
(
MessageTypes
.
MCU_ERROR
,
MessageTypes
.
ERR_APE_INTERFACE_PARAM_WRONG
);
return
;
}
//console.log(docDataModelPdu);
let
tableItemPdu
=
new
pdu
[
'RCRegistryTableItemPdu'
];
tableItemPdu
.
itemIdx
=
itemIdx
;
//直接用时间戳作为id
tableItemPdu
.
registerObjId
=
ApeConsts
.
DOCSHARING_OBJ_TABLE_ID
;
// tableItemPdu.registerObjId=ApeConsts.DOCSHARING_OBJ_TABLE_ID_H5;
tableItemPdu
.
owner
=
0
;
//收到flash的是这个值,不清楚先写固定
tableItemPdu
.
itemData
=
docDataModelPdu
.
toArrayBuffer
();
//insert
let
tableInsertItemPdu
=
new
pdu
[
'RCRegistryTableInsertItemPdu'
];
//optional RCPduType_E type = 1 [default = RCPDU_REG_TABLE_UPDATE_PDU];
//repeated RCRegistryTableItemPdu items = 2;
tableInsertItemPdu
.
type
=
pdu
.
RCPDU_REG_TABLE_INSERT_PDU
;
//
tableInsertItemPdu
.
items
.
push
(
tableItemPdu
);
let
updateObjPdu
=
new
pdu
[
'RCRegistryUpdateObjPdu'
];
updateObjPdu
.
objId
=
ApeConsts
.
DOCSHARING_OBJ_TABLE_ID
;
// updateObjPdu.objId = ApeConsts.DOCSHARING_OBJ_TABLE_ID_H5;
updateObjPdu
.
subType
=
tableInsertItemPdu
.
type
;
updateObjPdu
.
userData
=
tableInsertItemPdu
.
toArrayBuffer
();
//同步
let
adapterItemPdu
=
new
pdu
[
'RCAdapterItemPdu'
];
adapterItemPdu
.
type
=
pdu
.
RCPDU_REG_UPDATE_OBJ
;
adapterItemPdu
.
itemData
=
updateObjPdu
.
toArrayBuffer
();
let
adapterPdu
=
new
pdu
[
'RCAdapterPdu'
];
adapterPdu
.
type
=
pdu
.
RCPDU_REG_ADAPTER
;
adapterPdu
.
item
.
push
(
adapterItemPdu
);
loger
.
log
(
"上传文档->发送->itemIdx="
+
tableItemPdu
.
itemIdx
);
this
.
sendUniform
(
adapterPdu
,
true
);
}
updaterDoc
(
_docDataModel
,
_itemIdx
)
{
//loger.log("文档===updaterDoc ",_itemIdx);
//验证坐标点集合数组是否合法
if
(
_docDataModel
==
null
||
_itemIdx
==
null
)
{
this
.
_emit
(
MessageTypes
.
MCU_ERROR
,
MessageTypes
.
ERR_APE_INTERFACE_PARAM_WRONG
);
return
null
;
}
//loger.log("文档->updaterDoc ", _docDataModel);
let
docDataModelPdu
=
this
.
packPdu
(
_docDataModel
,
_itemIdx
);
let
tableItemPdu
=
new
pdu
[
'RCRegistryTableItemPdu'
];
tableItemPdu
.
itemIdx
=
_itemIdx
;
//直接用时间戳作为id
//tableItemPdu.registerObjId=ApeConsts.DOCSHARING_OBJ_TABLE_ID;// tableItemPdu.registerObjId=ApeConsts.DOCSHARING_OBJ_TABLE_ID_H5;
tableItemPdu
.
owner
=
0
;
//收到flash的是这个值,不清楚先写固定
tableItemPdu
.
itemData
=
docDataModelPdu
.
toArrayBuffer
();
//insert
let
tableInsertItemPdu
=
new
pdu
[
'RCRegistryTableUpdateItemPdu'
];
//optional RCPduType_E type = 1 [default = RCPDU_REG_TABLE_UPDATE_PDU];
//repeated RCRegistryTableItemPdu items = 2;
tableInsertItemPdu
.
type
=
pdu
.
RCPDU_REG_TABLE_UPDATE_PDU
;
//
tableInsertItemPdu
.
items
.
push
(
tableItemPdu
);
let
updateObjPdu
=
new
pdu
[
'RCRegistryUpdateObjPdu'
];
updateObjPdu
.
objId
=
ApeConsts
.
DOCSHARING_OBJ_TABLE_ID
;
// updateObjPdu.objId = ApeConsts.DOCSHARING_OBJ_TABLE_ID_H5;
updateObjPdu
.
subType
=
tableInsertItemPdu
.
type
;
updateObjPdu
.
userData
=
tableInsertItemPdu
.
toArrayBuffer
();
//同步
let
adapterItemPdu
=
new
pdu
[
'RCAdapterItemPdu'
];
adapterItemPdu
.
type
=
pdu
.
RCPDU_REG_UPDATE_OBJ
;
adapterItemPdu
.
itemData
=
updateObjPdu
.
toArrayBuffer
();
let
adapterPdu
=
new
pdu
[
'RCAdapterPdu'
];
adapterPdu
.
type
=
pdu
.
RCPDU_REG_ADAPTER
;
adapterPdu
.
item
.
push
(
adapterItemPdu
);
//loger.log("发送更新文档.itemIdx=" + tableItemPdu.itemIdx);
this
.
sendUniform
(
adapterPdu
,
true
);
}
//获取文档的完整地址和所有图片
getDocFullAddress
(
_param
){
if
(
_param
==
null
||
_param
.
url
==
null
||
_param
.
itemIdx
==
null
)
{
loger
.
warn
(
'获取文档完整地址->传递的参数不正确->'
,
_param
);
return
{
"code"
:
ApeConsts
.
RETURN_FAILED
,
"data"
:
"获取文档时传递的参数不对"
};
}
let
fullPath
=
''
;
//文档路径地址
let
pageNum
=
1
;
//总页数
let
docType
=
""
;
//文档地址的后缀类型
let
fileType
=
""
;
//文档的原始类型
let
docItem
=
this
.
docList
[
_param
.
itemIdx
];
if
(
docItem
){
fullPath
=
docItem
.
url
||
""
;
pageNum
=
docItem
.
pageNum
||
1
;
fileType
=
docItem
.
fileType
||
""
}
else
{
fullPath
=
_param
.
url
;
}
//获取当前文档的后缀名
docType
=
this
.
_getDocType
(
fullPath
);
let
substrFullPath
=
this
.
_getDocPath
(
fullPath
);
//获取去掉后缀和文件名的地址,需要获取同目录下其他文件
let
imagesArr
=
[];
let
htmlPath
=
""
;
let
pdfPath
=
""
;
//根据文件后缀名,生成对应的访问地址
if
(
docType
==
"jpg"
||
docType
==
"png"
||
docType
==
"swf"
||
docType
==
"pdf"
||
docType
==
"doc"
||
docType
==
"pptx"
){
//页数从1开始
for
(
let
i
=
1
;
i
<=
pageNum
;
i
++
)
{
imagesArr
.
push
(
substrFullPath
+
"/"
+
i
+
".jpg"
);
}
}
if
(
docType
==
"swf"
||
docType
==
"pdf"
||
docType
==
"doc"
||
docType
==
"pptx"
){
pdfPath
=
fullPath
.
replace
(
/
\.
swf/g
,
".pdf"
)
||
""
;
}
//动态PPT
if
(
docType
==
"html"
){
htmlPath
=
fullPath
;
}
//返回文档第所有地址
return
{
'code'
:
ApeConsts
.
RETURN_SUCCESS
,
'data'
:
''
,
'docFullAddress'
:{
'images'
:
imagesArr
,
'pdf'
:
pdfPath
,
'html'
:
htmlPath
}};
constructor
()
{
super
(
ApeConsts
.
DOCSHARING_SESSION_ID
,
ApeConsts
.
DOCSHARING_SESSION_NAME
,
ApeConsts
.
DOCSHARING_SESSION_TAG
);
this
.
docList
=
{};
//记录文档的数组this.docList[itemIdx]=itemIdx的数据
// Ape Models
this
.
registerKey
(
this
.
_session_id
,
this
.
_session_name
,
this
.
_session_tag
,
new
ArrayBuffer
);
this
.
registerObj
(
pdu
.
RCPDU_REG_REGISTER_TABLE
,
ApeConsts
.
DOCSHARING_OBJ_TABLE_ID
,
ApeConsts
.
DOCSHARING_OBJ_TABLE_NAME
,
ApeConsts
.
DOCSHARING_OBJ_TABLE_TAG
,
0
,
new
ArrayBuffer
);
}
/////////////发送数据操作//////////////////////////////////////////////////////
//上传文档
documentUpload
(
paramInfo
)
{
if
(
paramInfo
==
null
||
EngineUtils
.
isEmptyObject
(
paramInfo
))
{
loger
.
warn
(
'上传文档->失败->参数错误->'
,
paramInfo
);
this
.
_emit
(
MessageTypes
.
MCU_ERROR
,
MessageTypes
.
ERR_APE_INTERFACE_PARAM_WRONG
);
return
;
}
//判断文档是否已经存在,每个文档都有唯一的docId,如果已经同步的文档中存在相同的docId就不需要再同步
if
(
this
.
checkDocId
(
paramInfo
.
docId
))
{
//文档已经存在相同的docId,不需要同步上传
loger
.
warn
(
'上传文档->失败->文档档的docId无效或已经存在相同的docId不需要上传'
);
return
;
}
_getDocType
(
_fullPath
){
if
(
!
_fullPath
){
return
""
;
}
if
(
_fullPath
.
lastIndexOf
(
".jpg"
)
>=
0
){
return
"jpg"
;
}
if
(
_fullPath
.
lastIndexOf
(
".png"
)
>=
0
){
return
"png"
;
}
if
(
_fullPath
.
lastIndexOf
(
".swf"
)
>=
0
){
return
"swf"
;
}
if
(
_fullPath
.
lastIndexOf
(
".pdf"
)
>=
0
){
return
"pdf"
;
}
if
(
_fullPath
.
lastIndexOf
(
".doc"
)
>=
0
){
return
"doc"
;
}
if
(
_fullPath
.
lastIndexOf
(
".html"
)
>=
0
){
return
"html"
;
}
if
(
_fullPath
.
lastIndexOf
(
".pptx"
)
>=
0
){
return
"pptx"
;
}
return
""
;
let
itemIdx
=
EngineUtils
.
creatSoleNumberFromTimestamp
();
//
let
docDataModelPdu
=
this
.
packPdu
(
paramInfo
,
itemIdx
);
if
(
docDataModelPdu
==
null
)
{
loger
.
log
(
'上传文档->失败->数据无效'
);
this
.
_emit
(
MessageTypes
.
MCU_ERROR
,
MessageTypes
.
ERR_APE_INTERFACE_PARAM_WRONG
);
return
;
}
//获取去掉文件名和后缀名的地址 http://www.xxx.xxx/image/aa.jpg -->http://www.xxx.xxx/image/
_getDocPath
(
_fullPath
){
if
(
!
_fullPath
){
return
""
;
}
var
lastIndex
=
_fullPath
.
lastIndexOf
(
"/"
);
if
(
lastIndex
>
0
)
{
return
_fullPath
.
substr
(
0
,
lastIndex
);
}
return
_fullPath
;
//console.log(docDataModelPdu);
let
tableItemPdu
=
new
pdu
[
'RCRegistryTableItemPdu'
];
tableItemPdu
.
itemIdx
=
itemIdx
;
//直接用时间戳作为id
tableItemPdu
.
registerObjId
=
ApeConsts
.
DOCSHARING_OBJ_TABLE_ID
;
// tableItemPdu.registerObjId=ApeConsts.DOCSHARING_OBJ_TABLE_ID_H5;
tableItemPdu
.
owner
=
0
;
//收到flash的是这个值,不清楚先写固定
tableItemPdu
.
itemData
=
docDataModelPdu
.
toArrayBuffer
();
//insert
let
tableInsertItemPdu
=
new
pdu
[
'RCRegistryTableInsertItemPdu'
];
//optional RCPduType_E type = 1 [default = RCPDU_REG_TABLE_UPDATE_PDU];
//repeated RCRegistryTableItemPdu items = 2;
tableInsertItemPdu
.
type
=
pdu
.
RCPDU_REG_TABLE_INSERT_PDU
;
//
tableInsertItemPdu
.
items
.
push
(
tableItemPdu
);
let
updateObjPdu
=
new
pdu
[
'RCRegistryUpdateObjPdu'
];
updateObjPdu
.
objId
=
ApeConsts
.
DOCSHARING_OBJ_TABLE_ID
;
// updateObjPdu.objId = ApeConsts.DOCSHARING_OBJ_TABLE_ID_H5;
updateObjPdu
.
subType
=
tableInsertItemPdu
.
type
;
updateObjPdu
.
userData
=
tableInsertItemPdu
.
toArrayBuffer
();
//同步
let
adapterItemPdu
=
new
pdu
[
'RCAdapterItemPdu'
];
adapterItemPdu
.
type
=
pdu
.
RCPDU_REG_UPDATE_OBJ
;
adapterItemPdu
.
itemData
=
updateObjPdu
.
toArrayBuffer
();
let
adapterPdu
=
new
pdu
[
'RCAdapterPdu'
];
adapterPdu
.
type
=
pdu
.
RCPDU_REG_ADAPTER
;
adapterPdu
.
item
.
push
(
adapterItemPdu
);
loger
.
log
(
"上传文档->发送->itemIdx="
+
tableItemPdu
.
itemIdx
);
this
.
sendUniform
(
adapterPdu
,
true
);
}
updaterDoc
(
_docDataModel
,
_itemIdx
)
{
//loger.log("文档===updaterDoc ",_itemIdx);
//验证坐标点集合数组是否合法
if
(
_docDataModel
==
null
||
_itemIdx
==
null
)
{
this
.
_emit
(
MessageTypes
.
MCU_ERROR
,
MessageTypes
.
ERR_APE_INTERFACE_PARAM_WRONG
);
return
null
;
}
//获取文档的图片完整地址
getDocImageFullPath
(
_param
)
{
if
(
_param
==
null
||
_param
.
relativeUrl
==
null
||
_param
.
relativeUrl
==
""
)
{
loger
.
warn
(
'获取文档完整地址,传递的参数不对.'
,
_param
);
return
[];
}
let
port
=
(
GlobalConfig
.
DOCServerPort
==
""
||
GlobalConfig
.
DOCServerPort
==
null
)
?
""
:
":"
+
GlobalConfig
.
DOCServerPort
;
let
fullPath
=
GlobalConfig
.
DOCServerIP
+
port
+
_param
.
relativeUrl
;
if
(
fullPath
&&
fullPath
.
indexOf
(
"http://"
)
<
0
)
{
fullPath
=
"http://"
+
fullPath
;
}
var
fileType
=
"jpg"
;
switch
(
_param
.
type
)
{
case
"jpg"
:
fileType
=
"jpg"
;
fullPath
=
this
.
replacePathType
(
fullPath
)
+
".jpg"
;
break
;
case
"png"
:
fileType
=
"png"
;
fullPath
=
this
.
replacePathType
(
fullPath
)
+
".png"
;
break
;
default
:
//不做处理,直接返回拼接的地址
break
;
}
if
(
_param
.
pageNum
&&
parseInt
(
_param
.
pageNum
)
>
1
)
{
//如果是多页的,需要返回序列
var
lastIndex
=
fullPath
.
lastIndexOf
(
"/"
);
if
(
lastIndex
>
0
)
{
let
newPath
=
fullPath
.
substr
(
0
,
lastIndex
);
let
pathArr
=
[];
//页数从1开始
for
(
let
i
=
1
;
i
<=
_param
.
pageNum
;
i
++
)
{
pathArr
.
push
(
newPath
+
"/"
+
i
+
"."
+
fileType
);
}
return
pathArr
;
}
else
{
return
[
fullPath
];
}
}
else
{
return
[
fullPath
];
}
//loger.log("文档->updaterDoc ", _docDataModel);
let
docDataModelPdu
=
this
.
packPdu
(
_docDataModel
,
_itemIdx
);
let
tableItemPdu
=
new
pdu
[
'RCRegistryTableItemPdu'
];
tableItemPdu
.
itemIdx
=
_itemIdx
;
//直接用时间戳作为id
//tableItemPdu.registerObjId=ApeConsts.DOCSHARING_OBJ_TABLE_ID;// tableItemPdu.registerObjId=ApeConsts.DOCSHARING_OBJ_TABLE_ID_H5;
tableItemPdu
.
owner
=
0
;
//收到flash的是这个值,不清楚先写固定
tableItemPdu
.
itemData
=
docDataModelPdu
.
toArrayBuffer
();
//insert
let
tableInsertItemPdu
=
new
pdu
[
'RCRegistryTableUpdateItemPdu'
];
//optional RCPduType_E type = 1 [default = RCPDU_REG_TABLE_UPDATE_PDU];
//repeated RCRegistryTableItemPdu items = 2;
tableInsertItemPdu
.
type
=
pdu
.
RCPDU_REG_TABLE_UPDATE_PDU
;
//
tableInsertItemPdu
.
items
.
push
(
tableItemPdu
);
let
updateObjPdu
=
new
pdu
[
'RCRegistryUpdateObjPdu'
];
updateObjPdu
.
objId
=
ApeConsts
.
DOCSHARING_OBJ_TABLE_ID
;
// updateObjPdu.objId = ApeConsts.DOCSHARING_OBJ_TABLE_ID_H5;
updateObjPdu
.
subType
=
tableInsertItemPdu
.
type
;
updateObjPdu
.
userData
=
tableInsertItemPdu
.
toArrayBuffer
();
//同步
let
adapterItemPdu
=
new
pdu
[
'RCAdapterItemPdu'
];
adapterItemPdu
.
type
=
pdu
.
RCPDU_REG_UPDATE_OBJ
;
adapterItemPdu
.
itemData
=
updateObjPdu
.
toArrayBuffer
();
let
adapterPdu
=
new
pdu
[
'RCAdapterPdu'
];
adapterPdu
.
type
=
pdu
.
RCPDU_REG_ADAPTER
;
adapterPdu
.
item
.
push
(
adapterItemPdu
);
//loger.log("发送更新文档.itemIdx=" + tableItemPdu.itemIdx);
this
.
sendUniform
(
adapterPdu
,
true
);
}
//获取文档的完整地址和所有图片
getDocFullAddress
(
_param
)
{
if
(
_param
==
null
||
_param
.
url
==
null
||
_param
.
itemIdx
==
null
)
{
loger
.
warn
(
'获取文档完整地址->传递的参数不正确->'
,
_param
);
return
{
"code"
:
ApeConsts
.
RETURN_FAILED
,
"data"
:
"获取文档时传递的参数不对"
};
}
let
fullPath
=
''
;
//文档路径地址
let
pageNum
=
1
;
//总页数
let
docType
=
""
;
//文档地址的后缀类型
let
fileType
=
""
;
//文档的原始类型
let
docItem
=
this
.
docList
[
_param
.
itemIdx
];
if
(
docItem
)
{
fullPath
=
docItem
.
url
||
""
;
pageNum
=
docItem
.
pageNum
||
1
;
fileType
=
docItem
.
fileType
||
""
}
else
{
fullPath
=
_param
.
url
;
}
//获取文档的pdf完整地址
getDocPDFFullPath
(
_param
)
{
if
(
_param
==
null
||
_param
.
relativeUrl
==
null
||
_param
.
relativeUrl
==
""
)
{
loger
.
warn
(
'获取文档完整地址,传递的参数不对.'
,
_param
);
return
[];
}
let
port
=
(
GlobalConfig
.
DOCServerPort
==
""
||
GlobalConfig
.
DOCServerPort
==
null
)
?
""
:
":"
+
GlobalConfig
.
DOCServerPort
;
let
fullPath
=
GlobalConfig
.
DOCServerIP
+
port
+
_param
.
relativeUrl
;
if
(
fullPath
&&
fullPath
.
indexOf
(
"http://"
)
<
0
)
{
fullPath
=
"http://"
+
fullPath
;
}
fullPath
=
this
.
replacePathType
(
fullPath
)
+
".pdf"
;
return
[
fullPath
];
}
// 去除文件的后缀格式名称
replacePathType
(
_path
)
{
let
path
=
_path
;
path
=
path
.
replace
(
/.jpg/g
,
""
);
path
=
path
.
replace
(
/.png/g
,
""
);
path
=
path
.
replace
(
/.swf/g
,
""
);
path
=
path
.
replace
(
/.pdf/g
,
""
);
return
path
;
}
//组织完整的文档信息,包含上传时的信息和转换后的完整地址信息
_docPackFullInfo
(
_itemDataInfo
){
let
itemDataInfo
=
_itemDataInfo
;
let
getDocAddress
=
this
.
getDocFullAddress
(
_itemDataInfo
);
//loger.log('docPackFullInfo->', itemDataInfo);
if
(
getDocAddress
.
code
==
ApeConsts
.
RETURN_SUCCESS
){
itemDataInfo
.
images
=
getDocAddress
.
docFullAddress
.
images
||
[];
itemDataInfo
.
pdf
=
getDocAddress
.
docFullAddress
.
pdf
||
""
;
itemDataInfo
.
html
=
getDocAddress
.
docFullAddress
.
html
||
""
;
}
else
{
itemDataInfo
.
images
=
[];
itemDataInfo
.
pdf
=
''
;
itemDataInfo
.
html
=
''
;
}
return
itemDataInfo
;
}
//更新文档模块的录制信息,每次开启录制的时候需要把当前文档的信息更新一次
updaterRecordApeStatus
(
_param
){
/* if(GlobalConfig.isHost&&!GlobalConfig.isRecordPlayBack&&GlobalConfig.activeDocId>0){
loger.log("录制状态发送改变->更新当前的文档数据->docId:", GlobalConfig.activeDocId, 'page:',GlobalConfig.activeDocCurPage);
this.documentSwitchPage({
"itemIdx": GlobalConfig.activeDocId,
"curPageNo":GlobalConfig.activeDocCurPage
});
}*/
loger
.
warn
(
"录制状态发送改变->更新当前的文档数据->docId:"
,
GlobalConfig
.
activeDocId
,
'page:'
,
GlobalConfig
.
activeDocCurPage
);
this
.
documentSwitchPage
({
"itemIdx"
:
GlobalConfig
.
activeDocId
,
"curPageNo"
:
GlobalConfig
.
activeDocCurPage
});
}
//清除当前文档模块的数据
clearData
(){
loger
.
log
(
"clearData->"
)
this
.
docList
=
{};
GlobalConfig
.
activeDocId
=
0
;
GlobalConfig
.
activeDocCurPage
=
1
;
}
//切换文档
documentSwitchDoc
(
paramInfo
)
{
loger
.
log
(
'切换文档->'
,
paramInfo
);
if
(
GlobalConfig
.
isRecordPlayBack
)
{
loger
.
warn
(
'录制回放状态不允许切换文档'
);
return
;
}
if
(
paramInfo
==
null
||
paramInfo
.
itemIdx
==
null
)
{
loger
.
warn
(
'切换文档失败,参数错误'
,
paramInfo
);
this
.
_emit
(
MessageTypes
.
MCU_ERROR
,
MessageTypes
.
ERR_APE_INTERFACE_PARAM_WRONG
);
return
;
}
if
(
paramInfo
.
itemIdx
==
GlobalConfig
.
activeDocId
&&
GlobalConfig
.
activeDocId
!=
0
)
{
loger
.
warn
(
'文档已经显示'
,
paramInfo
.
itemIdx
,
GlobalConfig
.
activeDocId
);
return
;
}
//更新切换之前的文档的数据,要显示当前切换的文档,上一个文档需要隐藏
let
oldDocModel
;
if
(
GlobalConfig
.
activeDocId
!=
0
)
{
oldDocModel
=
this
.
docList
[
GlobalConfig
.
activeDocId
];
if
(
oldDocModel
)
{
oldDocModel
.
action
=
ApeConsts
.
DOC_ACTION_NORMAL
;
oldDocModel
.
visible
=
false
;
//设置为不可见
oldDocModel
.
animationStep
=
1
;
//切换文档之后动画步数还原
}
}
//获取已经存在的数据
let
docDataModel
=
this
.
docList
[
paramInfo
.
itemIdx
];
if
(
docDataModel
==
null
)
{
loger
.
warn
(
'切换文档失败,文档不存在'
,
paramInfo
);
this
.
_emit
(
MessageTypes
.
MCU_ERROR
,
MessageTypes
.
ERR_APE_INTERFACE_PARAM_WRONG
);
return
;
}
//更新当前选择的文档数据的字段
docDataModel
.
action
=
ApeConsts
.
DOC_ACTION_SWITCH_DOC
;
docDataModel
.
visible
=
paramInfo
.
visible
||
false
;
//默认是false
docDataModel
.
animationStep
=
1
;
//切换文档之后动画步数还原
//替换地址的协议头,如果地址栏是https开头就换成https
fullPath
=
fullPath
.
replace
(
"http://"
,
GlobalConfig
.
locationProtocol
);
//获取当前文档的后缀名
docType
=
this
.
_getDocType
(
fullPath
);
let
substrFullPath
=
this
.
_getDocPath
(
fullPath
);
//获取去掉后缀和文件名的地址,需要获取同目录下其他文件
let
imagesArr
=
[];
let
htmlPath
=
""
;
let
pdfPath
=
""
;
//根据文件后缀名,生成对应的访问地址
if
(
docType
==
"jpg"
||
docType
==
"png"
||
docType
==
"swf"
||
docType
==
"pdf"
||
docType
==
"doc"
||
docType
==
"pptx"
)
{
//页数从1开始
for
(
let
i
=
1
;
i
<=
pageNum
;
i
++
)
{
imagesArr
.
push
(
substrFullPath
+
"/"
+
i
+
".jpg"
);
}
}
if
(
docType
==
"swf"
||
docType
==
"pdf"
||
docType
==
"doc"
||
docType
==
"pptx"
)
{
pdfPath
=
fullPath
.
replace
(
/
\.
swf/g
,
".pdf"
)
||
""
;
}
//动态PPT
if
(
docType
==
"html"
)
{
htmlPath
=
fullPath
;
}
//返回文档第所有地址
return
{
'code'
:
ApeConsts
.
RETURN_SUCCESS
,
'data'
:
''
,
'docFullAddress'
:
{
'images'
:
imagesArr
,
'pdf'
:
pdfPath
,
'html'
:
htmlPath
}
};
}
//loger.log('切换文档,当前文档和上一个显示的文档都需要更新状态');
loger
.
log
({
"oldDoc"
:
oldDocModel
,
"nowDoc"
:
docDataModel
});
//更新当前选择的文档
this
.
updaterDoc
(
docDataModel
,
docDataModel
.
itemIdx
);
_getDocType
(
_fullPath
)
{
if
(
!
_fullPath
)
{
return
""
;
}
if
(
_fullPath
.
lastIndexOf
(
".jpg"
)
>=
0
)
{
return
"jpg"
;
}
if
(
_fullPath
.
lastIndexOf
(
".png"
)
>=
0
)
{
return
"png"
;
}
if
(
_fullPath
.
lastIndexOf
(
".swf"
)
>=
0
)
{
return
"swf"
;
}
if
(
_fullPath
.
lastIndexOf
(
".pdf"
)
>=
0
)
{
return
"pdf"
;
}
if
(
_fullPath
.
lastIndexOf
(
".doc"
)
>=
0
)
{
return
"doc"
;
}
if
(
_fullPath
.
lastIndexOf
(
".html"
)
>=
0
)
{
return
"html"
;
}
if
(
_fullPath
.
lastIndexOf
(
".pptx"
)
>=
0
)
{
return
"pptx"
;
}
return
""
;
}
//更新上一个文档 隐藏
if
(
oldDocModel
)
{
this
.
updaterDoc
(
oldDocModel
,
oldDocModel
.
itemIdx
);
}
//获取去掉文件名和后缀名的地址 http://www.xxx.xxx/image/aa.jpg -->http://www.xxx.xxx/image/
_getDocPath
(
_fullPath
)
{
if
(
!
_fullPath
)
{
return
""
;
}
var
lastIndex
=
_fullPath
.
lastIndexOf
(
"/"
);
if
(
lastIndex
>
0
)
{
return
_fullPath
.
substr
(
0
,
lastIndex
);
}
return
_fullPath
;
}
//获取文档的图片完整地址
getDocImageFullPath
(
_param
)
{
return
[];
/*if (_param == null || _param.relativeUrl == null || _param.relativeUrl == "") {
loger.warn('获取文档完整地址,传递的参数不对.', _param);
return [];
}
let port = (GlobalConfig.DOCServerPort == "" || GlobalConfig.DOCServerPort == null) ? "" : ":" + GlobalConfig.DOCServerPort;
let fullPath = GlobalConfig.DOCServerIP + port + _param.relativeUrl;
if (fullPath && fullPath.indexOf("http://") < 0) {
fullPath = "http://" + fullPath;
}
var fileType = "jpg";
switch (_param.type) {
case "jpg":
fileType = "jpg";
fullPath = this.replacePathType(fullPath) + ".jpg";
break;
case "png":
fileType = "png";
fullPath = this.replacePathType(fullPath) + ".png";
break;
default :
//不做处理,直接返回拼接的地址
break;
}
if (_param.pageNum && parseInt(_param.pageNum) > 1) {
//如果是多页的,需要返回序列
var lastIndex = fullPath.lastIndexOf("/");
if (lastIndex > 0) {
let newPath = fullPath.substr(0, lastIndex);
let pathArr = [];
//页数从1开始
for (let i = 1; i <= _param.pageNum; i++) {
pathArr.push(newPath + "/" + i + "." + fileType);
}
return pathArr;
} else {
return [fullPath];
}
} else {
return [fullPath];
}*/
}
//获取文档的pdf完整地址
getDocPDFFullPath
(
_param
)
{
return
[];
/*
if (_param == null || _param.relativeUrl == null || _param.relativeUrl == "") {
loger.warn('获取文档完整地址,传递的参数不对.', _param);
return [];
}
let port = (GlobalConfig.DOCServerPort == "" || GlobalConfig.DOCServerPort == null) ? "" : ":" + GlobalConfig.DOCServerPort;
let fullPath = GlobalConfig.DOCServerIP + port + _param.relativeUrl;
if (fullPath && fullPath.indexOf("http://") < 0) {
fullPath = "http://" + fullPath;
}
fullPath = this.replacePathType(fullPath) + ".pdf";
return [fullPath];*/
}
// 去除文件的后缀格式名称
replacePathType
(
_path
)
{
let
path
=
_path
;
path
=
path
.
replace
(
/.jpg/g
,
""
);
path
=
path
.
replace
(
/.png/g
,
""
);
path
=
path
.
replace
(
/.swf/g
,
""
);
path
=
path
.
replace
(
/.pdf/g
,
""
);
return
path
;
}
//组织完整的文档信息,包含上传时的信息和转换后的完整地址信息
_docPackFullInfo
(
_itemDataInfo
)
{
let
itemDataInfo
=
_itemDataInfo
;
let
getDocAddress
=
this
.
getDocFullAddress
(
_itemDataInfo
);
//loger.log('docPackFullInfo->', itemDataInfo);
if
(
getDocAddress
.
code
==
ApeConsts
.
RETURN_SUCCESS
)
{
itemDataInfo
.
images
=
getDocAddress
.
docFullAddress
.
images
||
[];
itemDataInfo
.
pdf
=
getDocAddress
.
docFullAddress
.
pdf
||
""
;
itemDataInfo
.
html
=
getDocAddress
.
docFullAddress
.
html
||
""
;
}
else
{
itemDataInfo
.
images
=
[];
itemDataInfo
.
pdf
=
''
;
itemDataInfo
.
html
=
''
;
}
return
itemDataInfo
;
}
//更新文档模块的录制信息,每次开启录制的时候需要把当前文档的信息更新一次
updaterRecordApeStatus
(
_param
)
{
/* if(GlobalConfig.isHost&&!GlobalConfig.isRecordPlayBack&&GlobalConfig.activeDocId>0){
loger.log("录制状态发送改变->更新当前的文档数据->docId:", GlobalConfig.activeDocId, 'page:',GlobalConfig.activeDocCurPage);
this.documentSwitchPage({
"itemIdx": GlobalConfig.activeDocId,
"curPageNo":GlobalConfig.activeDocCurPage
});
}*/
loger
.
warn
(
"录制状态发送改变->更新当前的文档数据->docId:"
,
GlobalConfig
.
activeDocId
,
'page:'
,
GlobalConfig
.
activeDocCurPage
);
this
.
documentSwitchPage
({
"itemIdx"
:
GlobalConfig
.
activeDocId
,
"curPageNo"
:
GlobalConfig
.
activeDocCurPage
});
}
//清除当前文档模块的数据
clearData
()
{
loger
.
log
(
"clearData->"
)
this
.
docList
=
{};
GlobalConfig
.
activeDocId
=
0
;
GlobalConfig
.
activeDocCurPage
=
1
;
}
//切换文档
documentSwitchDoc
(
paramInfo
)
{
loger
.
log
(
'切换文档->'
,
paramInfo
);
if
(
GlobalConfig
.
isRecordPlayBack
)
{
loger
.
warn
(
'录制回放状态不允许切换文档'
);
return
;
}
//文档翻页
documentSwitchPage
(
paramInfo
)
{
loger
.
log
(
'文档翻页->'
,
paramInfo
);
//获取已经存在的数据
let
docDataModel
=
this
.
docList
[
paramInfo
.
itemIdx
];
//console.log(docDataModelPdu);
//console.log(docDataModel);
if
(
docDataModel
==
null
)
{
loger
.
log
(
'文档翻页->文档不存在'
,
paramInfo
);
this
.
_emit
(
MessageTypes
.
MCU_ERROR
,
MessageTypes
.
ERR_APE_INTERFACE_PARAM_WRONG
);
return
;
}
//更新数据的字段
docDataModel
.
action
=
ApeConsts
.
DOC_ACTION_SWITCH_PAGE
;
docDataModel
.
curPageNo
=
parseInt
(
paramInfo
.
curPageNo
)
||
1
;
docDataModel
.
animationStep
=
1
;
//切换文档之后动画步数还原
if
(
docDataModel
.
curPageNo
<
1
)
{
docDataModel
.
curPageNo
=
1
;
//默认值最小是1
}
this
.
updaterDoc
(
docDataModel
,
docDataModel
.
itemIdx
);
}
//文档动画切换
documentSwitchAnimation
(
paramInfo
)
{
loger
.
log
(
'文档页面动画切换->'
,
paramInfo
);
//获取已经存在的数据
let
docDataModel
=
this
.
docList
[
GlobalConfig
.
activeDocId
];
if
(
docDataModel
==
null
)
{
loger
.
log
(
'文档页面动画切换->文档不存在'
,
GlobalConfig
.
activeDocId
,
paramInfo
);
this
.
_emit
(
MessageTypes
.
MCU_ERROR
,
MessageTypes
.
ERR_APE_INTERFACE_PARAM_WRONG
);
return
;
}
//更新数据的字段
docDataModel
.
action
=
ApeConsts
.
DOC_ACTION_SWITCH_ANIMATION
;
docDataModel
.
animationStep
=
docDataModel
.
animationStep
||
1
;
//最少步骤是1
if
(
paramInfo
&&
paramInfo
.
step
==-
1
){
//上一个
docDataModel
.
animationStep
--
;
}
else
{
//下一个
docDataModel
.
animationStep
++
;
}
if
(
!
docDataModel
.
animationStep
||
docDataModel
.
animationStep
<
1
)
{
docDataModel
.
animationStep
=
1
;
//默认值最小是1
}
this
.
updaterDoc
(
docDataModel
,
docDataModel
.
itemIdx
);
}
//文档切换显示模式
documentSwitchShowModel
(
paramInfo
)
{
loger
.
log
(
'文档切换显示模式'
,
paramInfo
);
//获取已经存在的数据
let
docDataModel
=
this
.
docList
[
paramInfo
.
itemIdx
];
if
(
docDataModel
==
null
)
{
loger
.
log
(
'文档切换显示模式->文档不存在'
,
paramInfo
);
this
.
_emit
(
MessageTypes
.
MCU_ERROR
,
MessageTypes
.
ERR_APE_INTERFACE_PARAM_WRONG
);
return
;
}
//更新数据的字段
docDataModel
.
action
=
ApeConsts
.
DOC_ACTION_SWITCH_PAGE
;
docDataModel
.
curPageNo
=
parseInt
(
paramInfo
.
curPageNo
)
||
1
;
if
(
docDataModel
.
curPageNo
<
1
)
{
docDataModel
.
curPageNo
=
1
;
//默认值最小是1
}
this
.
updaterDoc
(
docDataModel
,
docDataModel
.
itemIdx
);
if
(
paramInfo
==
null
||
paramInfo
.
itemIdx
==
null
)
{
loger
.
warn
(
'切换文档失败,参数错误'
,
paramInfo
);
this
.
_emit
(
MessageTypes
.
MCU_ERROR
,
MessageTypes
.
ERR_APE_INTERFACE_PARAM_WRONG
);
return
;
}
//缩放/滚动/显示模式
documentCommand
(
paramInfo
)
{
//获取已经存在的数据
let
docDataModel
=
this
.
docList
[
paramInfo
.
itemIdx
];
if
(
docDataModel
==
null
)
{
loger
.
log
(
'文档显示控制失败->文档不存在'
,
paramInfo
);
this
.
_emit
(
MessageTypes
.
MCU_ERROR
,
MessageTypes
.
ERR_APE_INTERFACE_PARAM_WRONG
);
return
;
}
//更新数据的字段
docDataModel
.
action
=
ApeConsts
.
DOC_ACTION_COMMAND
;
docDataModel
.
showType
=
parseInt
(
paramInfo
.
showType
)
||
0
;
//0;//完整显示;1;//按宽度显示;2;//按高度显示
docDataModel
.
curV
=
parseInt
(
paramInfo
.
curV
)
||
0
;
//垂直方向的滚动条进度百分比 0-100
docDataModel
.
curH
=
parseInt
(
paramInfo
.
curH
)
||
0
;
//水平方向的滚动条进度百分比 0-100
docDataModel
.
scale
=
parseInt
(
paramInfo
.
scale
)
||
100
;
//文档缩放百分比 0-100
this
.
updaterDoc
(
docDataModel
,
docDataModel
.
itemIdx
);
}
//删除所有文档
documentDeleteAll
(
_param
)
{
for
(
let
key
in
this
.
docList
)
{
//console.log("key:"+key);
loger
.
log
(
"删除文档数据->itemIdx:"
+
key
);
this
.
documentDelete
({
"itemIdx"
:
key
});
}
if
(
paramInfo
.
itemIdx
==
GlobalConfig
.
activeDocId
&&
GlobalConfig
.
activeDocId
!=
0
)
{
loger
.
warn
(
'文档已经显示'
,
paramInfo
.
itemIdx
,
GlobalConfig
.
activeDocId
);
return
;
}
//删除文档
documentDelete
(
paramInfo
)
{
//{"itemIdx":itemIdx}
let
tableDeleteItemPdu
=
new
pdu
[
'RCRegistryTableDeleteItemPdu'
];
//optional RCPduType_E type = 1 [default = RCPDU_REG_TABLE_DELETE_PDU];
// repeated uint32 item_idx = 2;
tableDeleteItemPdu
.
type
=
pdu
.
RCPDU_REG_TABLE_DELETE_PDU
;
//
tableDeleteItemPdu
.
itemIdx
=
parseInt
(
paramInfo
.
itemIdx
);
//这里需要设置要删除的数据的itemIdx,每条数据的这个id都不一样
//更新切换之前的文档的数据,要显示当前切换的文档,上一个文档需要隐藏
let
oldDocModel
;
if
(
GlobalConfig
.
activeDocId
!=
0
)
{
oldDocModel
=
this
.
docList
[
GlobalConfig
.
activeDocId
];
if
(
oldDocModel
)
{
oldDocModel
.
action
=
ApeConsts
.
DOC_ACTION_NORMAL
;
oldDocModel
.
visible
=
false
;
//设置为不可见
oldDocModel
.
animationStep
=
1
;
//切换文档之后动画步数还原
}
}
let
updateObjPdu
=
new
pdu
[
'RCRegistryUpdateObjPdu'
];
updateObjPdu
.
objId
=
ApeConsts
.
DOCSHARING_OBJ_TABLE_ID
;
// updateObjPdu.objId = ApeConsts.DOCSHARING_OBJ_TABLE_ID_H5;
updateObjPdu
.
subType
=
tableDeleteItemPdu
.
type
;
updateObjPdu
.
userData
=
tableDeleteItemPdu
.
toArrayBuffer
();
//获取已经存在的数据
let
docDataModel
=
this
.
docList
[
paramInfo
.
itemIdx
];
if
(
docDataModel
==
null
)
{
loger
.
warn
(
'切换文档失败,文档不存在'
,
paramInfo
);
this
.
_emit
(
MessageTypes
.
MCU_ERROR
,
MessageTypes
.
ERR_APE_INTERFACE_PARAM_WRONG
);
return
;
}
//同步
let
adapterItemPdu
=
new
pdu
[
'RCAdapterItemPdu'
];
adapterItemPdu
.
type
=
pdu
.
RCPDU_REG_UPDATE_OBJ
;
adapterItemPdu
.
itemData
=
updateObjPdu
.
toArrayBuffer
();
//更新当前选择的文档数据的字段
docDataModel
.
action
=
ApeConsts
.
DOC_ACTION_SWITCH_DOC
;
docDataModel
.
visible
=
paramInfo
.
visible
||
false
;
//默认是false
docDataModel
.
animationStep
=
1
;
//切换文档之后动画步数还原
let
adapterPdu
=
new
pdu
[
'RCAdapterPdu'
];
adapterPdu
.
type
=
pdu
.
RCPDU_REG_ADAPTER
;
adapterPdu
.
item
.
push
(
adapterItemPdu
);
//loger.log('切换文档,当前文档和上一个显示的文档都需要更新状态');
loger
.
log
({
"oldDoc"
:
oldDocModel
,
"nowDoc"
:
docDataModel
});
//更新当前选择的文档
this
.
updaterDoc
(
docDataModel
,
docDataModel
.
itemIdx
);
loger
.
log
(
"文档发送删除数据=============>"
+
tableDeleteItemPdu
.
itemIdx
);
this
.
sendUniform
(
adapterPdu
,
true
);
//更新上一个文档 隐藏
if
(
oldDocModel
)
{
this
.
updaterDoc
(
oldDocModel
,
oldDocModel
.
itemIdx
);
}
/////收到消息处理/////////////////////////////////////////////////////////////////////////////////
tableInsertHandler
(
owner
,
itemIdx
,
itemData
)
{
/* let itemDataInfo = this.unPackPdu(owner, itemIdx, itemData);
this.docList[itemIdx] = itemDataInfo;
if (itemDataInfo.visible == "true" || itemDataInfo.visible == true) {
}
//文档翻页
documentSwitchPage
(
paramInfo
)
{
loger
.
log
(
'文档翻页->'
,
paramInfo
);
//获取已经存在的数据
let
docDataModel
=
this
.
docList
[
paramInfo
.
itemIdx
];
//console.log(docDataModelPdu);
//console.log(docDataModel);
if
(
docDataModel
==
null
)
{
loger
.
log
(
'文档翻页->文档不存在'
,
paramInfo
);
this
.
_emit
(
MessageTypes
.
MCU_ERROR
,
MessageTypes
.
ERR_APE_INTERFACE_PARAM_WRONG
);
return
;
}
//更新数据的字段
docDataModel
.
action
=
ApeConsts
.
DOC_ACTION_SWITCH_PAGE
;
docDataModel
.
curPageNo
=
parseInt
(
paramInfo
.
curPageNo
)
||
1
;
docDataModel
.
animationStep
=
1
;
//切换文档之后动画步数还原
if
(
docDataModel
.
curPageNo
<
1
)
{
docDataModel
.
curPageNo
=
1
;
//默认值最小是1
}
this
.
updaterDoc
(
docDataModel
,
docDataModel
.
itemIdx
);
}
//文档动画切换
documentSwitchAnimation
(
paramInfo
)
{
loger
.
log
(
'文档页面动画切换->'
,
paramInfo
);
//获取已经存在的数据
let
docDataModel
=
this
.
docList
[
GlobalConfig
.
activeDocId
];
if
(
docDataModel
==
null
)
{
loger
.
log
(
'文档页面动画切换->文档不存在'
,
GlobalConfig
.
activeDocId
,
paramInfo
);
this
.
_emit
(
MessageTypes
.
MCU_ERROR
,
MessageTypes
.
ERR_APE_INTERFACE_PARAM_WRONG
);
return
;
}
//更新数据的字段
docDataModel
.
action
=
ApeConsts
.
DOC_ACTION_SWITCH_ANIMATION
;
docDataModel
.
animationStep
=
docDataModel
.
animationStep
||
1
;
//最少步骤是1
if
(
paramInfo
&&
paramInfo
.
step
==
-
1
)
{
//上一个
docDataModel
.
animationStep
--
;
}
else
{
//下一个
docDataModel
.
animationStep
++
;
}
if
(
!
docDataModel
.
animationStep
||
docDataModel
.
animationStep
<
1
)
{
docDataModel
.
animationStep
=
1
;
//默认值最小是1
}
this
.
updaterDoc
(
docDataModel
,
docDataModel
.
itemIdx
);
}
//文档切换显示模式
documentSwitchShowModel
(
paramInfo
)
{
loger
.
log
(
'文档切换显示模式'
,
paramInfo
);
//获取已经存在的数据
let
docDataModel
=
this
.
docList
[
paramInfo
.
itemIdx
];
if
(
docDataModel
==
null
)
{
loger
.
log
(
'文档切换显示模式->文档不存在'
,
paramInfo
);
this
.
_emit
(
MessageTypes
.
MCU_ERROR
,
MessageTypes
.
ERR_APE_INTERFACE_PARAM_WRONG
);
return
;
}
//更新数据的字段
docDataModel
.
action
=
ApeConsts
.
DOC_ACTION_SWITCH_PAGE
;
docDataModel
.
curPageNo
=
parseInt
(
paramInfo
.
curPageNo
)
||
1
;
if
(
docDataModel
.
curPageNo
<
1
)
{
docDataModel
.
curPageNo
=
1
;
//默认值最小是1
}
this
.
updaterDoc
(
docDataModel
,
docDataModel
.
itemIdx
);
}
//缩放/滚动/显示模式
documentCommand
(
paramInfo
)
{
//获取已经存在的数据
let
docDataModel
=
this
.
docList
[
paramInfo
.
itemIdx
];
if
(
docDataModel
==
null
)
{
loger
.
log
(
'文档显示控制失败->文档不存在'
,
paramInfo
);
this
.
_emit
(
MessageTypes
.
MCU_ERROR
,
MessageTypes
.
ERR_APE_INTERFACE_PARAM_WRONG
);
return
;
}
//更新数据的字段
docDataModel
.
action
=
ApeConsts
.
DOC_ACTION_COMMAND
;
docDataModel
.
showType
=
parseInt
(
paramInfo
.
showType
)
||
0
;
//0;//完整显示;1;//按宽度显示;2;//按高度显示
docDataModel
.
curV
=
parseInt
(
paramInfo
.
curV
)
||
0
;
//垂直方向的滚动条进度百分比 0-100
docDataModel
.
curH
=
parseInt
(
paramInfo
.
curH
)
||
0
;
//水平方向的滚动条进度百分比 0-100
docDataModel
.
scale
=
parseInt
(
paramInfo
.
scale
)
||
100
;
//文档缩放百分比 0-100
this
.
updaterDoc
(
docDataModel
,
docDataModel
.
itemIdx
);
}
//删除所有文档
documentDeleteAll
(
_param
)
{
for
(
let
key
in
this
.
docList
)
{
//console.log("key:"+key);
loger
.
log
(
"删除文档数据->itemIdx:"
+
key
);
this
.
documentDelete
({
"itemIdx"
:
key
});
}
}
//删除文档
documentDelete
(
paramInfo
)
{
//{"itemIdx":itemIdx}
let
tableDeleteItemPdu
=
new
pdu
[
'RCRegistryTableDeleteItemPdu'
];
//optional RCPduType_E type = 1 [default = RCPDU_REG_TABLE_DELETE_PDU];
// repeated uint32 item_idx = 2;
tableDeleteItemPdu
.
type
=
pdu
.
RCPDU_REG_TABLE_DELETE_PDU
;
//
tableDeleteItemPdu
.
itemIdx
=
parseInt
(
paramInfo
.
itemIdx
);
//这里需要设置要删除的数据的itemIdx,每条数据的这个id都不一样
let
updateObjPdu
=
new
pdu
[
'RCRegistryUpdateObjPdu'
];
updateObjPdu
.
objId
=
ApeConsts
.
DOCSHARING_OBJ_TABLE_ID
;
// updateObjPdu.objId = ApeConsts.DOCSHARING_OBJ_TABLE_ID_H5;
updateObjPdu
.
subType
=
tableDeleteItemPdu
.
type
;
updateObjPdu
.
userData
=
tableDeleteItemPdu
.
toArrayBuffer
();
//同步
let
adapterItemPdu
=
new
pdu
[
'RCAdapterItemPdu'
];
adapterItemPdu
.
type
=
pdu
.
RCPDU_REG_UPDATE_OBJ
;
adapterItemPdu
.
itemData
=
updateObjPdu
.
toArrayBuffer
();
let
adapterPdu
=
new
pdu
[
'RCAdapterPdu'
];
adapterPdu
.
type
=
pdu
.
RCPDU_REG_ADAPTER
;
adapterPdu
.
item
.
push
(
adapterItemPdu
);
loger
.
log
(
"文档发送删除数据=============>"
+
tableDeleteItemPdu
.
itemIdx
);
this
.
sendUniform
(
adapterPdu
,
true
);
}
/////收到消息处理/////////////////////////////////////////////////////////////////////////////////
tableInsertHandler
(
owner
,
itemIdx
,
itemData
)
{
/* let itemDataInfo = this.unPackPdu(owner, itemIdx, itemData);
this.docList[itemIdx] = itemDataInfo;
if (itemDataInfo.visible == "true" || itemDataInfo.visible == true) {
GlobalConfig.activeDocId = itemDataInfo.itemIdx;//当前激活的文档ID
GlobalConfig.activeDocCurPage = itemDataInfo.curPageNo;//当前激活的文档的当前页
loger.log('tableInsertHandler 设置当前激活的文档id');
}
loger.log('tableInsertHandler->', itemDataInfo);
this._emit(MessageTypes.DOC_UPDATE, itemDataInfo);//用添加和更新都统一DOC_UPDATE
//文档数据更新完毕,如果当前没有显示的文档,默认选择一个显示
if (GlobalConfig.activeDocId < 1 && itemDataInfo) {
let paramInfo = {
"itemIdx": itemDataInfo.itemIdx,
"visible": true
};
this.documentSwitchDoc(paramInfo);
}*/
}
//添加文档
tableInsertApeHandler
(
_tableUpdateItems
,
_seekTime
)
{
let
tableInsertItems
=
_tableUpdateItems
;
let
tableInsertItemsLen
=
tableInsertItems
.
length
;
loger
.
log
(
'添加文档->'
,
"activeDocId->"
,
GlobalConfig
.
activeDocId
,
"tableUpdateItemsLen->"
,
tableInsertItemsLen
);
for
(
let
i
=
0
;
i
<
tableInsertItemsLen
;
++
i
)
{
let
insertItem
=
tableInsertItems
[
i
];
if
(
insertItem
)
{
//this.tableInsertHandler(insertItem.owner, insertItem.itemIdx, insertItem.itemData);
let
itemDataInfo
=
this
.
unPackPdu
(
insertItem
.
owner
,
insertItem
.
itemIdx
,
insertItem
.
itemData
);
if
(
itemDataInfo
)
{
this
.
docList
[
insertItem
.
itemIdx
]
=
itemDataInfo
;
if
(
itemDataInfo
.
visible
==
"true"
||
itemDataInfo
.
visible
==
true
)
{
GlobalConfig
.
activeDocId
=
itemDataInfo
.
itemIdx
;
//当前激活的文档ID
GlobalConfig
.
activeDocCurPage
=
itemDataInfo
.
curPageNo
;
//当前激活的文档的当前页
loger.log('tableInsertHandler 设置当前激活的文档id');
}
loger.log('tableInsertHandler->', itemDataInfo);
this._emit(MessageTypes.DOC_UPDATE, itemDataInfo);//用添加和更新都统一DOC_UPDATE
//文档数据更新完毕,如果当前没有显示的文档,默认选择一个显示
if (GlobalConfig.activeDocId < 1 && itemDataInfo) {
let paramInfo = {
"itemIdx": itemDataInfo.itemIdx,
"visible": true
};
this.documentSwitchDoc(paramInfo);
}*/
}
//添加文档
tableInsertApeHandler
(
_tableUpdateItems
,
_seekTime
)
{
let
tableInsertItems
=
_tableUpdateItems
;
let
tableInsertItemsLen
=
tableInsertItems
.
length
;
loger
.
log
(
'添加文档->'
,
"activeDocId->"
,
GlobalConfig
.
activeDocId
,
"tableUpdateItemsLen->"
,
tableInsertItemsLen
);
for
(
let
i
=
0
;
i
<
tableInsertItemsLen
;
++
i
)
{
let
insertItem
=
tableInsertItems
[
i
];
if
(
insertItem
){
//this.tableInsertHandler(insertItem.owner, insertItem.itemIdx, insertItem.itemData);
let
itemDataInfo
=
this
.
unPackPdu
(
insertItem
.
owner
,
insertItem
.
itemIdx
,
insertItem
.
itemData
);
if
(
itemDataInfo
){
this
.
docList
[
insertItem
.
itemIdx
]
=
itemDataInfo
;
if
(
itemDataInfo
.
visible
==
"true"
||
itemDataInfo
.
visible
==
true
)
{
GlobalConfig
.
activeDocId
=
itemDataInfo
.
itemIdx
;
//当前激活的文档ID
GlobalConfig
.
activeDocCurPage
=
itemDataInfo
.
curPageNo
;
//当前激活的文档的当前页
//loger.log('添加文档->设置当前激活的文档id');
}
let
getdocPackFullInfo
=
this
.
_docPackFullInfo
(
itemDataInfo
);
loger
.
log
(
'添加文档->'
,
getdocPackFullInfo
);
this
.
_emit
(
MessageTypes
.
DOC_UPDATE
,
getdocPackFullInfo
);
//用添加和更新都统一DOC_UPDATE
}
else
{
loger
.
warn
(
'文档数据解析失败->删除->itemIdx:'
+
insertItem
.
itemIdx
);
this
.
documentDelete
({
"itemIdx"
:
insertItem
.
itemIdx
});
}
//loger.log('添加文档->设置当前激活的文档id');
}
let
getdocPackFullInfo
=
this
.
_docPackFullInfo
(
itemDataInfo
);
loger
.
log
(
'添加文档->'
,
getdocPackFullInfo
);
this
.
_emit
(
MessageTypes
.
DOC_UPDATE
,
getdocPackFullInfo
);
//用添加和更新都统一DOC_UPDATE
}
else
{
loger
.
warn
(
'文档数据解析失败->删除->itemIdx:'
+
insertItem
.
itemIdx
);
this
.
documentDelete
({
"itemIdx"
:
insertItem
.
itemIdx
});
}
//文档数据更新完毕,如果当前没有显示的文档,默认选择一个显示
this
.
_showDefaultDoc
();
}
tableDeleteHandler
(
object_id
,
tableDeleteData
)
{
loger
.
log
(
'删除文档数据->'
,
object_id
,
tableDeleteData
);
//["tableDeleteHandler",1179649,{"type":231,"itemIdx":[1486301768]}]
if
(
tableDeleteData
&&
tableDeleteData
.
itemIdx
)
{
let
len
=
tableDeleteData
.
itemIdx
.
length
;
let
itemIdxs
=
tableDeleteData
.
itemIdx
;
for
(
let
i
=
0
;
i
<
len
;
i
++
)
{
if
(
this
.
docList
[
itemIdxs
[
i
]])
{
loger
.
log
(
"删除文档数据:"
,
itemIdxs
[
i
]);
//this._emit(MessageTypes.DOC_DELETE, {"itemIdx": itemIdxs[i]});
let
itemDataInfo
=
this
.
docList
[
itemIdxs
[
i
]];
if
(
itemDataInfo
&&
(
itemDataInfo
.
visible
==
"true"
||
itemDataInfo
.
visible
==
true
))
{
GlobalConfig
.
activeDocId
=
0
;
//当前激活的文档ID
GlobalConfig
.
activeDocCurPage
=
1
;
//当前激活的文档的当前页
loger
.
log
(
'删除文档数据->清除当前显示的文档'
);
}
this
.
_emit
(
MessageTypes
.
DOC_DELETE
,
{
"itemIdx"
:
itemIdxs
[
i
]});
delete
this
.
docList
[
itemIdxs
[
i
]];
}
}
}
}
}
tableUpdateHandler
(
owner
,
itemIdx
,
itemData
)
{
//这个方法废弃,更新用tableUpdateApeHandler方法
/* let itemDataInfo = this.unPackPdu(owner, itemIdx, itemData);
if(itemDataInfo!=null){
this.docList[itemIdx] = itemDataInfo;
if(itemDataInfo&&(itemDataInfo.visible=="true"||itemDataInfo.visible==true)){
GlobalConfig.activeDocId=itemDataInfo.itemIdx;//当前激活的文档ID
GlobalConfig.activeDocCurPage=itemDataInfo.curPageNo;//当前激活的文档的当前页
loger.log('tableUpdateHandler 设置当前激活的文档id');
}
loger.log('tableUpdateHandler 发送给客户端');
loger.log(itemDataInfo);
this._emit(MessageTypes.DOC_UPDATE,itemDataInfo);
}else {
loger.log('tableUpdateHandler 数据无效--> itemIdx',itemIdx);
}*/
}
tableUpdateApeHandler
(
_tableUpdateItems
,
_seekTime
)
{
let
tableUpdateItemsLen
=
_tableUpdateItems
.
length
;
//loger.log('更新文档->', "activeDocId->", GlobalConfig.activeDocId, "更新的数量->", tableUpdateItemsLen);
for
(
let
i
=
0
;
i
<
tableUpdateItemsLen
;
++
i
)
{
let
tableItem
=
_tableUpdateItems
[
i
];
if
(
tableItem
)
{
let
itemDataInfo
=
this
.
unPackPdu
(
tableItem
.
owner
,
tableItem
.
itemIdx
,
tableItem
.
itemData
);
if
(
itemDataInfo
)
{
this
.
docList
[
tableItem
.
itemIdx
]
=
itemDataInfo
;
if
(
itemDataInfo
&&
(
itemDataInfo
.
visible
==
"true"
||
itemDataInfo
.
visible
==
true
))
{
GlobalConfig
.
activeDocId
=
itemDataInfo
.
itemIdx
;
//当前激活的文档ID
GlobalConfig
.
activeDocCurPage
=
itemDataInfo
.
curPageNo
;
//当前激活的文档的当前页
loger
.
log
(
'更新文档->设置当前激活的文档id->'
,
GlobalConfig
.
activeDocId
,
"curPageNum->"
,
GlobalConfig
.
activeDocCurPage
);
}
let
getdocPackFullInfo
=
this
.
_docPackFullInfo
(
itemDataInfo
);
this
.
_emit
(
MessageTypes
.
DOC_UPDATE
,
getdocPackFullInfo
);
}
else
{
loger
.
warn
(
'文档数据解析失败->删除->itemIdx:'
+
tableItem
.
itemIdx
);
this
.
documentDelete
({
"itemIdx"
:
tableItem
.
itemIdx
});
}
//文档数据更新完毕,如果当前没有显示的文档,默认选择一个显示
this
.
_showDefaultDoc
();
}
tableDeleteHandler
(
object_id
,
tableDeleteData
)
{
loger
.
log
(
'删除文档数据->'
,
object_id
,
tableDeleteData
);
//["tableDeleteHandler",1179649,{"type":231,"itemIdx":[1486301768]}]
if
(
tableDeleteData
&&
tableDeleteData
.
itemIdx
)
{
let
len
=
tableDeleteData
.
itemIdx
.
length
;
let
itemIdxs
=
tableDeleteData
.
itemIdx
;
for
(
let
i
=
0
;
i
<
len
;
i
++
)
{
if
(
this
.
docList
[
itemIdxs
[
i
]])
{
loger
.
log
(
"删除文档数据:"
,
itemIdxs
[
i
]);
//this._emit(MessageTypes.DOC_DELETE, {"itemIdx": itemIdxs[i]});
let
itemDataInfo
=
this
.
docList
[
itemIdxs
[
i
]];
if
(
itemDataInfo
&&
(
itemDataInfo
.
visible
==
"true"
||
itemDataInfo
.
visible
==
true
))
{
GlobalConfig
.
activeDocId
=
0
;
//当前激活的文档ID
GlobalConfig
.
activeDocCurPage
=
1
;
//当前激活的文档的当前页
loger
.
log
(
'删除文档数据->清除当前显示的文档'
);
}
this
.
_emit
(
MessageTypes
.
DOC_DELETE
,
{
"itemIdx"
:
itemIdxs
[
i
]});
delete
this
.
docList
[
itemIdxs
[
i
]];
}
this
.
_showDefaultDoc
();
}
}
//果当前没有显示的文档,默认选择一个显示文档
_showDefaultDoc
()
{
/*//显示默认文档条件->1.非录制回放状态下 2.只有host有权限操作 3.当前激活的文档id不为0
if (GlobalConfig.isRecordPlayBack || !GlobalConfig.isHost || GlobalConfig.activeDocId > 0) {
return;
}
tableUpdateHandler
(
owner
,
itemIdx
,
itemData
)
{
//这个方法废弃,更新用tableUpdateApeHandler方法
/* let itemDataInfo = this.unPackPdu(owner, itemIdx, itemData);
if(itemDataInfo!=null){
this.docList[itemIdx] = itemDataInfo;
if(itemDataInfo&&(itemDataInfo.visible=="true"||itemDataInfo.visible==true)){
GlobalConfig.activeDocId=itemDataInfo.itemIdx;//当前激活的文档ID
GlobalConfig.activeDocCurPage=itemDataInfo.curPageNo;//当前激活的文档的当前页
loger.log('tableUpdateHandler 设置当前激活的文档id');
}
loger.log('tableUpdateHandler 发送给客户端');
loger.log(itemDataInfo);
this._emit(MessageTypes.DOC_UPDATE,itemDataInfo);
}else {
loger.log('tableUpdateHandler 数据无效--> itemIdx',itemIdx);
}*/
}
tableUpdateApeHandler
(
_tableUpdateItems
,
_seekTime
)
{
let
tableUpdateItemsLen
=
_tableUpdateItems
.
length
;
//loger.log('更新文档->', "activeDocId->", GlobalConfig.activeDocId, "更新的数量->", tableUpdateItemsLen);
for
(
let
i
=
0
;
i
<
tableUpdateItemsLen
;
++
i
)
{
let
tableItem
=
_tableUpdateItems
[
i
];
if
(
tableItem
)
{
let
itemDataInfo
=
this
.
unPackPdu
(
tableItem
.
owner
,
tableItem
.
itemIdx
,
tableItem
.
itemData
);
if
(
itemDataInfo
)
{
this
.
docList
[
tableItem
.
itemIdx
]
=
itemDataInfo
;
if
(
itemDataInfo
&&
(
itemDataInfo
.
visible
==
"true"
||
itemDataInfo
.
visible
==
true
))
{
GlobalConfig
.
activeDocId
=
itemDataInfo
.
itemIdx
;
//当前激活的文档ID
GlobalConfig
.
activeDocCurPage
=
itemDataInfo
.
curPageNo
;
//当前激活的文档的当前页
loger
.
log
(
'更新文档->设置当前激活的文档id->'
,
GlobalConfig
.
activeDocId
,
"curPageNum->"
,
GlobalConfig
.
activeDocCurPage
);
}
let
getdocPackFullInfo
=
this
.
_docPackFullInfo
(
itemDataInfo
);
this
.
_emit
(
MessageTypes
.
DOC_UPDATE
,
getdocPackFullInfo
);
}
else
{
loger
.
warn
(
'文档数据解析失败->删除->itemIdx:'
+
tableItem
.
itemIdx
);
this
.
documentDelete
({
"itemIdx"
:
tableItem
.
itemIdx
});
}
*/
//非录制回放状态下和当前激活的文档id不为0的时候也不能操作
if
(
GlobalConfig
.
isRecordPlayBack
||
GlobalConfig
.
activeDocId
>
0
)
{
return
;
}
//如果自己不是老师,并且当前课堂内人数大于1,不能操作
if
(
!
GlobalConfig
.
isHost
&&
GlobalConfig
.
rosterNumber
>
1
){
}
this
.
_showDefaultDoc
();
}
//果当前没有显示的文档,默认选择一个显示文档
_showDefaultDoc
()
{
/*//显示默认文档条件->1.非录制回放状态下 2.只有host有权限操作 3.当前激活的文档id不为0
if (GlobalConfig.isRecordPlayBack || !GlobalConfig.isHost || GlobalConfig.activeDocId > 0) {
return;
}
*/
//非录制回放状态下和当前激活的文档id不为0的时候也不能操作
if
(
GlobalConfig
.
isRecordPlayBack
||
GlobalConfig
.
activeDocId
>
0
)
{
return
;
}
//如果自己不是老师,并且当前课堂内人数大于1,不能操作
if
(
!
GlobalConfig
.
isHost
&&
GlobalConfig
.
rosterNumber
>
1
)
{
return
;
}
let
tempDocItemIdx
;
//临时记录文档数据,用于显示默认文档
for
(
let
key
in
this
.
docList
)
{
tempDocItemIdx
=
this
.
docList
[
key
];
if
(
tempDocItemIdx
)
{
loger
.
log
(
"选择一个文档作为默认文档显示->"
,
tempDocItemIdx
);
let
paramInfo
=
{
"itemIdx"
:
tempDocItemIdx
.
itemIdx
,
"visible"
:
true
};
this
.
documentSwitchDoc
(
paramInfo
);
//选择完成就跳出循环
return
;
}
let
tempDocItemIdx
;
//临时记录文档数据,用于显示默认文档
for
(
let
key
in
this
.
docList
)
{
tempDocItemIdx
=
this
.
docList
[
key
];
if
(
tempDocItemIdx
)
{
loger
.
log
(
"选择一个文档作为默认文档显示->"
,
tempDocItemIdx
);
let
paramInfo
=
{
"itemIdx"
:
tempDocItemIdx
.
itemIdx
,
"visible"
:
true
};
this
.
documentSwitchDoc
(
paramInfo
);
//选择完成就跳出循环
return
;
}
}
}
onJoinChannelHandlerSuccess
()
{
loger
.
log
(
this
.
_session_name
+
' onJoinChannelHandlerSuccess==========================='
);
if
(
this
.
_apeDelayed
)
{
// this._apeDelayedMsgs.push(regBuffer);
// this._apeDelayedStart();
setTimeout
(()
=>
{
this
.
_emit
(
DocApe
.
DOC_JOIN_CHANNEL_SUCCESS
);
},
(
GlobalConfig
.
mcuDelay
+
GlobalConfig
.
docDelay
)
||
12000
+
GlobalConfig
.
docDelay
);
}
else
{
setTimeout
(()
=>
{
this
.
_emit
(
DocApe
.
DOC_JOIN_CHANNEL_SUCCESS
);
},
GlobalConfig
.
docDelay
);
}
}
onJoinChannelHandlerSuccess
()
{
loger
.
log
(
this
.
_session_name
+
' onJoinChannelHandlerSuccess==========================='
);
if
(
this
.
_apeDelayed
)
{
// this._apeDelayedMsgs.push(regBuffer);
// this._apeDelayedStart();
setTimeout
(()
=>
{
this
.
_emit
(
DocApe
.
DOC_JOIN_CHANNEL_SUCCESS
);
},
(
GlobalConfig
.
mcuDelay
+
GlobalConfig
.
docDelay
)
||
12000
+
GlobalConfig
.
docDelay
);
}
else
{
setTimeout
(()
=>
{
this
.
_emit
(
DocApe
.
DOC_JOIN_CHANNEL_SUCCESS
);
},
GlobalConfig
.
docDelay
);
}
}
//检查文档是否已经存在,如果存在 返回true,否则返回false
checkDocId
(
_docId
)
{
if
(
_docId
==
null
)
{
loger
.
warn
(
'查找文档->失败->参数为null'
);
return
true
;
}
//遍历查找
for
(
let
key
in
this
.
docList
)
{
let
item
=
this
.
docList
[
key
];
if
(
item
&&
item
.
docId
==
_docId
)
{
//loger.log('查找文档->已经存在->',_docId);
return
true
;
}
}
loger
.
log
(
'查找文档->没有查找到文档->'
,
_docId
);
//储存的数据中没有查找到
return
false
;
}
///////数据的封包和解包/////////////////////////////////////////
packPdu
(
_param
,
_itemIdx
)
{
//loger.log("文档->packPdu");
//验证坐标点集合数组是否合法
if
(
_param
==
null
||
_itemIdx
==
null
)
{
this
.
_emit
(
MessageTypes
.
MCU_ERROR
,
MessageTypes
.
ERR_APE_INTERFACE_PARAM_WRONG
);
return
null
;
}
//判断type类型,根据type设置不同的参数
let
docModelPdu
=
new
pdu
[
'RCDocSendDataModelPdu'
];
docModelPdu
.
itemIdx
=
_itemIdx
;
docModelPdu
.
owner
=
GlobalConfig
.
nodeId
;
docModelPdu
.
from
=
GlobalConfig
.
nodeId
;
docModelPdu
.
curPageNo
=
_param
.
curPageNo
||
1
;
docModelPdu
.
pageNum
=
_param
.
pageNum
||
1
;
docModelPdu
.
fileType
=
_param
.
fileType
||
""
;
docModelPdu
.
creatUserId
=
_param
.
creatUserId
||
"0"
;
docModelPdu
.
url
=
_param
.
url
||
""
;
//这个地址没用到,数据太长占用资源 暂停使用//"http://101.200.150.192/DocSharing/data/h5test/20170206-171100025/7e9c4178cac1133e0dd9d5b583439122.jpg";
docModelPdu
.
relativeUrl
=
_param
.
relativeUrl
||
""
;
//"/DocSharing/data/h5test/20170206-171100025/7e9c4178cac1133e0dd9d5b583439122.jpg";
docModelPdu
.
curV
=
parseInt
(
_param
.
curV
)
||
0
;
docModelPdu
.
curH
=
parseInt
(
_param
.
curH
)
||
0
;
docModelPdu
.
scale
=
_param
.
scale
||
100
;
//按百分比
docModelPdu
.
visible
=
_param
.
visible
||
false
;
docModelPdu
.
action
=
_param
.
action
||
ApeConsts
.
DOC_ACTION_NORMAL
;
//0,无操作, 1翻页、2.显示/隐藏, 3缩放/滚动
docModelPdu
.
docId
=
_param
.
docId
||
""
;
//文档在服务器数据库中的唯一id,必须有
docModelPdu
.
md5
=
_param
.
md5
||
""
;
//MD5
docModelPdu
.
fileName
=
_param
.
fileName
||
"doc_"
+
_itemIdx
;
//文档的名字
docModelPdu
.
dynamicTS
=
_param
.
dynamicTS
||
"0"
;
//文档上传后返回值中的字段dynamicTransferStatic
docModelPdu
.
showType
=
_param
.
showType
||
0
;
//文档显示模式
docModelPdu
.
animationStep
=
_param
.
animationStep
||
1
;
//当前页面上的动画步数(动态ppt时有这个字段)
//loger.log(docModelPdu);
return
docModelPdu
;
}
unPackPdu
(
owner
,
itemIdx
,
itemData
)
{
if
(
owner
==
null
||
itemIdx
==
null
||
itemData
==
null
)
{
this
.
_emit
(
MessageTypes
.
MCU_ERROR
,
MessageTypes
.
ERR_APE_INTERFACE_PARAM_WRONG
);
return
null
;
}
try
{
let
docModelPdu
=
pdu
[
'RCDocSendDataModelPdu'
].
decode
(
itemData
);
//loger.log("文档===>unPackPdu");
return
docModelPdu
;
}
catch
(
err
)
{
loger
.
log
(
"文档===>unPackPdu->Pdu解析错误->itemIdx="
+
itemIdx
+
"->err:"
+
err
.
message
);
}
return
null
;
//检查文档是否已经存在,如果存在 返回true,否则返回false
checkDocId
(
_docId
)
{
if
(
_docId
==
null
)
{
loger
.
warn
(
'查找文档->失败->参数为null'
);
return
true
;
}
//遍历查找
for
(
let
key
in
this
.
docList
)
{
let
item
=
this
.
docList
[
key
];
if
(
item
&&
item
.
docId
==
_docId
)
{
//loger.log('查找文档->已经存在->',_docId);
return
true
;
}
}
loger
.
log
(
'查找文档->没有查找到文档->'
,
_docId
);
//储存的数据中没有查找到
return
false
;
}
///////数据的封包和解包/////////////////////////////////////////
packPdu
(
_param
,
_itemIdx
)
{
//loger.log("文档->packPdu");
//验证坐标点集合数组是否合法
if
(
_param
==
null
||
_itemIdx
==
null
)
{
this
.
_emit
(
MessageTypes
.
MCU_ERROR
,
MessageTypes
.
ERR_APE_INTERFACE_PARAM_WRONG
);
return
null
;
}
//判断type类型,根据type设置不同的参数
let
docModelPdu
=
new
pdu
[
'RCDocSendDataModelPdu'
];
docModelPdu
.
itemIdx
=
_itemIdx
;
docModelPdu
.
owner
=
GlobalConfig
.
nodeId
;
docModelPdu
.
from
=
GlobalConfig
.
nodeId
;
docModelPdu
.
curPageNo
=
_param
.
curPageNo
||
1
;
docModelPdu
.
pageNum
=
_param
.
pageNum
||
1
;
docModelPdu
.
fileType
=
_param
.
fileType
||
""
;
docModelPdu
.
creatUserId
=
_param
.
creatUserId
||
"0"
;
docModelPdu
.
url
=
_param
.
url
||
""
;
//这个地址没用到,数据太长占用资源 暂停使用//"http://101.200.150.192/DocSharing/data/h5test/20170206-171100025/7e9c4178cac1133e0dd9d5b583439122.jpg";
docModelPdu
.
relativeUrl
=
_param
.
relativeUrl
||
""
;
//"/DocSharing/data/h5test/20170206-171100025/7e9c4178cac1133e0dd9d5b583439122.jpg";
docModelPdu
.
curV
=
parseInt
(
_param
.
curV
)
||
0
;
docModelPdu
.
curH
=
parseInt
(
_param
.
curH
)
||
0
;
docModelPdu
.
scale
=
_param
.
scale
||
100
;
//按百分比
docModelPdu
.
visible
=
_param
.
visible
||
false
;
docModelPdu
.
action
=
_param
.
action
||
ApeConsts
.
DOC_ACTION_NORMAL
;
//0,无操作, 1翻页、2.显示/隐藏, 3缩放/滚动
docModelPdu
.
docId
=
_param
.
docId
||
""
;
//文档在服务器数据库中的唯一id,必须有
docModelPdu
.
md5
=
_param
.
md5
||
""
;
//MD5
docModelPdu
.
fileName
=
_param
.
fileName
||
"doc_"
+
_itemIdx
;
//文档的名字
docModelPdu
.
dynamicTS
=
_param
.
dynamicTS
||
"0"
;
//文档上传后返回值中的字段dynamicTransferStatic
docModelPdu
.
showType
=
_param
.
showType
||
0
;
//文档显示模式
docModelPdu
.
animationStep
=
_param
.
animationStep
||
1
;
//当前页面上的动画步数(动态ppt时有这个字段)
//loger.log(docModelPdu);
return
docModelPdu
;
}
unPackPdu
(
owner
,
itemIdx
,
itemData
)
{
if
(
owner
==
null
||
itemIdx
==
null
||
itemData
==
null
)
{
this
.
_emit
(
MessageTypes
.
MCU_ERROR
,
MessageTypes
.
ERR_APE_INTERFACE_PARAM_WRONG
);
return
null
;
}
try
{
let
docModelPdu
=
pdu
[
'RCDocSendDataModelPdu'
].
decode
(
itemData
);
//loger.log("文档===>unPackPdu");
return
docModelPdu
;
}
catch
(
err
)
{
loger
.
log
(
"文档===>unPackPdu->Pdu解析错误->itemIdx="
+
itemIdx
+
"->err:"
+
err
.
message
);
}
return
null
;
}
}
...
...
请
注册
或
登录
后发表评论