正在显示
5 个修改的文件
包含
767 行增加
和
689 行删除
| @@ -58,16 +58,21 @@ export default class MessageEntrance extends Emiter { | @@ -58,16 +58,21 @@ export default class MessageEntrance extends Emiter { | ||
| 58 | constructor() { | 58 | constructor() { |
| 59 | super(); | 59 | super(); |
| 60 | //sdk 信息 | 60 | //sdk 信息 |
| 61 | - GlobalConfig.sdkVersion = "v1.68.2.20170812"; | 61 | + GlobalConfig.sdkVersion = "v1.70.5.20170812"; |
| 62 | loger.warn("sdkVersion:" + GlobalConfig.sdkVersion); | 62 | loger.warn("sdkVersion:" + GlobalConfig.sdkVersion); |
| 63 | 63 | ||
| 64 | //设置 | 64 | //设置 |
| 65 | let locationProtocol= location.protocol; | 65 | let locationProtocol= location.protocol; |
| 66 | - if(locationProtocol!="https:"){ | ||
| 67 | - GlobalConfig.locationProtocol="http://"; | ||
| 68 | - }else { | 66 | + if(locationProtocol=="https:"){ |
| 67 | + GlobalConfig.isHttps=true; | ||
| 69 | GlobalConfig.locationProtocol="https://"; | 68 | GlobalConfig.locationProtocol="https://"; |
| 69 | + GlobalConfig.websocketProtocol="wss://"; | ||
| 70 | + }else { | ||
| 71 | + GlobalConfig.isHttps=false; | ||
| 72 | + GlobalConfig.locationProtocol="http://"; | ||
| 73 | + GlobalConfig.websocketProtocol="ws://"; | ||
| 70 | } | 74 | } |
| 75 | + | ||
| 71 | loger.warn("protocol:" + GlobalConfig.locationProtocol); | 76 | loger.warn("protocol:" + GlobalConfig.locationProtocol); |
| 72 | //获取设备和系统信息 | 77 | //获取设备和系统信息 |
| 73 | SystemConfig.getSystemInfo(); | 78 | SystemConfig.getSystemInfo(); |
| @@ -496,7 +501,12 @@ export default class MessageEntrance extends Emiter { | @@ -496,7 +501,12 @@ export default class MessageEntrance extends Emiter { | ||
| 496 | //保存参数 | 501 | //保存参数 |
| 497 | GlobalConfig.isRecordPlayBack = false; //设置为非录制回放状态 | 502 | GlobalConfig.isRecordPlayBack = false; //设置为非录制回放状态 |
| 498 | GlobalConfig.classId = parseInt(_param.classId); | 503 | GlobalConfig.classId = parseInt(_param.classId); |
| 499 | - GlobalConfig.portal = _param.portal; | 504 | + GlobalConfig.portal = _param.portal||""; |
| 505 | + if(GlobalConfig.isHttps==true){ | ||
| 506 | + //https的时候替换所有80端口 | ||
| 507 | + GlobalConfig.portal= GlobalConfig.portal.replace(":80",""); | ||
| 508 | + } | ||
| 509 | + | ||
| 500 | GlobalConfig.userId = _param.userId || "0"; | 510 | GlobalConfig.userId = _param.userId || "0"; |
| 501 | //H5处理 | 511 | //H5处理 |
| 502 | GlobalConfig.isH5 = _param.isH5 || false;//外部传入的参数,是否是H5 | 512 | GlobalConfig.isH5 = _param.isH5 || false;//外部传入的参数,是否是H5 |
| @@ -2279,7 +2289,12 @@ export default class MessageEntrance extends Emiter { | @@ -2279,7 +2289,12 @@ export default class MessageEntrance extends Emiter { | ||
| 2279 | //保存参数 | 2289 | //保存参数 |
| 2280 | GlobalConfig.isRecordPlayBack = true; //设置为录制回放状态 | 2290 | GlobalConfig.isRecordPlayBack = true; //设置为录制回放状态 |
| 2281 | GlobalConfig.classId = parseInt(_param.classId); | 2291 | GlobalConfig.classId = parseInt(_param.classId); |
| 2282 | - GlobalConfig.portal = _param.portal; | 2292 | + GlobalConfig.portal = _param.portal||""; |
| 2293 | + if(GlobalConfig.isHttps==true){ | ||
| 2294 | + //https的时候替换所有80端口 | ||
| 2295 | + GlobalConfig.portal= GlobalConfig.portal.replace(":80",""); | ||
| 2296 | + } | ||
| 2297 | + | ||
| 2283 | GlobalConfig.userRole = ApeConsts.normal; //*************很重要,录制回放的时候,身份模式是普通人******** | 2298 | GlobalConfig.userRole = ApeConsts.normal; //*************很重要,录制回放的时候,身份模式是普通人******** |
| 2284 | GlobalConfig.userId = _param.userId || "0"; | 2299 | GlobalConfig.userId = _param.userId || "0"; |
| 2285 | GlobalConfig.userName = _param.userName || ""; | 2300 | GlobalConfig.userName = _param.userName || ""; |
| @@ -2330,6 +2345,12 @@ export default class MessageEntrance extends Emiter { | @@ -2330,6 +2345,12 @@ export default class MessageEntrance extends Emiter { | ||
| 2330 | if (_video_ape) { | 2345 | if (_video_ape) { |
| 2331 | _video_ape.clearData(); | 2346 | _video_ape.clearData(); |
| 2332 | } | 2347 | } |
| 2348 | + if (_mediaShareApe) { | ||
| 2349 | + _mediaShareApe.clearData(); | ||
| 2350 | + } | ||
| 2351 | + if (_musicShareApe) { | ||
| 2352 | + _musicShareApe.clearData(); | ||
| 2353 | + } | ||
| 2333 | } | 2354 | } |
| 2334 | 2355 | ||
| 2335 | //录制回放加入 课堂成功 | 2356 | //录制回放加入 课堂成功 |
| @@ -14,6 +14,8 @@ | @@ -14,6 +14,8 @@ | ||
| 14 | 14 | ||
| 15 | import Emiter from 'Emiter'; | 15 | import Emiter from 'Emiter'; |
| 16 | import Loger from 'Loger'; | 16 | import Loger from 'Loger'; |
| 17 | +import GlobalConfig from 'GlobalConfig'; | ||
| 18 | + | ||
| 17 | let loger = Loger.getLoger('EverSocket'); | 19 | let loger = Loger.getLoger('EverSocket'); |
| 18 | const MCU_MAX_RECONNECTION = 4;//最多重连次数 | 20 | const MCU_MAX_RECONNECTION = 4;//最多重连次数 |
| 19 | class EverSocket extends Emiter { | 21 | class EverSocket extends Emiter { |
| @@ -33,7 +35,8 @@ class EverSocket extends Emiter { | @@ -33,7 +35,8 @@ class EverSocket extends Emiter { | ||
| 33 | loger.error('开始MCU连接->MCU连接地址无效'); | 35 | loger.error('开始MCU连接->MCU连接地址无效'); |
| 34 | } | 36 | } |
| 35 | this._enableEverSocket = true; | 37 | this._enableEverSocket = true; |
| 36 | - this.wsURL = 'ws://' + ip + ':' + port; | 38 | + //this.wsURL = 'ws://' + ip + ':' + port; |
| 39 | + this.wsURL = GlobalConfig.websocketProtocol + ip + ':' + port; | ||
| 37 | this._newConnection(); | 40 | this._newConnection(); |
| 38 | } | 41 | } |
| 39 | 42 | ||
| @@ -42,10 +45,15 @@ class EverSocket extends Emiter { | @@ -42,10 +45,15 @@ class EverSocket extends Emiter { | ||
| 42 | this._clear(); | 45 | this._clear(); |
| 43 | } | 46 | } |
| 44 | switchSocketIp(ip,port) { | 47 | switchSocketIp(ip,port) { |
| 45 | - if(port){ | 48 | + /* if(port){ |
| 46 | this.wsURL = 'ws://' + ip + ':' + port; | 49 | this.wsURL = 'ws://' + ip + ':' + port; |
| 47 | }else { | 50 | }else { |
| 48 | this.wsURL = 'ws://' + ip; | 51 | this.wsURL = 'ws://' + ip; |
| 52 | + }*/ | ||
| 53 | + if(port){ | ||
| 54 | + this.wsURL = GlobalConfig.websocketProtocol + ip + ':' + port; | ||
| 55 | + }else { | ||
| 56 | + this.wsURL = GlobalConfig.websocketProtocol + ip; | ||
| 49 | } | 57 | } |
| 50 | } | 58 | } |
| 51 | get connected() { | 59 | get connected() { |
| @@ -352,7 +352,7 @@ GlobalConfig.messageDelay = false; //是否启用消息延迟 | @@ -352,7 +352,7 @@ GlobalConfig.messageDelay = false; //是否启用消息延迟 | ||
| 352 | GlobalConfig.mcuDelay = 0; //默认的延迟时间(单位-秒) | 352 | GlobalConfig.mcuDelay = 0; //默认的延迟时间(单位-秒) |
| 353 | 353 | ||
| 354 | GlobalConfig.docDelay = 1600; //文档模块加入成功之后延迟发送送成功的消息给主模块(sdk内部使用) | 354 | GlobalConfig.docDelay = 1600; //文档模块加入成功之后延迟发送送成功的消息给主模块(sdk内部使用) |
| 355 | -GlobalConfig.portal = "112.126.80.182:80"; //Sass IP | 355 | +GlobalConfig.portal = ""; //Sass IP |
| 356 | 356 | ||
| 357 | //从Sass获取的 | 357 | //从Sass获取的 |
| 358 | GlobalConfig.country = ""; //国家 | 358 | GlobalConfig.country = ""; //国家 |
| @@ -535,5 +535,7 @@ GlobalConfig.explorerVersion="未知";//浏览器版本 | @@ -535,5 +535,7 @@ GlobalConfig.explorerVersion="未知";//浏览器版本 | ||
| 535 | GlobalConfig.os="未知";//系统 | 535 | GlobalConfig.os="未知";//系统 |
| 536 | 536 | ||
| 537 | GlobalConfig.locationProtocol="http://";//https;或http: | 537 | GlobalConfig.locationProtocol="http://";//https;或http: |
| 538 | +GlobalConfig.websocketProtocol="ws://";//wss或ws | ||
| 539 | +GlobalConfig.isHttps=false;//是否是https | ||
| 538 | export default GlobalConfig; | 540 | export default GlobalConfig; |
| 539 | 541 |
| @@ -41,6 +41,7 @@ class RecordPlayBackParse extends Emiter { | @@ -41,6 +41,7 @@ class RecordPlayBackParse extends Emiter { | ||
| 41 | this._docApeMssages = {};//文档数据 | 41 | this._docApeMssages = {};//文档数据 |
| 42 | this._whiteApeMssages = {};//白板数据 | 42 | this._whiteApeMssages = {};//白板数据 |
| 43 | this._mediaShareApeMssages={};//媒体共享 | 43 | this._mediaShareApeMssages={};//媒体共享 |
| 44 | + this._musicShareApeMssages={};//伴音媒体共享 | ||
| 44 | this._timerCounter = new TimerCounter();//计时器 | 45 | this._timerCounter = new TimerCounter();//计时器 |
| 45 | this._timerCounter.addTimerCallBack(this._timerCounterUptate.bind(this), 1); | 46 | this._timerCounter.addTimerCallBack(this._timerCounterUptate.bind(this), 1); |
| 46 | } | 47 | } |
| @@ -171,6 +172,9 @@ class RecordPlayBackParse extends Emiter { | @@ -171,6 +172,9 @@ class RecordPlayBackParse extends Emiter { | ||
| 171 | case ApeConsts.MEDIA_SESSION_ID: | 172 | case ApeConsts.MEDIA_SESSION_ID: |
| 172 | this.saveParseData(data, timestamp, this._mediaShareApeMssages); | 173 | this.saveParseData(data, timestamp, this._mediaShareApeMssages); |
| 173 | break; | 174 | break; |
| 175 | + case ApeConsts.MUSIC_SESSION_ID: | ||
| 176 | + this.saveParseData(data, timestamp, this._musicShareApeMssages); | ||
| 177 | + break; | ||
| 174 | case ApeConsts.WHITEBOARD_SESSION_ID: | 178 | case ApeConsts.WHITEBOARD_SESSION_ID: |
| 175 | this.saveParseData(data, timestamp, this._whiteApeMssages); | 179 | this.saveParseData(data, timestamp, this._whiteApeMssages); |
| 176 | break; | 180 | break; |
| @@ -235,7 +239,8 @@ class RecordPlayBackParse extends Emiter { | @@ -235,7 +239,8 @@ class RecordPlayBackParse extends Emiter { | ||
| 235 | this._searchMessageFromTime(this._recordPlaybackTimestamp, this._conferApeMssages,"conferApe"); | 239 | this._searchMessageFromTime(this._recordPlaybackTimestamp, this._conferApeMssages,"conferApe"); |
| 236 | this._searchMessageFromTime(this._recordPlaybackTimestamp, this._chatApeMssages,"chatApe"); | 240 | this._searchMessageFromTime(this._recordPlaybackTimestamp, this._chatApeMssages,"chatApe"); |
| 237 | this._searchMessageFromTime(this._recordPlaybackTimestamp, this._docApeMssages,"docApe"); | 241 | this._searchMessageFromTime(this._recordPlaybackTimestamp, this._docApeMssages,"docApe"); |
| 238 | - this._searchMessageFromTime(this._recordPlaybackTimestamp, this._mediaShareApeMssages,"mediaShareApe") | 242 | + this._searchMessageFromTime(this._recordPlaybackTimestamp, this._mediaShareApeMssages,"mediaShareApe"); |
| 243 | + this._searchMessageFromTime(this._recordPlaybackTimestamp, this._musicShareApeMssages,"musicShareApe"); | ||
| 239 | this._searchMessageFromTime(this._recordPlaybackTimestamp, this._whiteApeMssages,"whiteApe"); | 244 | this._searchMessageFromTime(this._recordPlaybackTimestamp, this._whiteApeMssages,"whiteApe"); |
| 240 | this._searchMessageFromTime(this._recordPlaybackTimestamp, this._videoApeMssages,"videoAp"); | 245 | this._searchMessageFromTime(this._recordPlaybackTimestamp, this._videoApeMssages,"videoAp"); |
| 241 | this._searchMessageFromTime(this._recordPlaybackTimestamp, this._audioApeMssages,"audioApe"); | 246 | this._searchMessageFromTime(this._recordPlaybackTimestamp, this._audioApeMssages,"audioApe"); |
| @@ -319,7 +324,9 @@ class RecordPlayBackParse extends Emiter { | @@ -319,7 +324,9 @@ class RecordPlayBackParse extends Emiter { | ||
| 319 | } | 324 | } |
| 320 | 325 | ||
| 321 | GlobalConfig.recordPlaybackMaxTime = this._recordPlaybackMaxTime; | 326 | GlobalConfig.recordPlaybackMaxTime = this._recordPlaybackMaxTime; |
| 322 | - console.log('MediaChannleList',this.mediaChannleList); | 327 | + console.log('音视频通话模块数据',this.mediaChannleList); |
| 328 | + console.log('媒体共享模块数据',this._mediaShareApeMssages); | ||
| 329 | + console.log('伴音模块数据',this._musicShareApeMssages); | ||
| 323 | loger.log("录制回放数据解析完成,录制回放的总时间长为->", this._recordPlaybackMaxTime); | 330 | loger.log("录制回放数据解析完成,录制回放的总时间长为->", this._recordPlaybackMaxTime); |
| 324 | this._emit(RecordPlayBackParse.CLASS_JOIN_RECORD_PLAYBACK_SUCCESS, {"recordPlaybackMaxTime": this._recordPlaybackMaxTime}); | 331 | this._emit(RecordPlayBackParse.CLASS_JOIN_RECORD_PLAYBACK_SUCCESS, {"recordPlaybackMaxTime": this._recordPlaybackMaxTime}); |
| 325 | } | 332 | } |
| @@ -403,6 +410,9 @@ class RecordPlayBackParse extends Emiter { | @@ -403,6 +410,9 @@ class RecordPlayBackParse extends Emiter { | ||
| 403 | //媒体共享模块 | 410 | //媒体共享模块 |
| 404 | this.searchMediaShareApeMessageKeyfram(this._mediaShareApeMssages); | 411 | this.searchMediaShareApeMessageKeyfram(this._mediaShareApeMssages); |
| 405 | 412 | ||
| 413 | + //伴音共享模块 | ||
| 414 | + this.searchMusicShareApeMessageKeyfram(this._musicShareApeMssages); | ||
| 415 | + | ||
| 406 | //聊天模块、白板标注模块的比较特殊,消息是累计的,默认最多30条 | 416 | //聊天模块、白板标注模块的比较特殊,消息是累计的,默认最多30条 |
| 407 | this._searchChatHistoryMessageKeyfram(this._chatApeMssages, ApeConsts.CHAT_SESSION_ID); | 417 | this._searchChatHistoryMessageKeyfram(this._chatApeMssages, ApeConsts.CHAT_SESSION_ID); |
| 408 | this._searchWhiteboradHistoryMessageKeyfram(this._whiteApeMssages, ApeConsts.WHITEBOARD_SESSION_ID); | 418 | this._searchWhiteboradHistoryMessageKeyfram(this._whiteApeMssages, ApeConsts.WHITEBOARD_SESSION_ID); |
| @@ -486,6 +496,28 @@ class RecordPlayBackParse extends Emiter { | @@ -486,6 +496,28 @@ class RecordPlayBackParse extends Emiter { | ||
| 486 | loger.log("SEEK->APE->媒体共享", this._recordPlaybackTimestamp, "没有查找到相连的数据"); | 496 | loger.log("SEEK->APE->媒体共享", this._recordPlaybackTimestamp, "没有查找到相连的数据"); |
| 487 | } | 497 | } |
| 488 | 498 | ||
| 499 | + //伴音共享模块查找关键帧时间戳的消息 | ||
| 500 | + searchMusicShareApeMessageKeyfram(_apeMessages){ | ||
| 501 | + if(!_apeMessages){ | ||
| 502 | + return; | ||
| 503 | + } | ||
| 504 | + let messageItem; | ||
| 505 | + let keyFrameSeekTime = 0; | ||
| 506 | + for (let i = this._recordPlaybackTimestamp; i > 0; i--) { | ||
| 507 | + messageItem = _apeMessages[i]; | ||
| 508 | + if (messageItem) { | ||
| 509 | + keyFrameSeekTime = (this._recordPlaybackTimestamp - i) | ||
| 510 | + loger.log("SEEK->APE",'伴音共享',this._recordPlaybackTimestamp, "查找到相连的timestamp->", i, '需要seek->', keyFrameSeekTime, "秒"); | ||
| 511 | + //把时间点对应的数据发送,同一秒内有存在多个数据的情况 | ||
| 512 | + for (let k = 0; k < messageItem.length; k++) { | ||
| 513 | + this._everSocketMsgReceivedHandler(messageItem[k].byteData, keyFrameSeekTime); | ||
| 514 | + } | ||
| 515 | + return; | ||
| 516 | + } | ||
| 517 | + } | ||
| 518 | + loger.log("SEEK->APE->伴音共享", this._recordPlaybackTimestamp, "没有查找到相连的数据"); | ||
| 519 | + } | ||
| 520 | + | ||
| 489 | //查找聊天模块ape关键帧数据,聊天模块比较特殊,消息是累积的,当前时间戳之前的都需要显示 | 521 | //查找聊天模块ape关键帧数据,聊天模块比较特殊,消息是累积的,当前时间戳之前的都需要显示 |
| 490 | _searchChatHistoryMessageKeyfram(_apeMessages) { | 522 | _searchChatHistoryMessageKeyfram(_apeMessages) { |
| 491 | if(!_apeMessages){ | 523 | if(!_apeMessages){ |
| @@ -25,720 +25,735 @@ let loger = Loger.getLoger('DocApe'); | @@ -25,720 +25,735 @@ let loger = Loger.getLoger('DocApe'); | ||
| 25 | //let itemIdx = 0;//table插入新数据的计数id,目前用时间戳 | 25 | //let itemIdx = 0;//table插入新数据的计数id,目前用时间戳 |
| 26 | 26 | ||
| 27 | class DocApe extends Ape { | 27 | class DocApe extends Ape { |
| 28 | - constructor() { | ||
| 29 | - super( | ||
| 30 | - ApeConsts.DOCSHARING_SESSION_ID, | ||
| 31 | - ApeConsts.DOCSHARING_SESSION_NAME, | ||
| 32 | - ApeConsts.DOCSHARING_SESSION_TAG | ||
| 33 | - ); | ||
| 34 | - this.docList = {};//记录文档的数组this.docList[itemIdx]=itemIdx的数据 | ||
| 35 | - | ||
| 36 | - // Ape Models | ||
| 37 | - this.registerKey(this._session_id, this._session_name, this._session_tag, new ArrayBuffer); | ||
| 38 | - 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); | ||
| 39 | - } | ||
| 40 | - | ||
| 41 | - /////////////发送数据操作////////////////////////////////////////////////////// | ||
| 42 | - //上传文档 | ||
| 43 | - documentUpload(paramInfo) { | ||
| 44 | - if (paramInfo == null || EngineUtils.isEmptyObject(paramInfo)) { | ||
| 45 | - loger.warn('上传文档->失败->参数错误->',paramInfo); | ||
| 46 | - this._emit(MessageTypes.MCU_ERROR, MessageTypes.ERR_APE_INTERFACE_PARAM_WRONG); | ||
| 47 | - return; | ||
| 48 | - } | ||
| 49 | - //判断文档是否已经存在,每个文档都有唯一的docId,如果已经同步的文档中存在相同的docId就不需要再同步 | ||
| 50 | - if (this.checkDocId(paramInfo.docId)) { | ||
| 51 | - //文档已经存在相同的docId,不需要同步上传 | ||
| 52 | - loger.warn('上传文档->失败->文档档的docId无效或已经存在相同的docId不需要上传'); | ||
| 53 | - return; | ||
| 54 | - } | ||
| 55 | - | ||
| 56 | - let itemIdx = EngineUtils.creatSoleNumberFromTimestamp();// | ||
| 57 | - let docDataModelPdu = this.packPdu(paramInfo, itemIdx); | ||
| 58 | - if (docDataModelPdu == null) { | ||
| 59 | - loger.log('上传文档->失败->数据无效'); | ||
| 60 | - this._emit(MessageTypes.MCU_ERROR, MessageTypes.ERR_APE_INTERFACE_PARAM_WRONG); | ||
| 61 | - return; | ||
| 62 | - } | ||
| 63 | - //console.log(docDataModelPdu); | ||
| 64 | - | ||
| 65 | - let tableItemPdu = new pdu['RCRegistryTableItemPdu']; | ||
| 66 | - tableItemPdu.itemIdx = itemIdx;//直接用时间戳作为id | ||
| 67 | - tableItemPdu.registerObjId = ApeConsts.DOCSHARING_OBJ_TABLE_ID;// tableItemPdu.registerObjId=ApeConsts.DOCSHARING_OBJ_TABLE_ID_H5; | ||
| 68 | - tableItemPdu.owner = 0;//收到flash的是这个值,不清楚先写固定 | ||
| 69 | - tableItemPdu.itemData = docDataModelPdu.toArrayBuffer(); | ||
| 70 | - | ||
| 71 | - //insert | ||
| 72 | - let tableInsertItemPdu = new pdu['RCRegistryTableInsertItemPdu']; | ||
| 73 | - //optional RCPduType_E type = 1 [default = RCPDU_REG_TABLE_UPDATE_PDU]; | ||
| 74 | - //repeated RCRegistryTableItemPdu items = 2; | ||
| 75 | - tableInsertItemPdu.type = pdu.RCPDU_REG_TABLE_INSERT_PDU;// | ||
| 76 | - tableInsertItemPdu.items.push(tableItemPdu); | ||
| 77 | - | ||
| 78 | - let updateObjPdu = new pdu['RCRegistryUpdateObjPdu']; | ||
| 79 | - updateObjPdu.objId = ApeConsts.DOCSHARING_OBJ_TABLE_ID;// updateObjPdu.objId = ApeConsts.DOCSHARING_OBJ_TABLE_ID_H5; | ||
| 80 | - updateObjPdu.subType = tableInsertItemPdu.type; | ||
| 81 | - updateObjPdu.userData = tableInsertItemPdu.toArrayBuffer(); | ||
| 82 | - | ||
| 83 | - //同步 | ||
| 84 | - let adapterItemPdu = new pdu['RCAdapterItemPdu']; | ||
| 85 | - adapterItemPdu.type = pdu.RCPDU_REG_UPDATE_OBJ; | ||
| 86 | - adapterItemPdu.itemData = updateObjPdu.toArrayBuffer(); | ||
| 87 | - | ||
| 88 | - let adapterPdu = new pdu['RCAdapterPdu']; | ||
| 89 | - adapterPdu.type = pdu.RCPDU_REG_ADAPTER; | ||
| 90 | - adapterPdu.item.push(adapterItemPdu); | ||
| 91 | - | ||
| 92 | - loger.log("上传文档->发送->itemIdx=" + tableItemPdu.itemIdx); | ||
| 93 | - this.sendUniform(adapterPdu, true); | ||
| 94 | - } | ||
| 95 | - | ||
| 96 | - updaterDoc(_docDataModel, _itemIdx) { | ||
| 97 | - //loger.log("文档===updaterDoc ",_itemIdx); | ||
| 98 | - //验证坐标点集合数组是否合法 | ||
| 99 | - if (_docDataModel == null || _itemIdx == null) { | ||
| 100 | - this._emit(MessageTypes.MCU_ERROR, MessageTypes.ERR_APE_INTERFACE_PARAM_WRONG); | ||
| 101 | - return null; | ||
| 102 | - } | ||
| 103 | - //loger.log("文档->updaterDoc ", _docDataModel); | ||
| 104 | - | ||
| 105 | - let docDataModelPdu = this.packPdu(_docDataModel, _itemIdx); | ||
| 106 | - let tableItemPdu = new pdu['RCRegistryTableItemPdu']; | ||
| 107 | - tableItemPdu.itemIdx = _itemIdx;//直接用时间戳作为id | ||
| 108 | - //tableItemPdu.registerObjId=ApeConsts.DOCSHARING_OBJ_TABLE_ID;// tableItemPdu.registerObjId=ApeConsts.DOCSHARING_OBJ_TABLE_ID_H5; | ||
| 109 | - tableItemPdu.owner = 0;//收到flash的是这个值,不清楚先写固定 | ||
| 110 | - tableItemPdu.itemData = docDataModelPdu.toArrayBuffer(); | ||
| 111 | - | ||
| 112 | - //insert | ||
| 113 | - let tableInsertItemPdu = new pdu['RCRegistryTableUpdateItemPdu']; | ||
| 114 | - //optional RCPduType_E type = 1 [default = RCPDU_REG_TABLE_UPDATE_PDU]; | ||
| 115 | - //repeated RCRegistryTableItemPdu items = 2; | ||
| 116 | - tableInsertItemPdu.type = pdu.RCPDU_REG_TABLE_UPDATE_PDU;// | ||
| 117 | - tableInsertItemPdu.items.push(tableItemPdu); | ||
| 118 | - | ||
| 119 | - let updateObjPdu = new pdu['RCRegistryUpdateObjPdu']; | ||
| 120 | - updateObjPdu.objId = ApeConsts.DOCSHARING_OBJ_TABLE_ID;// updateObjPdu.objId = ApeConsts.DOCSHARING_OBJ_TABLE_ID_H5; | ||
| 121 | - updateObjPdu.subType = tableInsertItemPdu.type; | ||
| 122 | - updateObjPdu.userData = tableInsertItemPdu.toArrayBuffer(); | ||
| 123 | - | ||
| 124 | - //同步 | ||
| 125 | - let adapterItemPdu = new pdu['RCAdapterItemPdu']; | ||
| 126 | - adapterItemPdu.type = pdu.RCPDU_REG_UPDATE_OBJ; | ||
| 127 | - adapterItemPdu.itemData = updateObjPdu.toArrayBuffer(); | ||
| 128 | - | ||
| 129 | - let adapterPdu = new pdu['RCAdapterPdu']; | ||
| 130 | - adapterPdu.type = pdu.RCPDU_REG_ADAPTER; | ||
| 131 | - adapterPdu.item.push(adapterItemPdu); | ||
| 132 | - | ||
| 133 | - //loger.log("发送更新文档.itemIdx=" + tableItemPdu.itemIdx); | ||
| 134 | - this.sendUniform(adapterPdu, true); | ||
| 135 | - } | ||
| 136 | - //获取文档的完整地址和所有图片 | ||
| 137 | - getDocFullAddress(_param){ | ||
| 138 | - if (_param == null || _param.url == null || _param.itemIdx ==null) { | ||
| 139 | - loger.warn('获取文档完整地址->传递的参数不正确->', _param); | ||
| 140 | - return {"code":ApeConsts.RETURN_FAILED, "data": "获取文档时传递的参数不对"}; | ||
| 141 | - } | ||
| 142 | - let fullPath='';//文档路径地址 | ||
| 143 | - let pageNum=1;//总页数 | ||
| 144 | - let docType="";//文档地址的后缀类型 | ||
| 145 | - let fileType="";//文档的原始类型 | ||
| 146 | - let docItem=this.docList[_param.itemIdx]; | ||
| 147 | - if(docItem){ | ||
| 148 | - fullPath=docItem.url||""; | ||
| 149 | - pageNum=docItem.pageNum||1; | ||
| 150 | - fileType=docItem.fileType||"" | ||
| 151 | - }else { | ||
| 152 | - fullPath =_param.url; | ||
| 153 | - } | ||
| 154 | - | ||
| 155 | - //获取当前文档的后缀名 | ||
| 156 | - docType=this._getDocType(fullPath); | ||
| 157 | - let substrFullPath=this._getDocPath(fullPath);//获取去掉后缀和文件名的地址,需要获取同目录下其他文件 | ||
| 158 | - let imagesArr=[]; | ||
| 159 | - let htmlPath=""; | ||
| 160 | - let pdfPath=""; | ||
| 161 | - | ||
| 162 | - //根据文件后缀名,生成对应的访问地址 | ||
| 163 | - if(docType=="jpg"||docType=="png"||docType=="swf"||docType=="pdf"||docType=="doc"||docType=="pptx"){ | ||
| 164 | - //页数从1开始 | ||
| 165 | - for (let i = 1; i <=pageNum; i++) { | ||
| 166 | - imagesArr.push(substrFullPath + "/" + i + ".jpg"); | ||
| 167 | - } | ||
| 168 | - } | ||
| 169 | - if(docType=="swf"||docType=="pdf"||docType=="doc"||docType=="pptx"){ | ||
| 170 | - pdfPath=fullPath.replace(/\.swf/g, ".pdf")||""; | ||
| 171 | - } | ||
| 172 | - //动态PPT | ||
| 173 | - if(docType=="html"){ | ||
| 174 | - htmlPath=fullPath; | ||
| 175 | - } | ||
| 176 | - //返回文档第所有地址 | ||
| 177 | - return {'code':ApeConsts.RETURN_SUCCESS, 'data': '','docFullAddress':{ | ||
| 178 | - 'images':imagesArr, | ||
| 179 | - 'pdf':pdfPath, | ||
| 180 | - 'html':htmlPath | ||
| 181 | - }}; | 28 | + constructor() { |
| 29 | + super( | ||
| 30 | + ApeConsts.DOCSHARING_SESSION_ID, | ||
| 31 | + ApeConsts.DOCSHARING_SESSION_NAME, | ||
| 32 | + ApeConsts.DOCSHARING_SESSION_TAG | ||
| 33 | + ); | ||
| 34 | + this.docList = {};//记录文档的数组this.docList[itemIdx]=itemIdx的数据 | ||
| 35 | + | ||
| 36 | + // Ape Models | ||
| 37 | + this.registerKey(this._session_id, this._session_name, this._session_tag, new ArrayBuffer); | ||
| 38 | + 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); | ||
| 39 | + } | ||
| 40 | + | ||
| 41 | + /////////////发送数据操作////////////////////////////////////////////////////// | ||
| 42 | + //上传文档 | ||
| 43 | + documentUpload(paramInfo) { | ||
| 44 | + if (paramInfo == null || EngineUtils.isEmptyObject(paramInfo)) { | ||
| 45 | + loger.warn('上传文档->失败->参数错误->', paramInfo); | ||
| 46 | + this._emit(MessageTypes.MCU_ERROR, MessageTypes.ERR_APE_INTERFACE_PARAM_WRONG); | ||
| 47 | + return; | ||
| 48 | + } | ||
| 49 | + //判断文档是否已经存在,每个文档都有唯一的docId,如果已经同步的文档中存在相同的docId就不需要再同步 | ||
| 50 | + if (this.checkDocId(paramInfo.docId)) { | ||
| 51 | + //文档已经存在相同的docId,不需要同步上传 | ||
| 52 | + loger.warn('上传文档->失败->文档档的docId无效或已经存在相同的docId不需要上传'); | ||
| 53 | + return; | ||
| 182 | } | 54 | } |
| 183 | 55 | ||
| 184 | - _getDocType(_fullPath){ | ||
| 185 | - if(!_fullPath){ | ||
| 186 | - return ""; | ||
| 187 | - } | ||
| 188 | - if(_fullPath.lastIndexOf(".jpg")>=0){ | ||
| 189 | - return "jpg"; | ||
| 190 | - } | ||
| 191 | - if(_fullPath.lastIndexOf(".png")>=0){ | ||
| 192 | - return "png"; | ||
| 193 | - } | ||
| 194 | - if(_fullPath.lastIndexOf(".swf")>=0){ | ||
| 195 | - return "swf"; | ||
| 196 | - } | ||
| 197 | - if(_fullPath.lastIndexOf(".pdf")>=0){ | ||
| 198 | - return "pdf"; | ||
| 199 | - } | ||
| 200 | - if(_fullPath.lastIndexOf(".doc")>=0){ | ||
| 201 | - return "doc"; | ||
| 202 | - } | ||
| 203 | - if(_fullPath.lastIndexOf(".html")>=0){ | ||
| 204 | - return "html"; | ||
| 205 | - } | ||
| 206 | - if(_fullPath.lastIndexOf(".pptx")>=0){ | ||
| 207 | - return "pptx"; | ||
| 208 | - } | ||
| 209 | - return ""; | 56 | + let itemIdx = EngineUtils.creatSoleNumberFromTimestamp();// |
| 57 | + let docDataModelPdu = this.packPdu(paramInfo, itemIdx); | ||
| 58 | + if (docDataModelPdu == null) { | ||
| 59 | + loger.log('上传文档->失败->数据无效'); | ||
| 60 | + this._emit(MessageTypes.MCU_ERROR, MessageTypes.ERR_APE_INTERFACE_PARAM_WRONG); | ||
| 61 | + return; | ||
| 210 | } | 62 | } |
| 211 | - //获取去掉文件名和后缀名的地址 http://www.xxx.xxx/image/aa.jpg -->http://www.xxx.xxx/image/ | ||
| 212 | - _getDocPath(_fullPath){ | ||
| 213 | - if(!_fullPath){ | ||
| 214 | - return ""; | ||
| 215 | - } | ||
| 216 | - var lastIndex = _fullPath.lastIndexOf("/"); | ||
| 217 | - if (lastIndex > 0) { | ||
| 218 | - return _fullPath.substr(0, lastIndex); | ||
| 219 | - } | ||
| 220 | - return _fullPath; | 63 | + //console.log(docDataModelPdu); |
| 64 | + | ||
| 65 | + let tableItemPdu = new pdu['RCRegistryTableItemPdu']; | ||
| 66 | + tableItemPdu.itemIdx = itemIdx;//直接用时间戳作为id | ||
| 67 | + tableItemPdu.registerObjId = ApeConsts.DOCSHARING_OBJ_TABLE_ID;// tableItemPdu.registerObjId=ApeConsts.DOCSHARING_OBJ_TABLE_ID_H5; | ||
| 68 | + tableItemPdu.owner = 0;//收到flash的是这个值,不清楚先写固定 | ||
| 69 | + tableItemPdu.itemData = docDataModelPdu.toArrayBuffer(); | ||
| 70 | + | ||
| 71 | + //insert | ||
| 72 | + let tableInsertItemPdu = new pdu['RCRegistryTableInsertItemPdu']; | ||
| 73 | + //optional RCPduType_E type = 1 [default = RCPDU_REG_TABLE_UPDATE_PDU]; | ||
| 74 | + //repeated RCRegistryTableItemPdu items = 2; | ||
| 75 | + tableInsertItemPdu.type = pdu.RCPDU_REG_TABLE_INSERT_PDU;// | ||
| 76 | + tableInsertItemPdu.items.push(tableItemPdu); | ||
| 77 | + | ||
| 78 | + let updateObjPdu = new pdu['RCRegistryUpdateObjPdu']; | ||
| 79 | + updateObjPdu.objId = ApeConsts.DOCSHARING_OBJ_TABLE_ID;// updateObjPdu.objId = ApeConsts.DOCSHARING_OBJ_TABLE_ID_H5; | ||
| 80 | + updateObjPdu.subType = tableInsertItemPdu.type; | ||
| 81 | + updateObjPdu.userData = tableInsertItemPdu.toArrayBuffer(); | ||
| 82 | + | ||
| 83 | + //同步 | ||
| 84 | + let adapterItemPdu = new pdu['RCAdapterItemPdu']; | ||
| 85 | + adapterItemPdu.type = pdu.RCPDU_REG_UPDATE_OBJ; | ||
| 86 | + adapterItemPdu.itemData = updateObjPdu.toArrayBuffer(); | ||
| 87 | + | ||
| 88 | + let adapterPdu = new pdu['RCAdapterPdu']; | ||
| 89 | + adapterPdu.type = pdu.RCPDU_REG_ADAPTER; | ||
| 90 | + adapterPdu.item.push(adapterItemPdu); | ||
| 91 | + | ||
| 92 | + loger.log("上传文档->发送->itemIdx=" + tableItemPdu.itemIdx); | ||
| 93 | + this.sendUniform(adapterPdu, true); | ||
| 94 | + } | ||
| 95 | + | ||
| 96 | + updaterDoc(_docDataModel, _itemIdx) { | ||
| 97 | + //loger.log("文档===updaterDoc ",_itemIdx); | ||
| 98 | + //验证坐标点集合数组是否合法 | ||
| 99 | + if (_docDataModel == null || _itemIdx == null) { | ||
| 100 | + this._emit(MessageTypes.MCU_ERROR, MessageTypes.ERR_APE_INTERFACE_PARAM_WRONG); | ||
| 101 | + return null; | ||
| 221 | } | 102 | } |
| 222 | - | ||
| 223 | - //获取文档的图片完整地址 | ||
| 224 | - getDocImageFullPath(_param) { | ||
| 225 | - if (_param == null || _param.relativeUrl == null || _param.relativeUrl == "") { | ||
| 226 | - loger.warn('获取文档完整地址,传递的参数不对.', _param); | ||
| 227 | - return []; | ||
| 228 | - } | ||
| 229 | - | ||
| 230 | - let port = (GlobalConfig.DOCServerPort == "" || GlobalConfig.DOCServerPort == null) ? "" : ":" + GlobalConfig.DOCServerPort; | ||
| 231 | - let fullPath = GlobalConfig.DOCServerIP + port + _param.relativeUrl; | ||
| 232 | - if (fullPath && fullPath.indexOf("http://") < 0) { | ||
| 233 | - fullPath = "http://" + fullPath; | ||
| 234 | - } | ||
| 235 | - | ||
| 236 | - var fileType = "jpg"; | ||
| 237 | - switch (_param.type) { | ||
| 238 | - case "jpg": | ||
| 239 | - fileType = "jpg"; | ||
| 240 | - fullPath = this.replacePathType(fullPath) + ".jpg"; | ||
| 241 | - break; | ||
| 242 | - case "png": | ||
| 243 | - fileType = "png"; | ||
| 244 | - fullPath = this.replacePathType(fullPath) + ".png"; | ||
| 245 | - break; | ||
| 246 | - default : | ||
| 247 | - //不做处理,直接返回拼接的地址 | ||
| 248 | - break; | ||
| 249 | - } | ||
| 250 | - | ||
| 251 | - if (_param.pageNum && parseInt(_param.pageNum) > 1) { | ||
| 252 | - //如果是多页的,需要返回序列 | ||
| 253 | - var lastIndex = fullPath.lastIndexOf("/"); | ||
| 254 | - if (lastIndex > 0) { | ||
| 255 | - let newPath = fullPath.substr(0, lastIndex); | ||
| 256 | - let pathArr = []; | ||
| 257 | - //页数从1开始 | ||
| 258 | - for (let i = 1; i <= _param.pageNum; i++) { | ||
| 259 | - pathArr.push(newPath + "/" + i + "." + fileType); | ||
| 260 | - } | ||
| 261 | - return pathArr; | ||
| 262 | - } else { | ||
| 263 | - return [fullPath]; | ||
| 264 | - } | ||
| 265 | - } else { | ||
| 266 | - return [fullPath]; | ||
| 267 | - } | 103 | + //loger.log("文档->updaterDoc ", _docDataModel); |
| 104 | + | ||
| 105 | + let docDataModelPdu = this.packPdu(_docDataModel, _itemIdx); | ||
| 106 | + let tableItemPdu = new pdu['RCRegistryTableItemPdu']; | ||
| 107 | + tableItemPdu.itemIdx = _itemIdx;//直接用时间戳作为id | ||
| 108 | + //tableItemPdu.registerObjId=ApeConsts.DOCSHARING_OBJ_TABLE_ID;// tableItemPdu.registerObjId=ApeConsts.DOCSHARING_OBJ_TABLE_ID_H5; | ||
| 109 | + tableItemPdu.owner = 0;//收到flash的是这个值,不清楚先写固定 | ||
| 110 | + tableItemPdu.itemData = docDataModelPdu.toArrayBuffer(); | ||
| 111 | + | ||
| 112 | + //insert | ||
| 113 | + let tableInsertItemPdu = new pdu['RCRegistryTableUpdateItemPdu']; | ||
| 114 | + //optional RCPduType_E type = 1 [default = RCPDU_REG_TABLE_UPDATE_PDU]; | ||
| 115 | + //repeated RCRegistryTableItemPdu items = 2; | ||
| 116 | + tableInsertItemPdu.type = pdu.RCPDU_REG_TABLE_UPDATE_PDU;// | ||
| 117 | + tableInsertItemPdu.items.push(tableItemPdu); | ||
| 118 | + | ||
| 119 | + let updateObjPdu = new pdu['RCRegistryUpdateObjPdu']; | ||
| 120 | + updateObjPdu.objId = ApeConsts.DOCSHARING_OBJ_TABLE_ID;// updateObjPdu.objId = ApeConsts.DOCSHARING_OBJ_TABLE_ID_H5; | ||
| 121 | + updateObjPdu.subType = tableInsertItemPdu.type; | ||
| 122 | + updateObjPdu.userData = tableInsertItemPdu.toArrayBuffer(); | ||
| 123 | + | ||
| 124 | + //同步 | ||
| 125 | + let adapterItemPdu = new pdu['RCAdapterItemPdu']; | ||
| 126 | + adapterItemPdu.type = pdu.RCPDU_REG_UPDATE_OBJ; | ||
| 127 | + adapterItemPdu.itemData = updateObjPdu.toArrayBuffer(); | ||
| 128 | + | ||
| 129 | + let adapterPdu = new pdu['RCAdapterPdu']; | ||
| 130 | + adapterPdu.type = pdu.RCPDU_REG_ADAPTER; | ||
| 131 | + adapterPdu.item.push(adapterItemPdu); | ||
| 132 | + | ||
| 133 | + //loger.log("发送更新文档.itemIdx=" + tableItemPdu.itemIdx); | ||
| 134 | + this.sendUniform(adapterPdu, true); | ||
| 135 | + } | ||
| 136 | + | ||
| 137 | + //获取文档的完整地址和所有图片 | ||
| 138 | + getDocFullAddress(_param) { | ||
| 139 | + if (_param == null || _param.url == null || _param.itemIdx == null) { | ||
| 140 | + loger.warn('获取文档完整地址->传递的参数不正确->', _param); | ||
| 141 | + return {"code": ApeConsts.RETURN_FAILED, "data": "获取文档时传递的参数不对"}; | ||
| 142 | + } | ||
| 143 | + let fullPath = '';//文档路径地址 | ||
| 144 | + let pageNum = 1;//总页数 | ||
| 145 | + let docType = "";//文档地址的后缀类型 | ||
| 146 | + let fileType = "";//文档的原始类型 | ||
| 147 | + let docItem = this.docList[_param.itemIdx]; | ||
| 148 | + if (docItem) { | ||
| 149 | + fullPath = docItem.url || ""; | ||
| 150 | + pageNum = docItem.pageNum || 1; | ||
| 151 | + fileType = docItem.fileType || "" | ||
| 152 | + } else { | ||
| 153 | + fullPath = _param.url; | ||
| 268 | } | 154 | } |
| 269 | 155 | ||
| 270 | - //获取文档的pdf完整地址 | ||
| 271 | - getDocPDFFullPath(_param) { | ||
| 272 | - if (_param == null || _param.relativeUrl == null || _param.relativeUrl == "") { | ||
| 273 | - loger.warn('获取文档完整地址,传递的参数不对.', _param); | ||
| 274 | - return []; | ||
| 275 | - } | ||
| 276 | - let port = (GlobalConfig.DOCServerPort == "" || GlobalConfig.DOCServerPort == null) ? "" : ":" + GlobalConfig.DOCServerPort; | ||
| 277 | - let fullPath = GlobalConfig.DOCServerIP + port + _param.relativeUrl; | ||
| 278 | - if (fullPath && fullPath.indexOf("http://") < 0) { | ||
| 279 | - fullPath = "http://" + fullPath; | ||
| 280 | - } | ||
| 281 | - fullPath = this.replacePathType(fullPath) + ".pdf"; | ||
| 282 | - return [fullPath]; | ||
| 283 | - } | ||
| 284 | - | ||
| 285 | - // 去除文件的后缀格式名称 | ||
| 286 | - replacePathType(_path) { | ||
| 287 | - let path = _path; | ||
| 288 | - path = path.replace(/.jpg/g, ""); | ||
| 289 | - path = path.replace(/.png/g, ""); | ||
| 290 | - path = path.replace(/.swf/g, ""); | ||
| 291 | - path = path.replace(/.pdf/g, ""); | ||
| 292 | - return path; | ||
| 293 | - } | ||
| 294 | - | ||
| 295 | - //组织完整的文档信息,包含上传时的信息和转换后的完整地址信息 | ||
| 296 | - _docPackFullInfo(_itemDataInfo){ | ||
| 297 | - let itemDataInfo=_itemDataInfo; | ||
| 298 | - let getDocAddress=this.getDocFullAddress(_itemDataInfo); | ||
| 299 | - //loger.log('docPackFullInfo->', itemDataInfo); | ||
| 300 | - if(getDocAddress.code==ApeConsts.RETURN_SUCCESS){ | ||
| 301 | - itemDataInfo.images=getDocAddress.docFullAddress.images||[]; | ||
| 302 | - itemDataInfo.pdf=getDocAddress.docFullAddress.pdf||""; | ||
| 303 | - itemDataInfo.html=getDocAddress.docFullAddress.html||""; | ||
| 304 | - }else { | ||
| 305 | - itemDataInfo.images=[]; | ||
| 306 | - itemDataInfo.pdf=''; | ||
| 307 | - itemDataInfo.html=''; | ||
| 308 | - } | ||
| 309 | - | ||
| 310 | - return itemDataInfo; | ||
| 311 | - } | ||
| 312 | - //更新文档模块的录制信息,每次开启录制的时候需要把当前文档的信息更新一次 | ||
| 313 | - updaterRecordApeStatus(_param){ | ||
| 314 | - /* if(GlobalConfig.isHost&&!GlobalConfig.isRecordPlayBack&&GlobalConfig.activeDocId>0){ | ||
| 315 | - loger.log("录制状态发送改变->更新当前的文档数据->docId:", GlobalConfig.activeDocId, 'page:',GlobalConfig.activeDocCurPage); | ||
| 316 | - this.documentSwitchPage({ | ||
| 317 | - "itemIdx": GlobalConfig.activeDocId, | ||
| 318 | - "curPageNo":GlobalConfig.activeDocCurPage | ||
| 319 | - }); | ||
| 320 | - }*/ | ||
| 321 | - loger.warn("录制状态发送改变->更新当前的文档数据->docId:", GlobalConfig.activeDocId, 'page:',GlobalConfig.activeDocCurPage); | ||
| 322 | - this.documentSwitchPage({ | ||
| 323 | - "itemIdx": GlobalConfig.activeDocId, | ||
| 324 | - "curPageNo":GlobalConfig.activeDocCurPage | ||
| 325 | - }); | ||
| 326 | - } | ||
| 327 | - //清除当前文档模块的数据 | ||
| 328 | - clearData(){ | ||
| 329 | - loger.log("clearData->") | ||
| 330 | - this.docList={}; | ||
| 331 | - GlobalConfig.activeDocId=0; | ||
| 332 | - GlobalConfig.activeDocCurPage=1; | ||
| 333 | - | ||
| 334 | - } | ||
| 335 | - //切换文档 | ||
| 336 | - documentSwitchDoc(paramInfo) { | ||
| 337 | - loger.log('切换文档->', paramInfo); | ||
| 338 | - if (GlobalConfig.isRecordPlayBack) { | ||
| 339 | - loger.warn('录制回放状态不允许切换文档'); | ||
| 340 | - return; | ||
| 341 | - } | ||
| 342 | - | ||
| 343 | - if (paramInfo == null || paramInfo.itemIdx == null) { | ||
| 344 | - loger.warn('切换文档失败,参数错误', paramInfo); | ||
| 345 | - this._emit(MessageTypes.MCU_ERROR, MessageTypes.ERR_APE_INTERFACE_PARAM_WRONG); | ||
| 346 | - return; | ||
| 347 | - } | ||
| 348 | - | ||
| 349 | - if (paramInfo.itemIdx == GlobalConfig.activeDocId && GlobalConfig.activeDocId != 0) { | ||
| 350 | - loger.warn('文档已经显示', paramInfo.itemIdx, GlobalConfig.activeDocId); | ||
| 351 | - return; | ||
| 352 | - } | ||
| 353 | - | ||
| 354 | - //更新切换之前的文档的数据,要显示当前切换的文档,上一个文档需要隐藏 | ||
| 355 | - let oldDocModel; | ||
| 356 | - if (GlobalConfig.activeDocId != 0) { | ||
| 357 | - oldDocModel = this.docList[GlobalConfig.activeDocId]; | ||
| 358 | - if (oldDocModel) { | ||
| 359 | - oldDocModel.action = ApeConsts.DOC_ACTION_NORMAL; | ||
| 360 | - oldDocModel.visible = false;//设置为不可见 | ||
| 361 | - oldDocModel.animationStep=1;//切换文档之后动画步数还原 | ||
| 362 | - } | ||
| 363 | - } | ||
| 364 | - | ||
| 365 | - //获取已经存在的数据 | ||
| 366 | - let docDataModel = this.docList[paramInfo.itemIdx]; | ||
| 367 | - if (docDataModel == null) { | ||
| 368 | - loger.warn('切换文档失败,文档不存在', paramInfo); | ||
| 369 | - this._emit(MessageTypes.MCU_ERROR, MessageTypes.ERR_APE_INTERFACE_PARAM_WRONG); | ||
| 370 | - return; | ||
| 371 | - } | ||
| 372 | - | ||
| 373 | - //更新当前选择的文档数据的字段 | ||
| 374 | - docDataModel.action = ApeConsts.DOC_ACTION_SWITCH_DOC; | ||
| 375 | - docDataModel.visible = paramInfo.visible || false;//默认是false | ||
| 376 | - docDataModel.animationStep=1;//切换文档之后动画步数还原 | 156 | + //替换地址的协议头,如果地址栏是https开头就换成https |
| 157 | + fullPath = fullPath.replace("http://", GlobalConfig.locationProtocol); | ||
| 158 | + | ||
| 159 | + //获取当前文档的后缀名 | ||
| 160 | + docType = this._getDocType(fullPath); | ||
| 161 | + let substrFullPath = this._getDocPath(fullPath);//获取去掉后缀和文件名的地址,需要获取同目录下其他文件 | ||
| 162 | + let imagesArr = []; | ||
| 163 | + let htmlPath = ""; | ||
| 164 | + let pdfPath = ""; | ||
| 165 | + | ||
| 166 | + //根据文件后缀名,生成对应的访问地址 | ||
| 167 | + if (docType == "jpg" || docType == "png" || docType == "swf" || docType == "pdf" || docType == "doc" || docType == "pptx") { | ||
| 168 | + //页数从1开始 | ||
| 169 | + for (let i = 1; i <= pageNum; i++) { | ||
| 170 | + imagesArr.push(substrFullPath + "/" + i + ".jpg"); | ||
| 171 | + } | ||
| 172 | + } | ||
| 173 | + if (docType == "swf" || docType == "pdf" || docType == "doc" || docType == "pptx") { | ||
| 174 | + pdfPath = fullPath.replace(/\.swf/g, ".pdf") || ""; | ||
| 175 | + } | ||
| 176 | + //动态PPT | ||
| 177 | + if (docType == "html") { | ||
| 178 | + htmlPath = fullPath; | ||
| 179 | + } | ||
| 180 | + //返回文档第所有地址 | ||
| 181 | + return { | ||
| 182 | + 'code': ApeConsts.RETURN_SUCCESS, 'data': '', 'docFullAddress': { | ||
| 183 | + 'images': imagesArr, | ||
| 184 | + 'pdf': pdfPath, | ||
| 185 | + 'html': htmlPath | ||
| 186 | + } | ||
| 187 | + }; | ||
| 188 | + } | ||
| 377 | 189 | ||
| 378 | - //loger.log('切换文档,当前文档和上一个显示的文档都需要更新状态'); | ||
| 379 | - loger.log({"oldDoc": oldDocModel, "nowDoc": docDataModel}); | ||
| 380 | - //更新当前选择的文档 | ||
| 381 | - this.updaterDoc(docDataModel, docDataModel.itemIdx); | 190 | + _getDocType(_fullPath) { |
| 191 | + if (!_fullPath) { | ||
| 192 | + return ""; | ||
| 193 | + } | ||
| 194 | + if (_fullPath.lastIndexOf(".jpg") >= 0) { | ||
| 195 | + return "jpg"; | ||
| 196 | + } | ||
| 197 | + if (_fullPath.lastIndexOf(".png") >= 0) { | ||
| 198 | + return "png"; | ||
| 199 | + } | ||
| 200 | + if (_fullPath.lastIndexOf(".swf") >= 0) { | ||
| 201 | + return "swf"; | ||
| 202 | + } | ||
| 203 | + if (_fullPath.lastIndexOf(".pdf") >= 0) { | ||
| 204 | + return "pdf"; | ||
| 205 | + } | ||
| 206 | + if (_fullPath.lastIndexOf(".doc") >= 0) { | ||
| 207 | + return "doc"; | ||
| 208 | + } | ||
| 209 | + if (_fullPath.lastIndexOf(".html") >= 0) { | ||
| 210 | + return "html"; | ||
| 211 | + } | ||
| 212 | + if (_fullPath.lastIndexOf(".pptx") >= 0) { | ||
| 213 | + return "pptx"; | ||
| 214 | + } | ||
| 215 | + return ""; | ||
| 216 | + } | ||
| 382 | 217 | ||
| 383 | - //更新上一个文档 隐藏 | ||
| 384 | - if (oldDocModel) { | ||
| 385 | - this.updaterDoc(oldDocModel, oldDocModel.itemIdx); | ||
| 386 | - } | 218 | + //获取去掉文件名和后缀名的地址 http://www.xxx.xxx/image/aa.jpg -->http://www.xxx.xxx/image/ |
| 219 | + _getDocPath(_fullPath) { | ||
| 220 | + if (!_fullPath) { | ||
| 221 | + return ""; | ||
| 222 | + } | ||
| 223 | + var lastIndex = _fullPath.lastIndexOf("/"); | ||
| 224 | + if (lastIndex > 0) { | ||
| 225 | + return _fullPath.substr(0, lastIndex); | ||
| 226 | + } | ||
| 227 | + return _fullPath; | ||
| 228 | + } | ||
| 229 | + | ||
| 230 | + //获取文档的图片完整地址 | ||
| 231 | + getDocImageFullPath(_param) { | ||
| 232 | + return []; | ||
| 233 | + /*if (_param == null || _param.relativeUrl == null || _param.relativeUrl == "") { | ||
| 234 | + loger.warn('获取文档完整地址,传递的参数不对.', _param); | ||
| 235 | + return []; | ||
| 236 | + } | ||
| 237 | + | ||
| 238 | + let port = (GlobalConfig.DOCServerPort == "" || GlobalConfig.DOCServerPort == null) ? "" : ":" + GlobalConfig.DOCServerPort; | ||
| 239 | + let fullPath = GlobalConfig.DOCServerIP + port + _param.relativeUrl; | ||
| 240 | + if (fullPath && fullPath.indexOf("http://") < 0) { | ||
| 241 | + fullPath = "http://" + fullPath; | ||
| 242 | + } | ||
| 243 | + | ||
| 244 | + var fileType = "jpg"; | ||
| 245 | + switch (_param.type) { | ||
| 246 | + case "jpg": | ||
| 247 | + fileType = "jpg"; | ||
| 248 | + fullPath = this.replacePathType(fullPath) + ".jpg"; | ||
| 249 | + break; | ||
| 250 | + case "png": | ||
| 251 | + fileType = "png"; | ||
| 252 | + fullPath = this.replacePathType(fullPath) + ".png"; | ||
| 253 | + break; | ||
| 254 | + default : | ||
| 255 | + //不做处理,直接返回拼接的地址 | ||
| 256 | + break; | ||
| 257 | + } | ||
| 258 | + | ||
| 259 | + if (_param.pageNum && parseInt(_param.pageNum) > 1) { | ||
| 260 | + //如果是多页的,需要返回序列 | ||
| 261 | + var lastIndex = fullPath.lastIndexOf("/"); | ||
| 262 | + if (lastIndex > 0) { | ||
| 263 | + let newPath = fullPath.substr(0, lastIndex); | ||
| 264 | + let pathArr = []; | ||
| 265 | + //页数从1开始 | ||
| 266 | + for (let i = 1; i <= _param.pageNum; i++) { | ||
| 267 | + pathArr.push(newPath + "/" + i + "." + fileType); | ||
| 268 | + } | ||
| 269 | + return pathArr; | ||
| 270 | + } else { | ||
| 271 | + return [fullPath]; | ||
| 272 | + } | ||
| 273 | + } else { | ||
| 274 | + return [fullPath]; | ||
| 275 | + }*/ | ||
| 276 | + } | ||
| 277 | + | ||
| 278 | + //获取文档的pdf完整地址 | ||
| 279 | + getDocPDFFullPath(_param) { | ||
| 280 | + return []; | ||
| 281 | + /* | ||
| 282 | + if (_param == null || _param.relativeUrl == null || _param.relativeUrl == "") { | ||
| 283 | + loger.warn('获取文档完整地址,传递的参数不对.', _param); | ||
| 284 | + return []; | ||
| 285 | + } | ||
| 286 | + let port = (GlobalConfig.DOCServerPort == "" || GlobalConfig.DOCServerPort == null) ? "" : ":" + GlobalConfig.DOCServerPort; | ||
| 287 | + let fullPath = GlobalConfig.DOCServerIP + port + _param.relativeUrl; | ||
| 288 | + if (fullPath && fullPath.indexOf("http://") < 0) { | ||
| 289 | + fullPath = "http://" + fullPath; | ||
| 290 | + } | ||
| 291 | + fullPath = this.replacePathType(fullPath) + ".pdf"; | ||
| 292 | + return [fullPath];*/ | ||
| 293 | + } | ||
| 294 | + | ||
| 295 | + // 去除文件的后缀格式名称 | ||
| 296 | + replacePathType(_path) { | ||
| 297 | + let path = _path; | ||
| 298 | + path = path.replace(/.jpg/g, ""); | ||
| 299 | + path = path.replace(/.png/g, ""); | ||
| 300 | + path = path.replace(/.swf/g, ""); | ||
| 301 | + path = path.replace(/.pdf/g, ""); | ||
| 302 | + return path; | ||
| 303 | + } | ||
| 304 | + | ||
| 305 | + //组织完整的文档信息,包含上传时的信息和转换后的完整地址信息 | ||
| 306 | + _docPackFullInfo(_itemDataInfo) { | ||
| 307 | + let itemDataInfo = _itemDataInfo; | ||
| 308 | + let getDocAddress = this.getDocFullAddress(_itemDataInfo); | ||
| 309 | + //loger.log('docPackFullInfo->', itemDataInfo); | ||
| 310 | + if (getDocAddress.code == ApeConsts.RETURN_SUCCESS) { | ||
| 311 | + itemDataInfo.images = getDocAddress.docFullAddress.images || []; | ||
| 312 | + itemDataInfo.pdf = getDocAddress.docFullAddress.pdf || ""; | ||
| 313 | + itemDataInfo.html = getDocAddress.docFullAddress.html || ""; | ||
| 314 | + } else { | ||
| 315 | + itemDataInfo.images = []; | ||
| 316 | + itemDataInfo.pdf = ''; | ||
| 317 | + itemDataInfo.html = ''; | ||
| 387 | } | 318 | } |
| 388 | 319 | ||
| 320 | + return itemDataInfo; | ||
| 321 | + } | ||
| 322 | + | ||
| 323 | + //更新文档模块的录制信息,每次开启录制的时候需要把当前文档的信息更新一次 | ||
| 324 | + updaterRecordApeStatus(_param) { | ||
| 325 | + /* if(GlobalConfig.isHost&&!GlobalConfig.isRecordPlayBack&&GlobalConfig.activeDocId>0){ | ||
| 326 | + loger.log("录制状态发送改变->更新当前的文档数据->docId:", GlobalConfig.activeDocId, 'page:',GlobalConfig.activeDocCurPage); | ||
| 327 | + this.documentSwitchPage({ | ||
| 328 | + "itemIdx": GlobalConfig.activeDocId, | ||
| 329 | + "curPageNo":GlobalConfig.activeDocCurPage | ||
| 330 | + }); | ||
| 331 | + }*/ | ||
| 332 | + loger.warn("录制状态发送改变->更新当前的文档数据->docId:", GlobalConfig.activeDocId, 'page:', GlobalConfig.activeDocCurPage); | ||
| 333 | + this.documentSwitchPage({ | ||
| 334 | + "itemIdx": GlobalConfig.activeDocId, | ||
| 335 | + "curPageNo": GlobalConfig.activeDocCurPage | ||
| 336 | + }); | ||
| 337 | + } | ||
| 338 | + | ||
| 339 | + //清除当前文档模块的数据 | ||
| 340 | + clearData() { | ||
| 341 | + loger.log("clearData->") | ||
| 342 | + this.docList = {}; | ||
| 343 | + GlobalConfig.activeDocId = 0; | ||
| 344 | + GlobalConfig.activeDocCurPage = 1; | ||
| 345 | + | ||
| 346 | + } | ||
| 347 | + | ||
| 348 | + //切换文档 | ||
| 349 | + documentSwitchDoc(paramInfo) { | ||
| 350 | + loger.log('切换文档->', paramInfo); | ||
| 351 | + if (GlobalConfig.isRecordPlayBack) { | ||
| 352 | + loger.warn('录制回放状态不允许切换文档'); | ||
| 353 | + return; | ||
| 354 | + } | ||
| 389 | 355 | ||
| 390 | - //文档翻页 | ||
| 391 | - documentSwitchPage(paramInfo) { | ||
| 392 | - loger.log('文档翻页->',paramInfo); | ||
| 393 | - //获取已经存在的数据 | ||
| 394 | - let docDataModel = this.docList[paramInfo.itemIdx]; | ||
| 395 | - //console.log(docDataModelPdu); | ||
| 396 | - //console.log(docDataModel); | ||
| 397 | - if (docDataModel == null) { | ||
| 398 | - loger.log('文档翻页->文档不存在', paramInfo); | ||
| 399 | - this._emit(MessageTypes.MCU_ERROR, MessageTypes.ERR_APE_INTERFACE_PARAM_WRONG); | ||
| 400 | - return; | ||
| 401 | - } | ||
| 402 | - //更新数据的字段 | ||
| 403 | - docDataModel.action = ApeConsts.DOC_ACTION_SWITCH_PAGE; | ||
| 404 | - docDataModel.curPageNo = parseInt(paramInfo.curPageNo) || 1; | ||
| 405 | - docDataModel.animationStep=1;//切换文档之后动画步数还原 | ||
| 406 | - if (docDataModel.curPageNo < 1) { | ||
| 407 | - docDataModel.curPageNo = 1;//默认值最小是1 | ||
| 408 | - } | ||
| 409 | - this.updaterDoc(docDataModel, docDataModel.itemIdx); | ||
| 410 | - } | ||
| 411 | - | ||
| 412 | - //文档动画切换 | ||
| 413 | - documentSwitchAnimation(paramInfo) { | ||
| 414 | - loger.log('文档页面动画切换->',paramInfo); | ||
| 415 | - //获取已经存在的数据 | ||
| 416 | - let docDataModel = this.docList[GlobalConfig.activeDocId]; | ||
| 417 | - if (docDataModel == null) { | ||
| 418 | - loger.log('文档页面动画切换->文档不存在',GlobalConfig.activeDocId, paramInfo); | ||
| 419 | - this._emit(MessageTypes.MCU_ERROR, MessageTypes.ERR_APE_INTERFACE_PARAM_WRONG); | ||
| 420 | - return; | ||
| 421 | - } | ||
| 422 | - //更新数据的字段 | ||
| 423 | - docDataModel.action = ApeConsts.DOC_ACTION_SWITCH_ANIMATION; | ||
| 424 | - docDataModel.animationStep=docDataModel.animationStep||1;//最少步骤是1 | ||
| 425 | - if(paramInfo&¶mInfo.step==-1){ | ||
| 426 | - //上一个 | ||
| 427 | - docDataModel.animationStep--; | ||
| 428 | - }else{ | ||
| 429 | - //下一个 | ||
| 430 | - docDataModel.animationStep++; | ||
| 431 | - } | ||
| 432 | - if (!docDataModel.animationStep||docDataModel.animationStep < 1) { | ||
| 433 | - docDataModel.animationStep = 1;//默认值最小是1 | ||
| 434 | - } | ||
| 435 | - this.updaterDoc(docDataModel, docDataModel.itemIdx); | ||
| 436 | - } | ||
| 437 | - | ||
| 438 | - //文档切换显示模式 | ||
| 439 | - documentSwitchShowModel(paramInfo) { | ||
| 440 | - loger.log('文档切换显示模式', paramInfo); | ||
| 441 | - //获取已经存在的数据 | ||
| 442 | - let docDataModel = this.docList[paramInfo.itemIdx]; | ||
| 443 | - if (docDataModel == null) { | ||
| 444 | - loger.log('文档切换显示模式->文档不存在', paramInfo); | ||
| 445 | - this._emit(MessageTypes.MCU_ERROR, MessageTypes.ERR_APE_INTERFACE_PARAM_WRONG); | ||
| 446 | - return; | ||
| 447 | - } | ||
| 448 | - //更新数据的字段 | ||
| 449 | - docDataModel.action = ApeConsts.DOC_ACTION_SWITCH_PAGE; | ||
| 450 | - docDataModel.curPageNo = parseInt(paramInfo.curPageNo) || 1; | ||
| 451 | - if (docDataModel.curPageNo < 1) { | ||
| 452 | - docDataModel.curPageNo = 1;//默认值最小是1 | ||
| 453 | - } | ||
| 454 | - this.updaterDoc(docDataModel, docDataModel.itemIdx); | 356 | + if (paramInfo == null || paramInfo.itemIdx == null) { |
| 357 | + loger.warn('切换文档失败,参数错误', paramInfo); | ||
| 358 | + this._emit(MessageTypes.MCU_ERROR, MessageTypes.ERR_APE_INTERFACE_PARAM_WRONG); | ||
| 359 | + return; | ||
| 455 | } | 360 | } |
| 456 | 361 | ||
| 457 | - //缩放/滚动/显示模式 | ||
| 458 | - documentCommand(paramInfo) { | ||
| 459 | - //获取已经存在的数据 | ||
| 460 | - let docDataModel = this.docList[paramInfo.itemIdx]; | ||
| 461 | - if (docDataModel == null) { | ||
| 462 | - loger.log('文档显示控制失败->文档不存在', paramInfo); | ||
| 463 | - this._emit(MessageTypes.MCU_ERROR, MessageTypes.ERR_APE_INTERFACE_PARAM_WRONG); | ||
| 464 | - return; | ||
| 465 | - } | ||
| 466 | - //更新数据的字段 | ||
| 467 | - docDataModel.action = ApeConsts.DOC_ACTION_COMMAND; | ||
| 468 | - docDataModel.showType = parseInt(paramInfo.showType) || 0;//0;//完整显示;1;//按宽度显示;2;//按高度显示 | ||
| 469 | - docDataModel.curV= parseInt(paramInfo.curV) || 0;//垂直方向的滚动条进度百分比 0-100 | ||
| 470 | - docDataModel.curH= parseInt(paramInfo.curH) || 0;//水平方向的滚动条进度百分比 0-100 | ||
| 471 | - docDataModel.scale= parseInt(paramInfo.scale) || 100;//文档缩放百分比 0-100 | ||
| 472 | - this.updaterDoc(docDataModel, docDataModel.itemIdx); | ||
| 473 | - } | ||
| 474 | - | ||
| 475 | - //删除所有文档 | ||
| 476 | - documentDeleteAll(_param) { | ||
| 477 | - for (let key in this.docList) { | ||
| 478 | - //console.log("key:"+key); | ||
| 479 | - loger.log("删除文档数据->itemIdx:" + key); | ||
| 480 | - this.documentDelete({"itemIdx": key}); | ||
| 481 | - } | 362 | + if (paramInfo.itemIdx == GlobalConfig.activeDocId && GlobalConfig.activeDocId != 0) { |
| 363 | + loger.warn('文档已经显示', paramInfo.itemIdx, GlobalConfig.activeDocId); | ||
| 364 | + return; | ||
| 482 | } | 365 | } |
| 483 | 366 | ||
| 484 | - //删除文档 | ||
| 485 | - documentDelete(paramInfo) { | ||
| 486 | - //{"itemIdx":itemIdx} | ||
| 487 | - let tableDeleteItemPdu = new pdu['RCRegistryTableDeleteItemPdu']; | ||
| 488 | - //optional RCPduType_E type = 1 [default = RCPDU_REG_TABLE_DELETE_PDU]; | ||
| 489 | - // repeated uint32 item_idx = 2; | ||
| 490 | - tableDeleteItemPdu.type = pdu.RCPDU_REG_TABLE_DELETE_PDU;// | ||
| 491 | - tableDeleteItemPdu.itemIdx = parseInt(paramInfo.itemIdx);//这里需要设置要删除的数据的itemIdx,每条数据的这个id都不一样 | 367 | + //更新切换之前的文档的数据,要显示当前切换的文档,上一个文档需要隐藏 |
| 368 | + let oldDocModel; | ||
| 369 | + if (GlobalConfig.activeDocId != 0) { | ||
| 370 | + oldDocModel = this.docList[GlobalConfig.activeDocId]; | ||
| 371 | + if (oldDocModel) { | ||
| 372 | + oldDocModel.action = ApeConsts.DOC_ACTION_NORMAL; | ||
| 373 | + oldDocModel.visible = false;//设置为不可见 | ||
| 374 | + oldDocModel.animationStep = 1;//切换文档之后动画步数还原 | ||
| 375 | + } | ||
| 376 | + } | ||
| 492 | 377 | ||
| 493 | - let updateObjPdu = new pdu['RCRegistryUpdateObjPdu']; | ||
| 494 | - updateObjPdu.objId = ApeConsts.DOCSHARING_OBJ_TABLE_ID;// updateObjPdu.objId = ApeConsts.DOCSHARING_OBJ_TABLE_ID_H5; | ||
| 495 | - updateObjPdu.subType = tableDeleteItemPdu.type; | ||
| 496 | - updateObjPdu.userData = tableDeleteItemPdu.toArrayBuffer(); | 378 | + //获取已经存在的数据 |
| 379 | + let docDataModel = this.docList[paramInfo.itemIdx]; | ||
| 380 | + if (docDataModel == null) { | ||
| 381 | + loger.warn('切换文档失败,文档不存在', paramInfo); | ||
| 382 | + this._emit(MessageTypes.MCU_ERROR, MessageTypes.ERR_APE_INTERFACE_PARAM_WRONG); | ||
| 383 | + return; | ||
| 384 | + } | ||
| 497 | 385 | ||
| 498 | - //同步 | ||
| 499 | - let adapterItemPdu = new pdu['RCAdapterItemPdu']; | ||
| 500 | - adapterItemPdu.type = pdu.RCPDU_REG_UPDATE_OBJ; | ||
| 501 | - adapterItemPdu.itemData = updateObjPdu.toArrayBuffer(); | 386 | + //更新当前选择的文档数据的字段 |
| 387 | + docDataModel.action = ApeConsts.DOC_ACTION_SWITCH_DOC; | ||
| 388 | + docDataModel.visible = paramInfo.visible || false;//默认是false | ||
| 389 | + docDataModel.animationStep = 1;//切换文档之后动画步数还原 | ||
| 502 | 390 | ||
| 503 | - let adapterPdu = new pdu['RCAdapterPdu']; | ||
| 504 | - adapterPdu.type = pdu.RCPDU_REG_ADAPTER; | ||
| 505 | - adapterPdu.item.push(adapterItemPdu); | 391 | + //loger.log('切换文档,当前文档和上一个显示的文档都需要更新状态'); |
| 392 | + loger.log({"oldDoc": oldDocModel, "nowDoc": docDataModel}); | ||
| 393 | + //更新当前选择的文档 | ||
| 394 | + this.updaterDoc(docDataModel, docDataModel.itemIdx); | ||
| 506 | 395 | ||
| 507 | - loger.log("文档发送删除数据=============>" + tableDeleteItemPdu.itemIdx); | ||
| 508 | - this.sendUniform(adapterPdu, true); | 396 | + //更新上一个文档 隐藏 |
| 397 | + if (oldDocModel) { | ||
| 398 | + this.updaterDoc(oldDocModel, oldDocModel.itemIdx); | ||
| 509 | } | 399 | } |
| 510 | - | ||
| 511 | - /////收到消息处理///////////////////////////////////////////////////////////////////////////////// | ||
| 512 | - tableInsertHandler(owner, itemIdx, itemData) { | ||
| 513 | - /* let itemDataInfo = this.unPackPdu(owner, itemIdx, itemData); | ||
| 514 | - this.docList[itemIdx] = itemDataInfo; | ||
| 515 | - | ||
| 516 | - if (itemDataInfo.visible == "true" || itemDataInfo.visible == true) { | 400 | + } |
| 401 | + | ||
| 402 | + | ||
| 403 | + //文档翻页 | ||
| 404 | + documentSwitchPage(paramInfo) { | ||
| 405 | + loger.log('文档翻页->', paramInfo); | ||
| 406 | + //获取已经存在的数据 | ||
| 407 | + let docDataModel = this.docList[paramInfo.itemIdx]; | ||
| 408 | + //console.log(docDataModelPdu); | ||
| 409 | + //console.log(docDataModel); | ||
| 410 | + if (docDataModel == null) { | ||
| 411 | + loger.log('文档翻页->文档不存在', paramInfo); | ||
| 412 | + this._emit(MessageTypes.MCU_ERROR, MessageTypes.ERR_APE_INTERFACE_PARAM_WRONG); | ||
| 413 | + return; | ||
| 414 | + } | ||
| 415 | + //更新数据的字段 | ||
| 416 | + docDataModel.action = ApeConsts.DOC_ACTION_SWITCH_PAGE; | ||
| 417 | + docDataModel.curPageNo = parseInt(paramInfo.curPageNo) || 1; | ||
| 418 | + docDataModel.animationStep = 1;//切换文档之后动画步数还原 | ||
| 419 | + if (docDataModel.curPageNo < 1) { | ||
| 420 | + docDataModel.curPageNo = 1;//默认值最小是1 | ||
| 421 | + } | ||
| 422 | + this.updaterDoc(docDataModel, docDataModel.itemIdx); | ||
| 423 | + } | ||
| 424 | + | ||
| 425 | + //文档动画切换 | ||
| 426 | + documentSwitchAnimation(paramInfo) { | ||
| 427 | + loger.log('文档页面动画切换->', paramInfo); | ||
| 428 | + //获取已经存在的数据 | ||
| 429 | + let docDataModel = this.docList[GlobalConfig.activeDocId]; | ||
| 430 | + if (docDataModel == null) { | ||
| 431 | + loger.log('文档页面动画切换->文档不存在', GlobalConfig.activeDocId, paramInfo); | ||
| 432 | + this._emit(MessageTypes.MCU_ERROR, MessageTypes.ERR_APE_INTERFACE_PARAM_WRONG); | ||
| 433 | + return; | ||
| 434 | + } | ||
| 435 | + //更新数据的字段 | ||
| 436 | + docDataModel.action = ApeConsts.DOC_ACTION_SWITCH_ANIMATION; | ||
| 437 | + docDataModel.animationStep = docDataModel.animationStep || 1;//最少步骤是1 | ||
| 438 | + if (paramInfo && paramInfo.step == -1) { | ||
| 439 | + //上一个 | ||
| 440 | + docDataModel.animationStep--; | ||
| 441 | + } else { | ||
| 442 | + //下一个 | ||
| 443 | + docDataModel.animationStep++; | ||
| 444 | + } | ||
| 445 | + if (!docDataModel.animationStep || docDataModel.animationStep < 1) { | ||
| 446 | + docDataModel.animationStep = 1;//默认值最小是1 | ||
| 447 | + } | ||
| 448 | + this.updaterDoc(docDataModel, docDataModel.itemIdx); | ||
| 449 | + } | ||
| 450 | + | ||
| 451 | + //文档切换显示模式 | ||
| 452 | + documentSwitchShowModel(paramInfo) { | ||
| 453 | + loger.log('文档切换显示模式', paramInfo); | ||
| 454 | + //获取已经存在的数据 | ||
| 455 | + let docDataModel = this.docList[paramInfo.itemIdx]; | ||
| 456 | + if (docDataModel == null) { | ||
| 457 | + loger.log('文档切换显示模式->文档不存在', paramInfo); | ||
| 458 | + this._emit(MessageTypes.MCU_ERROR, MessageTypes.ERR_APE_INTERFACE_PARAM_WRONG); | ||
| 459 | + return; | ||
| 460 | + } | ||
| 461 | + //更新数据的字段 | ||
| 462 | + docDataModel.action = ApeConsts.DOC_ACTION_SWITCH_PAGE; | ||
| 463 | + docDataModel.curPageNo = parseInt(paramInfo.curPageNo) || 1; | ||
| 464 | + if (docDataModel.curPageNo < 1) { | ||
| 465 | + docDataModel.curPageNo = 1;//默认值最小是1 | ||
| 466 | + } | ||
| 467 | + this.updaterDoc(docDataModel, docDataModel.itemIdx); | ||
| 468 | + } | ||
| 469 | + | ||
| 470 | + //缩放/滚动/显示模式 | ||
| 471 | + documentCommand(paramInfo) { | ||
| 472 | + //获取已经存在的数据 | ||
| 473 | + let docDataModel = this.docList[paramInfo.itemIdx]; | ||
| 474 | + if (docDataModel == null) { | ||
| 475 | + loger.log('文档显示控制失败->文档不存在', paramInfo); | ||
| 476 | + this._emit(MessageTypes.MCU_ERROR, MessageTypes.ERR_APE_INTERFACE_PARAM_WRONG); | ||
| 477 | + return; | ||
| 478 | + } | ||
| 479 | + //更新数据的字段 | ||
| 480 | + docDataModel.action = ApeConsts.DOC_ACTION_COMMAND; | ||
| 481 | + docDataModel.showType = parseInt(paramInfo.showType) || 0;//0;//完整显示;1;//按宽度显示;2;//按高度显示 | ||
| 482 | + docDataModel.curV = parseInt(paramInfo.curV) || 0;//垂直方向的滚动条进度百分比 0-100 | ||
| 483 | + docDataModel.curH = parseInt(paramInfo.curH) || 0;//水平方向的滚动条进度百分比 0-100 | ||
| 484 | + docDataModel.scale = parseInt(paramInfo.scale) || 100;//文档缩放百分比 0-100 | ||
| 485 | + this.updaterDoc(docDataModel, docDataModel.itemIdx); | ||
| 486 | + } | ||
| 487 | + | ||
| 488 | + //删除所有文档 | ||
| 489 | + documentDeleteAll(_param) { | ||
| 490 | + for (let key in this.docList) { | ||
| 491 | + //console.log("key:"+key); | ||
| 492 | + loger.log("删除文档数据->itemIdx:" + key); | ||
| 493 | + this.documentDelete({"itemIdx": key}); | ||
| 494 | + } | ||
| 495 | + } | ||
| 496 | + | ||
| 497 | + //删除文档 | ||
| 498 | + documentDelete(paramInfo) { | ||
| 499 | + //{"itemIdx":itemIdx} | ||
| 500 | + let tableDeleteItemPdu = new pdu['RCRegistryTableDeleteItemPdu']; | ||
| 501 | + //optional RCPduType_E type = 1 [default = RCPDU_REG_TABLE_DELETE_PDU]; | ||
| 502 | + // repeated uint32 item_idx = 2; | ||
| 503 | + tableDeleteItemPdu.type = pdu.RCPDU_REG_TABLE_DELETE_PDU;// | ||
| 504 | + tableDeleteItemPdu.itemIdx = parseInt(paramInfo.itemIdx);//这里需要设置要删除的数据的itemIdx,每条数据的这个id都不一样 | ||
| 505 | + | ||
| 506 | + let updateObjPdu = new pdu['RCRegistryUpdateObjPdu']; | ||
| 507 | + updateObjPdu.objId = ApeConsts.DOCSHARING_OBJ_TABLE_ID;// updateObjPdu.objId = ApeConsts.DOCSHARING_OBJ_TABLE_ID_H5; | ||
| 508 | + updateObjPdu.subType = tableDeleteItemPdu.type; | ||
| 509 | + updateObjPdu.userData = tableDeleteItemPdu.toArrayBuffer(); | ||
| 510 | + | ||
| 511 | + //同步 | ||
| 512 | + let adapterItemPdu = new pdu['RCAdapterItemPdu']; | ||
| 513 | + adapterItemPdu.type = pdu.RCPDU_REG_UPDATE_OBJ; | ||
| 514 | + adapterItemPdu.itemData = updateObjPdu.toArrayBuffer(); | ||
| 515 | + | ||
| 516 | + let adapterPdu = new pdu['RCAdapterPdu']; | ||
| 517 | + adapterPdu.type = pdu.RCPDU_REG_ADAPTER; | ||
| 518 | + adapterPdu.item.push(adapterItemPdu); | ||
| 519 | + | ||
| 520 | + loger.log("文档发送删除数据=============>" + tableDeleteItemPdu.itemIdx); | ||
| 521 | + this.sendUniform(adapterPdu, true); | ||
| 522 | + } | ||
| 523 | + | ||
| 524 | + /////收到消息处理///////////////////////////////////////////////////////////////////////////////// | ||
| 525 | + tableInsertHandler(owner, itemIdx, itemData) { | ||
| 526 | + /* let itemDataInfo = this.unPackPdu(owner, itemIdx, itemData); | ||
| 527 | + this.docList[itemIdx] = itemDataInfo; | ||
| 528 | + | ||
| 529 | + if (itemDataInfo.visible == "true" || itemDataInfo.visible == true) { | ||
| 530 | + GlobalConfig.activeDocId = itemDataInfo.itemIdx;//当前激活的文档ID | ||
| 531 | + GlobalConfig.activeDocCurPage = itemDataInfo.curPageNo;//当前激活的文档的当前页 | ||
| 532 | + loger.log('tableInsertHandler 设置当前激活的文档id'); | ||
| 533 | + } | ||
| 534 | + loger.log('tableInsertHandler->', itemDataInfo); | ||
| 535 | + this._emit(MessageTypes.DOC_UPDATE, itemDataInfo);//用添加和更新都统一DOC_UPDATE | ||
| 536 | + | ||
| 537 | + //文档数据更新完毕,如果当前没有显示的文档,默认选择一个显示 | ||
| 538 | + if (GlobalConfig.activeDocId < 1 && itemDataInfo) { | ||
| 539 | + let paramInfo = { | ||
| 540 | + "itemIdx": itemDataInfo.itemIdx, | ||
| 541 | + "visible": true | ||
| 542 | + }; | ||
| 543 | + this.documentSwitchDoc(paramInfo); | ||
| 544 | + }*/ | ||
| 545 | + } | ||
| 546 | + | ||
| 547 | + //添加文档 | ||
| 548 | + tableInsertApeHandler(_tableUpdateItems, _seekTime) { | ||
| 549 | + let tableInsertItems = _tableUpdateItems; | ||
| 550 | + let tableInsertItemsLen = tableInsertItems.length; | ||
| 551 | + loger.log('添加文档->', "activeDocId->", GlobalConfig.activeDocId, "tableUpdateItemsLen->", tableInsertItemsLen); | ||
| 552 | + for (let i = 0; i < tableInsertItemsLen; ++i) { | ||
| 553 | + let insertItem = tableInsertItems[i]; | ||
| 554 | + if (insertItem) { | ||
| 555 | + //this.tableInsertHandler(insertItem.owner, insertItem.itemIdx, insertItem.itemData); | ||
| 556 | + let itemDataInfo = this.unPackPdu(insertItem.owner, insertItem.itemIdx, insertItem.itemData); | ||
| 557 | + if (itemDataInfo) { | ||
| 558 | + this.docList[insertItem.itemIdx] = itemDataInfo; | ||
| 559 | + if (itemDataInfo.visible == "true" || itemDataInfo.visible == true) { | ||
| 517 | GlobalConfig.activeDocId = itemDataInfo.itemIdx;//当前激活的文档ID | 560 | GlobalConfig.activeDocId = itemDataInfo.itemIdx;//当前激活的文档ID |
| 518 | GlobalConfig.activeDocCurPage = itemDataInfo.curPageNo;//当前激活的文档的当前页 | 561 | GlobalConfig.activeDocCurPage = itemDataInfo.curPageNo;//当前激活的文档的当前页 |
| 519 | - loger.log('tableInsertHandler 设置当前激活的文档id'); | ||
| 520 | - } | ||
| 521 | - loger.log('tableInsertHandler->', itemDataInfo); | ||
| 522 | - this._emit(MessageTypes.DOC_UPDATE, itemDataInfo);//用添加和更新都统一DOC_UPDATE | ||
| 523 | - | ||
| 524 | - //文档数据更新完毕,如果当前没有显示的文档,默认选择一个显示 | ||
| 525 | - if (GlobalConfig.activeDocId < 1 && itemDataInfo) { | ||
| 526 | - let paramInfo = { | ||
| 527 | - "itemIdx": itemDataInfo.itemIdx, | ||
| 528 | - "visible": true | ||
| 529 | - }; | ||
| 530 | - this.documentSwitchDoc(paramInfo); | ||
| 531 | - }*/ | ||
| 532 | - } | ||
| 533 | - //添加文档 | ||
| 534 | - tableInsertApeHandler(_tableUpdateItems, _seekTime) { | ||
| 535 | - let tableInsertItems =_tableUpdateItems; | ||
| 536 | - let tableInsertItemsLen = tableInsertItems.length; | ||
| 537 | - loger.log('添加文档->', "activeDocId->", GlobalConfig.activeDocId, "tableUpdateItemsLen->", tableInsertItemsLen); | ||
| 538 | - for (let i = 0; i < tableInsertItemsLen; ++i) { | ||
| 539 | - let insertItem = tableInsertItems[i]; | ||
| 540 | - if(insertItem){ | ||
| 541 | - //this.tableInsertHandler(insertItem.owner, insertItem.itemIdx, insertItem.itemData); | ||
| 542 | - let itemDataInfo = this.unPackPdu(insertItem.owner, insertItem.itemIdx, insertItem.itemData); | ||
| 543 | - if(itemDataInfo){ | ||
| 544 | - this.docList[insertItem.itemIdx] = itemDataInfo; | ||
| 545 | - if (itemDataInfo.visible == "true" || itemDataInfo.visible == true) { | ||
| 546 | - GlobalConfig.activeDocId = itemDataInfo.itemIdx;//当前激活的文档ID | ||
| 547 | - GlobalConfig.activeDocCurPage = itemDataInfo.curPageNo;//当前激活的文档的当前页 | ||
| 548 | - //loger.log('添加文档->设置当前激活的文档id'); | ||
| 549 | - } | ||
| 550 | - let getdocPackFullInfo= this._docPackFullInfo(itemDataInfo); | ||
| 551 | - loger.log('添加文档->',getdocPackFullInfo); | ||
| 552 | - this._emit(MessageTypes.DOC_UPDATE, getdocPackFullInfo);//用添加和更新都统一DOC_UPDATE | ||
| 553 | - }else{ | ||
| 554 | - loger.warn('文档数据解析失败->删除->itemIdx:'+insertItem.itemIdx); | ||
| 555 | - this.documentDelete({"itemIdx": insertItem.itemIdx}); | ||
| 556 | - } | 562 | + //loger.log('添加文档->设置当前激活的文档id'); |
| 557 | } | 563 | } |
| 564 | + let getdocPackFullInfo = this._docPackFullInfo(itemDataInfo); | ||
| 565 | + loger.log('添加文档->', getdocPackFullInfo); | ||
| 566 | + this._emit(MessageTypes.DOC_UPDATE, getdocPackFullInfo);//用添加和更新都统一DOC_UPDATE | ||
| 567 | + } else { | ||
| 568 | + loger.warn('文档数据解析失败->删除->itemIdx:' + insertItem.itemIdx); | ||
| 569 | + this.documentDelete({"itemIdx": insertItem.itemIdx}); | ||
| 558 | } | 570 | } |
| 559 | - //文档数据更新完毕,如果当前没有显示的文档,默认选择一个显示 | ||
| 560 | - this._showDefaultDoc(); | ||
| 561 | - } | ||
| 562 | - tableDeleteHandler(object_id, tableDeleteData) { | ||
| 563 | - loger.log('删除文档数据->', object_id, tableDeleteData);//["tableDeleteHandler",1179649,{"type":231,"itemIdx":[1486301768]}] | ||
| 564 | - if (tableDeleteData && tableDeleteData.itemIdx) { | ||
| 565 | - let len = tableDeleteData.itemIdx.length; | ||
| 566 | - let itemIdxs = tableDeleteData.itemIdx; | ||
| 567 | - for (let i = 0; i < len; i++) { | ||
| 568 | - if (this.docList[itemIdxs[i]]) { | ||
| 569 | - loger.log("删除文档数据:", itemIdxs[i]); | ||
| 570 | - //this._emit(MessageTypes.DOC_DELETE, {"itemIdx": itemIdxs[i]}); | ||
| 571 | - let itemDataInfo = this.docList[itemIdxs[i]]; | ||
| 572 | - if (itemDataInfo && (itemDataInfo.visible == "true" || itemDataInfo.visible == true)) { | ||
| 573 | - GlobalConfig.activeDocId = 0;//当前激活的文档ID | ||
| 574 | - GlobalConfig.activeDocCurPage = 1;//当前激活的文档的当前页 | ||
| 575 | - loger.log('删除文档数据->清除当前显示的文档'); | ||
| 576 | - } | ||
| 577 | - this._emit(MessageTypes.DOC_DELETE, {"itemIdx": itemIdxs[i]}); | ||
| 578 | - delete this.docList[itemIdxs[i]]; | ||
| 579 | - } | ||
| 580 | - } | ||
| 581 | - } | 571 | + } |
| 582 | } | 572 | } |
| 583 | - | ||
| 584 | - tableUpdateHandler(owner, itemIdx, itemData) { | ||
| 585 | - //这个方法废弃,更新用tableUpdateApeHandler方法 | ||
| 586 | - /* let itemDataInfo = this.unPackPdu(owner, itemIdx, itemData); | ||
| 587 | - if(itemDataInfo!=null){ | ||
| 588 | - this.docList[itemIdx] = itemDataInfo; | ||
| 589 | - if(itemDataInfo&&(itemDataInfo.visible=="true"||itemDataInfo.visible==true)){ | ||
| 590 | - GlobalConfig.activeDocId=itemDataInfo.itemIdx;//当前激活的文档ID | ||
| 591 | - GlobalConfig.activeDocCurPage=itemDataInfo.curPageNo;//当前激活的文档的当前页 | ||
| 592 | - loger.log('tableUpdateHandler 设置当前激活的文档id'); | ||
| 593 | - } | ||
| 594 | - loger.log('tableUpdateHandler 发送给客户端'); | ||
| 595 | - loger.log(itemDataInfo); | ||
| 596 | - this._emit(MessageTypes.DOC_UPDATE,itemDataInfo); | ||
| 597 | - | ||
| 598 | - }else { | ||
| 599 | - loger.log('tableUpdateHandler 数据无效--> itemIdx',itemIdx); | ||
| 600 | - }*/ | ||
| 601 | - } | ||
| 602 | - | ||
| 603 | - tableUpdateApeHandler(_tableUpdateItems, _seekTime) { | ||
| 604 | - let tableUpdateItemsLen = _tableUpdateItems.length; | ||
| 605 | - //loger.log('更新文档->', "activeDocId->", GlobalConfig.activeDocId, "更新的数量->", tableUpdateItemsLen); | ||
| 606 | - for (let i = 0; i < tableUpdateItemsLen; ++i) { | ||
| 607 | - let tableItem = _tableUpdateItems[i]; | ||
| 608 | - if(tableItem) { | ||
| 609 | - let itemDataInfo = this.unPackPdu(tableItem.owner, tableItem.itemIdx, tableItem.itemData); | ||
| 610 | - if (itemDataInfo) { | ||
| 611 | - this.docList[tableItem.itemIdx] = itemDataInfo; | ||
| 612 | - if (itemDataInfo && (itemDataInfo.visible == "true" || itemDataInfo.visible == true)) { | ||
| 613 | - GlobalConfig.activeDocId = itemDataInfo.itemIdx;//当前激活的文档ID | ||
| 614 | - GlobalConfig.activeDocCurPage = itemDataInfo.curPageNo;//当前激活的文档的当前页 | ||
| 615 | - loger.log('更新文档->设置当前激活的文档id->', GlobalConfig.activeDocId, "curPageNum->", GlobalConfig.activeDocCurPage); | ||
| 616 | - } | ||
| 617 | - let getdocPackFullInfo= this._docPackFullInfo(itemDataInfo); | ||
| 618 | - this._emit(MessageTypes.DOC_UPDATE, getdocPackFullInfo); | ||
| 619 | - } else { | ||
| 620 | - loger.warn('文档数据解析失败->删除->itemIdx:'+tableItem.itemIdx); | ||
| 621 | - this.documentDelete({"itemIdx": tableItem.itemIdx}); | ||
| 622 | - } | 573 | + //文档数据更新完毕,如果当前没有显示的文档,默认选择一个显示 |
| 574 | + this._showDefaultDoc(); | ||
| 575 | + } | ||
| 576 | + | ||
| 577 | + tableDeleteHandler(object_id, tableDeleteData) { | ||
| 578 | + loger.log('删除文档数据->', object_id, tableDeleteData);//["tableDeleteHandler",1179649,{"type":231,"itemIdx":[1486301768]}] | ||
| 579 | + if (tableDeleteData && tableDeleteData.itemIdx) { | ||
| 580 | + let len = tableDeleteData.itemIdx.length; | ||
| 581 | + let itemIdxs = tableDeleteData.itemIdx; | ||
| 582 | + for (let i = 0; i < len; i++) { | ||
| 583 | + if (this.docList[itemIdxs[i]]) { | ||
| 584 | + loger.log("删除文档数据:", itemIdxs[i]); | ||
| 585 | + //this._emit(MessageTypes.DOC_DELETE, {"itemIdx": itemIdxs[i]}); | ||
| 586 | + let itemDataInfo = this.docList[itemIdxs[i]]; | ||
| 587 | + if (itemDataInfo && (itemDataInfo.visible == "true" || itemDataInfo.visible == true)) { | ||
| 588 | + GlobalConfig.activeDocId = 0;//当前激活的文档ID | ||
| 589 | + GlobalConfig.activeDocCurPage = 1;//当前激活的文档的当前页 | ||
| 590 | + loger.log('删除文档数据->清除当前显示的文档'); | ||
| 623 | } | 591 | } |
| 592 | + this._emit(MessageTypes.DOC_DELETE, {"itemIdx": itemIdxs[i]}); | ||
| 593 | + delete this.docList[itemIdxs[i]]; | ||
| 624 | } | 594 | } |
| 625 | - this._showDefaultDoc(); | 595 | + } |
| 626 | } | 596 | } |
| 627 | - | ||
| 628 | - //果当前没有显示的文档,默认选择一个显示文档 | ||
| 629 | - _showDefaultDoc() { | ||
| 630 | - /*//显示默认文档条件->1.非录制回放状态下 2.只有host有权限操作 3.当前激活的文档id不为0 | ||
| 631 | - if (GlobalConfig.isRecordPlayBack || !GlobalConfig.isHost || GlobalConfig.activeDocId > 0) { | ||
| 632 | - return; | 597 | + } |
| 598 | + | ||
| 599 | + tableUpdateHandler(owner, itemIdx, itemData) { | ||
| 600 | + //这个方法废弃,更新用tableUpdateApeHandler方法 | ||
| 601 | + /* let itemDataInfo = this.unPackPdu(owner, itemIdx, itemData); | ||
| 602 | + if(itemDataInfo!=null){ | ||
| 603 | + this.docList[itemIdx] = itemDataInfo; | ||
| 604 | + if(itemDataInfo&&(itemDataInfo.visible=="true"||itemDataInfo.visible==true)){ | ||
| 605 | + GlobalConfig.activeDocId=itemDataInfo.itemIdx;//当前激活的文档ID | ||
| 606 | + GlobalConfig.activeDocCurPage=itemDataInfo.curPageNo;//当前激活的文档的当前页 | ||
| 607 | + loger.log('tableUpdateHandler 设置当前激活的文档id'); | ||
| 608 | + } | ||
| 609 | + loger.log('tableUpdateHandler 发送给客户端'); | ||
| 610 | + loger.log(itemDataInfo); | ||
| 611 | + this._emit(MessageTypes.DOC_UPDATE,itemDataInfo); | ||
| 612 | + | ||
| 613 | + }else { | ||
| 614 | + loger.log('tableUpdateHandler 数据无效--> itemIdx',itemIdx); | ||
| 615 | + }*/ | ||
| 616 | + } | ||
| 617 | + | ||
| 618 | + tableUpdateApeHandler(_tableUpdateItems, _seekTime) { | ||
| 619 | + let tableUpdateItemsLen = _tableUpdateItems.length; | ||
| 620 | + //loger.log('更新文档->', "activeDocId->", GlobalConfig.activeDocId, "更新的数量->", tableUpdateItemsLen); | ||
| 621 | + for (let i = 0; i < tableUpdateItemsLen; ++i) { | ||
| 622 | + let tableItem = _tableUpdateItems[i]; | ||
| 623 | + if (tableItem) { | ||
| 624 | + let itemDataInfo = this.unPackPdu(tableItem.owner, tableItem.itemIdx, tableItem.itemData); | ||
| 625 | + if (itemDataInfo) { | ||
| 626 | + this.docList[tableItem.itemIdx] = itemDataInfo; | ||
| 627 | + if (itemDataInfo && (itemDataInfo.visible == "true" || itemDataInfo.visible == true)) { | ||
| 628 | + GlobalConfig.activeDocId = itemDataInfo.itemIdx;//当前激活的文档ID | ||
| 629 | + GlobalConfig.activeDocCurPage = itemDataInfo.curPageNo;//当前激活的文档的当前页 | ||
| 630 | + loger.log('更新文档->设置当前激活的文档id->', GlobalConfig.activeDocId, "curPageNum->", GlobalConfig.activeDocCurPage); | ||
| 631 | + } | ||
| 632 | + let getdocPackFullInfo = this._docPackFullInfo(itemDataInfo); | ||
| 633 | + this._emit(MessageTypes.DOC_UPDATE, getdocPackFullInfo); | ||
| 634 | + } else { | ||
| 635 | + loger.warn('文档数据解析失败->删除->itemIdx:' + tableItem.itemIdx); | ||
| 636 | + this.documentDelete({"itemIdx": tableItem.itemIdx}); | ||
| 633 | } | 637 | } |
| 634 | - */ | ||
| 635 | - //非录制回放状态下和当前激活的文档id不为0的时候也不能操作 | ||
| 636 | - if (GlobalConfig.isRecordPlayBack || GlobalConfig.activeDocId > 0) { | ||
| 637 | - return; | ||
| 638 | } | 638 | } |
| 639 | - //如果自己不是老师,并且当前课堂内人数大于1,不能操作 | ||
| 640 | - if(!GlobalConfig.isHost&&GlobalConfig.rosterNumber>1){ | 639 | + } |
| 640 | + this._showDefaultDoc(); | ||
| 641 | + } | ||
| 642 | + | ||
| 643 | + //果当前没有显示的文档,默认选择一个显示文档 | ||
| 644 | + _showDefaultDoc() { | ||
| 645 | + /*//显示默认文档条件->1.非录制回放状态下 2.只有host有权限操作 3.当前激活的文档id不为0 | ||
| 646 | + if (GlobalConfig.isRecordPlayBack || !GlobalConfig.isHost || GlobalConfig.activeDocId > 0) { | ||
| 647 | + return; | ||
| 648 | + } | ||
| 649 | + */ | ||
| 650 | + //非录制回放状态下和当前激活的文档id不为0的时候也不能操作 | ||
| 651 | + if (GlobalConfig.isRecordPlayBack || GlobalConfig.activeDocId > 0) { | ||
| 652 | + return; | ||
| 653 | + } | ||
| 654 | + //如果自己不是老师,并且当前课堂内人数大于1,不能操作 | ||
| 655 | + if (!GlobalConfig.isHost && GlobalConfig.rosterNumber > 1) { | ||
| 656 | + return; | ||
| 657 | + } | ||
| 658 | + | ||
| 659 | + let tempDocItemIdx;//临时记录文档数据,用于显示默认文档 | ||
| 660 | + for (let key in this.docList) { | ||
| 661 | + tempDocItemIdx = this.docList[key]; | ||
| 662 | + if (tempDocItemIdx) { | ||
| 663 | + loger.log("选择一个文档作为默认文档显示->", tempDocItemIdx); | ||
| 664 | + let paramInfo = { | ||
| 665 | + "itemIdx": tempDocItemIdx.itemIdx, | ||
| 666 | + "visible": true | ||
| 667 | + }; | ||
| 668 | + this.documentSwitchDoc(paramInfo); | ||
| 669 | + //选择完成就跳出循环 | ||
| 641 | return; | 670 | return; |
| 642 | } | 671 | } |
| 643 | - | ||
| 644 | - let tempDocItemIdx;//临时记录文档数据,用于显示默认文档 | ||
| 645 | - for (let key in this.docList) { | ||
| 646 | - tempDocItemIdx= this.docList[key]; | ||
| 647 | - if (tempDocItemIdx) { | ||
| 648 | - loger.log("选择一个文档作为默认文档显示->", tempDocItemIdx); | ||
| 649 | - let paramInfo = { | ||
| 650 | - "itemIdx": tempDocItemIdx.itemIdx, | ||
| 651 | - "visible": true | ||
| 652 | - }; | ||
| 653 | - this.documentSwitchDoc(paramInfo); | ||
| 654 | - //选择完成就跳出循环 | ||
| 655 | - return; | ||
| 656 | - } | ||
| 657 | - } | ||
| 658 | } | 672 | } |
| 659 | - | ||
| 660 | - onJoinChannelHandlerSuccess() { | ||
| 661 | - loger.log(this._session_name + ' onJoinChannelHandlerSuccess==========================='); | ||
| 662 | - if (this._apeDelayed) { | ||
| 663 | - // this._apeDelayedMsgs.push(regBuffer); | ||
| 664 | - // this._apeDelayedStart(); | ||
| 665 | - setTimeout(() => { | ||
| 666 | - this._emit(DocApe.DOC_JOIN_CHANNEL_SUCCESS); | ||
| 667 | - }, (GlobalConfig.mcuDelay + GlobalConfig.docDelay) || 12000 + GlobalConfig.docDelay); | ||
| 668 | - } else { | ||
| 669 | - setTimeout(() => { | ||
| 670 | - this._emit(DocApe.DOC_JOIN_CHANNEL_SUCCESS); | ||
| 671 | - }, GlobalConfig.docDelay); | ||
| 672 | - } | 673 | + } |
| 674 | + | ||
| 675 | + onJoinChannelHandlerSuccess() { | ||
| 676 | + loger.log(this._session_name + ' onJoinChannelHandlerSuccess==========================='); | ||
| 677 | + if (this._apeDelayed) { | ||
| 678 | + // this._apeDelayedMsgs.push(regBuffer); | ||
| 679 | + // this._apeDelayedStart(); | ||
| 680 | + setTimeout(() => { | ||
| 681 | + this._emit(DocApe.DOC_JOIN_CHANNEL_SUCCESS); | ||
| 682 | + }, (GlobalConfig.mcuDelay + GlobalConfig.docDelay) || 12000 + GlobalConfig.docDelay); | ||
| 683 | + } else { | ||
| 684 | + setTimeout(() => { | ||
| 685 | + this._emit(DocApe.DOC_JOIN_CHANNEL_SUCCESS); | ||
| 686 | + }, GlobalConfig.docDelay); | ||
| 673 | } | 687 | } |
| 688 | + } | ||
| 674 | 689 | ||
| 675 | - //检查文档是否已经存在,如果存在 返回true,否则返回false | ||
| 676 | - checkDocId(_docId) { | ||
| 677 | - if (_docId == null) { | ||
| 678 | - loger.warn('查找文档->失败->参数为null'); | ||
| 679 | - return true; | ||
| 680 | - } | ||
| 681 | - //遍历查找 | ||
| 682 | - for (let key in this.docList) { | ||
| 683 | - let item = this.docList[key]; | ||
| 684 | - if (item && item.docId == _docId) { | ||
| 685 | - //loger.log('查找文档->已经存在->',_docId); | ||
| 686 | - return true; | ||
| 687 | - } | ||
| 688 | - } | ||
| 689 | - loger.log('查找文档->没有查找到文档->',_docId); | ||
| 690 | - //储存的数据中没有查找到 | ||
| 691 | - return false; | ||
| 692 | - } | ||
| 693 | - | ||
| 694 | - ///////数据的封包和解包///////////////////////////////////////// | ||
| 695 | - packPdu(_param, _itemIdx) { | ||
| 696 | - //loger.log("文档->packPdu"); | ||
| 697 | - //验证坐标点集合数组是否合法 | ||
| 698 | - if (_param == null || _itemIdx == null) { | ||
| 699 | - this._emit(MessageTypes.MCU_ERROR, MessageTypes.ERR_APE_INTERFACE_PARAM_WRONG); | ||
| 700 | - return null; | ||
| 701 | - } | ||
| 702 | - //判断type类型,根据type设置不同的参数 | ||
| 703 | - let docModelPdu = new pdu['RCDocSendDataModelPdu']; | ||
| 704 | - docModelPdu.itemIdx = _itemIdx; | ||
| 705 | - docModelPdu.owner = GlobalConfig.nodeId; | ||
| 706 | - docModelPdu.from = GlobalConfig.nodeId; | ||
| 707 | - docModelPdu.curPageNo = _param.curPageNo || 1; | ||
| 708 | - docModelPdu.pageNum = _param.pageNum || 1; | ||
| 709 | - docModelPdu.fileType = _param.fileType || ""; | ||
| 710 | - docModelPdu.creatUserId = _param.creatUserId || "0"; | ||
| 711 | - docModelPdu.url = _param.url||"";//这个地址没用到,数据太长占用资源 暂停使用//"http://101.200.150.192/DocSharing/data/h5test/20170206-171100025/7e9c4178cac1133e0dd9d5b583439122.jpg"; | ||
| 712 | - docModelPdu.relativeUrl = _param.relativeUrl || "";//"/DocSharing/data/h5test/20170206-171100025/7e9c4178cac1133e0dd9d5b583439122.jpg"; | ||
| 713 | - docModelPdu.curV = parseInt(_param.curV) || 0; | ||
| 714 | - docModelPdu.curH = parseInt(_param.curH) || 0; | ||
| 715 | - docModelPdu.scale = _param.scale || 100;//按百分比 | ||
| 716 | - docModelPdu.visible = _param.visible || false; | ||
| 717 | - docModelPdu.action = _param.action || ApeConsts.DOC_ACTION_NORMAL;//0,无操作, 1翻页、2.显示/隐藏, 3缩放/滚动 | ||
| 718 | - docModelPdu.docId = _param.docId || "";//文档在服务器数据库中的唯一id,必须有 | ||
| 719 | - docModelPdu.md5 = _param.md5 || "";//MD5 | ||
| 720 | - docModelPdu.fileName = _param.fileName || "doc_" + _itemIdx;//文档的名字 | ||
| 721 | - docModelPdu.dynamicTS = _param.dynamicTS || "0";//文档上传后返回值中的字段dynamicTransferStatic | ||
| 722 | - docModelPdu.showType = _param.showType || 0;//文档显示模式 | ||
| 723 | - docModelPdu.animationStep=_param.animationStep || 1;//当前页面上的动画步数(动态ppt时有这个字段) | ||
| 724 | - //loger.log(docModelPdu); | ||
| 725 | - return docModelPdu; | ||
| 726 | - } | ||
| 727 | - | ||
| 728 | - unPackPdu(owner, itemIdx, itemData) { | ||
| 729 | - if (owner == null || itemIdx == null || itemData == null) { | ||
| 730 | - this._emit(MessageTypes.MCU_ERROR, MessageTypes.ERR_APE_INTERFACE_PARAM_WRONG); | ||
| 731 | - return null; | ||
| 732 | - } | ||
| 733 | - try { | ||
| 734 | - let docModelPdu = pdu['RCDocSendDataModelPdu'].decode(itemData); | ||
| 735 | - //loger.log("文档===>unPackPdu"); | ||
| 736 | - return docModelPdu; | ||
| 737 | - } catch (err) { | ||
| 738 | - loger.log("文档===>unPackPdu->Pdu解析错误->itemIdx=" + itemIdx + "->err:" + err.message); | ||
| 739 | - } | ||
| 740 | - return null; | 690 | + //检查文档是否已经存在,如果存在 返回true,否则返回false |
| 691 | + checkDocId(_docId) { | ||
| 692 | + if (_docId == null) { | ||
| 693 | + loger.warn('查找文档->失败->参数为null'); | ||
| 694 | + return true; | ||
| 695 | + } | ||
| 696 | + //遍历查找 | ||
| 697 | + for (let key in this.docList) { | ||
| 698 | + let item = this.docList[key]; | ||
| 699 | + if (item && item.docId == _docId) { | ||
| 700 | + //loger.log('查找文档->已经存在->',_docId); | ||
| 701 | + return true; | ||
| 702 | + } | ||
| 703 | + } | ||
| 704 | + loger.log('查找文档->没有查找到文档->', _docId); | ||
| 705 | + //储存的数据中没有查找到 | ||
| 706 | + return false; | ||
| 707 | + } | ||
| 708 | + | ||
| 709 | + ///////数据的封包和解包///////////////////////////////////////// | ||
| 710 | + packPdu(_param, _itemIdx) { | ||
| 711 | + //loger.log("文档->packPdu"); | ||
| 712 | + //验证坐标点集合数组是否合法 | ||
| 713 | + if (_param == null || _itemIdx == null) { | ||
| 714 | + this._emit(MessageTypes.MCU_ERROR, MessageTypes.ERR_APE_INTERFACE_PARAM_WRONG); | ||
| 715 | + return null; | ||
| 716 | + } | ||
| 717 | + //判断type类型,根据type设置不同的参数 | ||
| 718 | + let docModelPdu = new pdu['RCDocSendDataModelPdu']; | ||
| 719 | + docModelPdu.itemIdx = _itemIdx; | ||
| 720 | + docModelPdu.owner = GlobalConfig.nodeId; | ||
| 721 | + docModelPdu.from = GlobalConfig.nodeId; | ||
| 722 | + docModelPdu.curPageNo = _param.curPageNo || 1; | ||
| 723 | + docModelPdu.pageNum = _param.pageNum || 1; | ||
| 724 | + docModelPdu.fileType = _param.fileType || ""; | ||
| 725 | + docModelPdu.creatUserId = _param.creatUserId || "0"; | ||
| 726 | + docModelPdu.url = _param.url || "";//这个地址没用到,数据太长占用资源 暂停使用//"http://101.200.150.192/DocSharing/data/h5test/20170206-171100025/7e9c4178cac1133e0dd9d5b583439122.jpg"; | ||
| 727 | + docModelPdu.relativeUrl = _param.relativeUrl || "";//"/DocSharing/data/h5test/20170206-171100025/7e9c4178cac1133e0dd9d5b583439122.jpg"; | ||
| 728 | + docModelPdu.curV = parseInt(_param.curV) || 0; | ||
| 729 | + docModelPdu.curH = parseInt(_param.curH) || 0; | ||
| 730 | + docModelPdu.scale = _param.scale || 100;//按百分比 | ||
| 731 | + docModelPdu.visible = _param.visible || false; | ||
| 732 | + docModelPdu.action = _param.action || ApeConsts.DOC_ACTION_NORMAL;//0,无操作, 1翻页、2.显示/隐藏, 3缩放/滚动 | ||
| 733 | + docModelPdu.docId = _param.docId || "";//文档在服务器数据库中的唯一id,必须有 | ||
| 734 | + docModelPdu.md5 = _param.md5 || "";//MD5 | ||
| 735 | + docModelPdu.fileName = _param.fileName || "doc_" + _itemIdx;//文档的名字 | ||
| 736 | + docModelPdu.dynamicTS = _param.dynamicTS || "0";//文档上传后返回值中的字段dynamicTransferStatic | ||
| 737 | + docModelPdu.showType = _param.showType || 0;//文档显示模式 | ||
| 738 | + docModelPdu.animationStep = _param.animationStep || 1;//当前页面上的动画步数(动态ppt时有这个字段) | ||
| 739 | + //loger.log(docModelPdu); | ||
| 740 | + return docModelPdu; | ||
| 741 | + } | ||
| 742 | + | ||
| 743 | + unPackPdu(owner, itemIdx, itemData) { | ||
| 744 | + if (owner == null || itemIdx == null || itemData == null) { | ||
| 745 | + this._emit(MessageTypes.MCU_ERROR, MessageTypes.ERR_APE_INTERFACE_PARAM_WRONG); | ||
| 746 | + return null; | ||
| 747 | + } | ||
| 748 | + try { | ||
| 749 | + let docModelPdu = pdu['RCDocSendDataModelPdu'].decode(itemData); | ||
| 750 | + //loger.log("文档===>unPackPdu"); | ||
| 751 | + return docModelPdu; | ||
| 752 | + } catch (err) { | ||
| 753 | + loger.log("文档===>unPackPdu->Pdu解析错误->itemIdx=" + itemIdx + "->err:" + err.message); | ||
| 741 | } | 754 | } |
| 755 | + return null; | ||
| 756 | + } | ||
| 742 | 757 | ||
| 743 | 758 | ||
| 744 | } | 759 | } |
-
请 注册 或 登录 后发表评论