正在显示
4 个修改的文件
包含
514 行增加
和
467 行删除
dist/McuClient.js
已删除
100644 → 0
此 diff 太大无法显示。
| @@ -26,7 +26,7 @@ import ArrayBufferUtil from 'libs/ArrayBufferUtil'; | @@ -26,7 +26,7 @@ import ArrayBufferUtil from 'libs/ArrayBufferUtil'; | ||
| 26 | import UTF8 from 'utf-8'; | 26 | import UTF8 from 'utf-8'; |
| 27 | 27 | ||
| 28 | let loger = Loger.getLoger('MessageEntrance'); | 28 | let loger = Loger.getLoger('MessageEntrance'); |
| 29 | -let _sdkInfo = {"version": "v.1.8.7.20170405-1", "author": "www.3mang.com"}; | 29 | +let _sdkInfo = {"version": "v.1.8.8.20170406-4", "author": "www.3mang.com"}; |
| 30 | 30 | ||
| 31 | //APE | 31 | //APE |
| 32 | let _sass; | 32 | let _sass; |
| @@ -177,7 +177,7 @@ export default class Ape extends Emiter { | @@ -177,7 +177,7 @@ export default class Ape extends Emiter { | ||
| 177 | this.tableUpdateHandler(tableItem.owner, tableItem.itemIdx, tableItem.itemData,seekTime); | 177 | this.tableUpdateHandler(tableItem.owner, tableItem.itemIdx, tableItem.itemData,seekTime); |
| 178 | } | 178 | } |
| 179 | 179 | ||
| 180 | - //白板数据内部自己处理数组 | 180 | + //白板,文档数据数组内部自己处理数组 |
| 181 | this.tableUpdateApeHandler(tableUpdateItems); | 181 | this.tableUpdateApeHandler(tableUpdateItems); |
| 182 | break; | 182 | break; |
| 183 | case pdu.RCPDU_REG_QUEUE_UPDATE_PDU: | 183 | case pdu.RCPDU_REG_QUEUE_UPDATE_PDU: |
| @@ -22,512 +22,559 @@ import GlobalConfig from 'GlobalConfig'; | @@ -22,512 +22,559 @@ import GlobalConfig from 'GlobalConfig'; | ||
| 22 | import EngineUtils from 'EngineUtils'; | 22 | import EngineUtils from 'EngineUtils'; |
| 23 | 23 | ||
| 24 | let loger = Loger.getLoger('DocApe'); | 24 | 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 | - //this.activeDocItemIdx =0;//当前激活的文档itemIdx | ||
| 36 | - //this.activeDocCurPage=1;//当前激活的文档的当前页 | ||
| 37 | - | ||
| 38 | - // Ape Models | ||
| 39 | - this.registerKey(this._session_id, this._session_name, this._session_tag, new ArrayBuffer); | ||
| 40 | - 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); | ||
| 41 | - //this.registerObj(pdu.RCPDU_REG_REGISTER_TABLE, ApeConsts.DOCSHARING_OBJ_TABLE_ID_H5, ApeConsts.DOCSHARING_OBJ_TABLE_NAME_H5, ApeConsts.DOCSHARING_OBJ_TABLE_TAG_H5, 0, new ArrayBuffer); | ||
| 42 | - } | ||
| 43 | - | ||
| 44 | - /////////////发送数据操作////////////////////////////////////////////////////// | ||
| 45 | - | ||
| 46 | - //上传文档 | ||
| 47 | - documentUpload(paramInfo){ | ||
| 48 | - if(paramInfo==null||EngineUtils.isEmptyObject(paramInfo)){ | ||
| 49 | - loger.log('documentUpload失败,参数错误'); | ||
| 50 | - this._emit(MessageTypes.MCU_ERROR,MessageTypes.ERR_APE_INTERFACE_PARAM_WRONG); | ||
| 51 | - return ; | ||
| 52 | - } | ||
| 53 | - //判断文档是否已经存在,每个文档都有唯一的docId,如果已经同步的文档中存在相同的docId就不需要再同步 | ||
| 54 | - if(this.checkDocId(paramInfo.docId)){ | ||
| 55 | - //文档已经存在相同的docId,不需要同步上传 | ||
| 56 | - loger.warn('documentUpload 文档的docId不无效或已经存在相同的docId,不需要上传'); | ||
| 57 | - return; | 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 | + //this.activeDocItemIdx =0;//当前激活的文档itemIdx | ||
| 36 | + //this.activeDocCurPage=1;//当前激活的文档的当前页 | ||
| 37 | + | ||
| 38 | + // Ape Models | ||
| 39 | + this.registerKey(this._session_id, this._session_name, this._session_tag, new ArrayBuffer); | ||
| 40 | + 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); | ||
| 41 | + //this.registerObj(pdu.RCPDU_REG_REGISTER_TABLE, ApeConsts.DOCSHARING_OBJ_TABLE_ID_H5, ApeConsts.DOCSHARING_OBJ_TABLE_NAME_H5, ApeConsts.DOCSHARING_OBJ_TABLE_TAG_H5, 0, new ArrayBuffer); | ||
| 58 | } | 42 | } |
| 59 | 43 | ||
| 60 | - itemIdx=EngineUtils.creatSoleNumberFromTimestamp(); | ||
| 61 | - let docDataModelPdu = this.packPdu(paramInfo,itemIdx); | ||
| 62 | - if(docDataModelPdu==null){ | ||
| 63 | - loger.log('documentUpload失败,参数错误'); | ||
| 64 | - this._emit(MessageTypes.MCU_ERROR,MessageTypes.ERR_APE_INTERFACE_PARAM_WRONG); | ||
| 65 | - return ; | ||
| 66 | - } | ||
| 67 | - //console.log(docDataModelPdu); | ||
| 68 | - | ||
| 69 | - let tableItemPdu = new pdu['RCRegistryTableItemPdu']; | ||
| 70 | - tableItemPdu.itemIdx=itemIdx;//直接用时间戳作为id | ||
| 71 | - tableItemPdu.registerObjId=ApeConsts.DOCSHARING_OBJ_TABLE_ID;// tableItemPdu.registerObjId=ApeConsts.DOCSHARING_OBJ_TABLE_ID_H5; | ||
| 72 | - tableItemPdu.owner = 0;//收到flash的是这个值,不清楚先写固定 | ||
| 73 | - tableItemPdu.itemData =docDataModelPdu.toArrayBuffer(); | ||
| 74 | - | ||
| 75 | - //insert | ||
| 76 | - let tableInsertItemPdu = new pdu['RCRegistryTableInsertItemPdu']; | ||
| 77 | - //optional RCPduType_E type = 1 [default = RCPDU_REG_TABLE_UPDATE_PDU]; | ||
| 78 | - //repeated RCRegistryTableItemPdu items = 2; | ||
| 79 | - tableInsertItemPdu.type = pdu.RCPDU_REG_TABLE_INSERT_PDU;// | ||
| 80 | - tableInsertItemPdu.items.push(tableItemPdu); | ||
| 81 | - | ||
| 82 | - let updateObjPdu = new pdu['RCRegistryUpdateObjPdu']; | ||
| 83 | - updateObjPdu.objId = ApeConsts.DOCSHARING_OBJ_TABLE_ID;// updateObjPdu.objId = ApeConsts.DOCSHARING_OBJ_TABLE_ID_H5; | ||
| 84 | - updateObjPdu.subType = tableInsertItemPdu.type; | ||
| 85 | - updateObjPdu.userData = tableInsertItemPdu.toArrayBuffer(); | ||
| 86 | - | ||
| 87 | - //同步 | ||
| 88 | - let adapterItemPdu = new pdu['RCAdapterItemPdu']; | ||
| 89 | - adapterItemPdu.type = pdu.RCPDU_REG_UPDATE_OBJ; | ||
| 90 | - adapterItemPdu.itemData = updateObjPdu.toArrayBuffer(); | ||
| 91 | - | ||
| 92 | - let adapterPdu = new pdu['RCAdapterPdu']; | ||
| 93 | - adapterPdu.type = pdu.RCPDU_REG_ADAPTER; | ||
| 94 | - adapterPdu.item.push(adapterItemPdu); | ||
| 95 | - | ||
| 96 | - loger.log("文档upload tableItemPdu.itemIdx="+tableItemPdu.itemIdx); | ||
| 97 | - this.sendUniform(adapterPdu,true); | ||
| 98 | - } | ||
| 99 | - updaterDoc(_docDataModel,_itemIdx){ | ||
| 100 | - //loger.log("文档===updaterDoc ",_itemIdx); | ||
| 101 | - //验证坐标点集合数组是否合法 | ||
| 102 | - if(_docDataModel==null||_itemIdx==null){ | ||
| 103 | - this._emit(MessageTypes.MCU_ERROR,MessageTypes.ERR_APE_INTERFACE_PARAM_WRONG); | ||
| 104 | - return null; | ||
| 105 | - } | ||
| 106 | - loger.log("文档===updaterDoc ",_docDataModel); | ||
| 107 | - | ||
| 108 | - let docDataModelPdu=this.packPdu(_docDataModel,_itemIdx); | ||
| 109 | - let tableItemPdu = new pdu['RCRegistryTableItemPdu']; | ||
| 110 | - tableItemPdu.itemIdx=_itemIdx;//直接用时间戳作为id | ||
| 111 | - //tableItemPdu.registerObjId=ApeConsts.DOCSHARING_OBJ_TABLE_ID;// tableItemPdu.registerObjId=ApeConsts.DOCSHARING_OBJ_TABLE_ID_H5; | ||
| 112 | - tableItemPdu.owner = 0;//收到flash的是这个值,不清楚先写固定 | ||
| 113 | - tableItemPdu.itemData =docDataModelPdu.toArrayBuffer(); | ||
| 114 | - | ||
| 115 | - //insert | ||
| 116 | - let tableInsertItemPdu = new pdu['RCRegistryTableUpdateItemPdu']; | ||
| 117 | - //optional RCPduType_E type = 1 [default = RCPDU_REG_TABLE_UPDATE_PDU]; | ||
| 118 | - //repeated RCRegistryTableItemPdu items = 2; | ||
| 119 | - tableInsertItemPdu.type = pdu.RCPDU_REG_TABLE_UPDATE_PDU;// | ||
| 120 | - tableInsertItemPdu.items.push(tableItemPdu); | ||
| 121 | - | ||
| 122 | - let updateObjPdu = new pdu['RCRegistryUpdateObjPdu']; | ||
| 123 | - updateObjPdu.objId = ApeConsts.DOCSHARING_OBJ_TABLE_ID;// updateObjPdu.objId = ApeConsts.DOCSHARING_OBJ_TABLE_ID_H5; | ||
| 124 | - updateObjPdu.subType = tableInsertItemPdu.type; | ||
| 125 | - updateObjPdu.userData = tableInsertItemPdu.toArrayBuffer(); | ||
| 126 | - | ||
| 127 | - //同步 | ||
| 128 | - let adapterItemPdu = new pdu['RCAdapterItemPdu']; | ||
| 129 | - adapterItemPdu.type = pdu.RCPDU_REG_UPDATE_OBJ; | ||
| 130 | - adapterItemPdu.itemData = updateObjPdu.toArrayBuffer(); | ||
| 131 | - | ||
| 132 | - let adapterPdu = new pdu['RCAdapterPdu']; | ||
| 133 | - adapterPdu.type = pdu.RCPDU_REG_ADAPTER; | ||
| 134 | - adapterPdu.item.push(adapterItemPdu); | ||
| 135 | - | ||
| 136 | - loger.log("发送更新文档.itemIdx="+tableItemPdu.itemIdx); | ||
| 137 | - this.sendUniform(adapterPdu,true); | ||
| 138 | - } | ||
| 139 | - //获取文档的图片完整地址 | ||
| 140 | - getDocImageFullPath(_param){ | ||
| 141 | - if(_param==null||_param.relativeUrl==null||_param.relativeUrl==""){ | ||
| 142 | - loger.warn('获取文档完整地址,传递的参数不对.',_param); | ||
| 143 | - return []; | 44 | + /////////////发送数据操作////////////////////////////////////////////////////// |
| 45 | + | ||
| 46 | + //上传文档 | ||
| 47 | + documentUpload(paramInfo) { | ||
| 48 | + if (paramInfo == null || EngineUtils.isEmptyObject(paramInfo)) { | ||
| 49 | + loger.log('documentUpload失败,参数错误'); | ||
| 50 | + this._emit(MessageTypes.MCU_ERROR, MessageTypes.ERR_APE_INTERFACE_PARAM_WRONG); | ||
| 51 | + return; | ||
| 52 | + } | ||
| 53 | + //判断文档是否已经存在,每个文档都有唯一的docId,如果已经同步的文档中存在相同的docId就不需要再同步 | ||
| 54 | + if (this.checkDocId(paramInfo.docId)) { | ||
| 55 | + //文档已经存在相同的docId,不需要同步上传 | ||
| 56 | + loger.warn('documentUpload 文档的docId不无效或已经存在相同的docId,不需要上传'); | ||
| 57 | + return; | ||
| 58 | + } | ||
| 59 | + | ||
| 60 | + itemIdx = EngineUtils.creatSoleNumberFromTimestamp(); | ||
| 61 | + let docDataModelPdu = this.packPdu(paramInfo, itemIdx); | ||
| 62 | + if (docDataModelPdu == null) { | ||
| 63 | + loger.log('documentUpload失败,参数错误'); | ||
| 64 | + this._emit(MessageTypes.MCU_ERROR, MessageTypes.ERR_APE_INTERFACE_PARAM_WRONG); | ||
| 65 | + return; | ||
| 66 | + } | ||
| 67 | + //console.log(docDataModelPdu); | ||
| 68 | + | ||
| 69 | + let tableItemPdu = new pdu['RCRegistryTableItemPdu']; | ||
| 70 | + tableItemPdu.itemIdx = itemIdx;//直接用时间戳作为id | ||
| 71 | + tableItemPdu.registerObjId = ApeConsts.DOCSHARING_OBJ_TABLE_ID;// tableItemPdu.registerObjId=ApeConsts.DOCSHARING_OBJ_TABLE_ID_H5; | ||
| 72 | + tableItemPdu.owner = 0;//收到flash的是这个值,不清楚先写固定 | ||
| 73 | + tableItemPdu.itemData = docDataModelPdu.toArrayBuffer(); | ||
| 74 | + | ||
| 75 | + //insert | ||
| 76 | + let tableInsertItemPdu = new pdu['RCRegistryTableInsertItemPdu']; | ||
| 77 | + //optional RCPduType_E type = 1 [default = RCPDU_REG_TABLE_UPDATE_PDU]; | ||
| 78 | + //repeated RCRegistryTableItemPdu items = 2; | ||
| 79 | + tableInsertItemPdu.type = pdu.RCPDU_REG_TABLE_INSERT_PDU;// | ||
| 80 | + tableInsertItemPdu.items.push(tableItemPdu); | ||
| 81 | + | ||
| 82 | + let updateObjPdu = new pdu['RCRegistryUpdateObjPdu']; | ||
| 83 | + updateObjPdu.objId = ApeConsts.DOCSHARING_OBJ_TABLE_ID;// updateObjPdu.objId = ApeConsts.DOCSHARING_OBJ_TABLE_ID_H5; | ||
| 84 | + updateObjPdu.subType = tableInsertItemPdu.type; | ||
| 85 | + updateObjPdu.userData = tableInsertItemPdu.toArrayBuffer(); | ||
| 86 | + | ||
| 87 | + //同步 | ||
| 88 | + let adapterItemPdu = new pdu['RCAdapterItemPdu']; | ||
| 89 | + adapterItemPdu.type = pdu.RCPDU_REG_UPDATE_OBJ; | ||
| 90 | + adapterItemPdu.itemData = updateObjPdu.toArrayBuffer(); | ||
| 91 | + | ||
| 92 | + let adapterPdu = new pdu['RCAdapterPdu']; | ||
| 93 | + adapterPdu.type = pdu.RCPDU_REG_ADAPTER; | ||
| 94 | + adapterPdu.item.push(adapterItemPdu); | ||
| 95 | + | ||
| 96 | + loger.log("文档upload tableItemPdu.itemIdx=" + tableItemPdu.itemIdx); | ||
| 97 | + this.sendUniform(adapterPdu, true); | ||
| 144 | } | 98 | } |
| 145 | 99 | ||
| 146 | - let port = (GlobalConfig.DOCServerPort == "" || GlobalConfig.DOCServerPort == null) ? "":":" + GlobalConfig.DOCServerPort; | ||
| 147 | - let fullPath=GlobalConfig.DOCServerIP+port+_param.relativeUrl; | ||
| 148 | - if(fullPath&&fullPath.indexOf("http://")<0){ | ||
| 149 | - fullPath="http://"+fullPath; | 100 | + updaterDoc(_docDataModel, _itemIdx) { |
| 101 | + //loger.log("文档===updaterDoc ",_itemIdx); | ||
| 102 | + //验证坐标点集合数组是否合法 | ||
| 103 | + if (_docDataModel == null || _itemIdx == null) { | ||
| 104 | + this._emit(MessageTypes.MCU_ERROR, MessageTypes.ERR_APE_INTERFACE_PARAM_WRONG); | ||
| 105 | + return null; | ||
| 106 | + } | ||
| 107 | + loger.log("文档===updaterDoc ", _docDataModel); | ||
| 108 | + | ||
| 109 | + let docDataModelPdu = this.packPdu(_docDataModel, _itemIdx); | ||
| 110 | + let tableItemPdu = new pdu['RCRegistryTableItemPdu']; | ||
| 111 | + tableItemPdu.itemIdx = _itemIdx;//直接用时间戳作为id | ||
| 112 | + //tableItemPdu.registerObjId=ApeConsts.DOCSHARING_OBJ_TABLE_ID;// tableItemPdu.registerObjId=ApeConsts.DOCSHARING_OBJ_TABLE_ID_H5; | ||
| 113 | + tableItemPdu.owner = 0;//收到flash的是这个值,不清楚先写固定 | ||
| 114 | + tableItemPdu.itemData = docDataModelPdu.toArrayBuffer(); | ||
| 115 | + | ||
| 116 | + //insert | ||
| 117 | + let tableInsertItemPdu = new pdu['RCRegistryTableUpdateItemPdu']; | ||
| 118 | + //optional RCPduType_E type = 1 [default = RCPDU_REG_TABLE_UPDATE_PDU]; | ||
| 119 | + //repeated RCRegistryTableItemPdu items = 2; | ||
| 120 | + tableInsertItemPdu.type = pdu.RCPDU_REG_TABLE_UPDATE_PDU;// | ||
| 121 | + tableInsertItemPdu.items.push(tableItemPdu); | ||
| 122 | + | ||
| 123 | + let updateObjPdu = new pdu['RCRegistryUpdateObjPdu']; | ||
| 124 | + updateObjPdu.objId = ApeConsts.DOCSHARING_OBJ_TABLE_ID;// updateObjPdu.objId = ApeConsts.DOCSHARING_OBJ_TABLE_ID_H5; | ||
| 125 | + updateObjPdu.subType = tableInsertItemPdu.type; | ||
| 126 | + updateObjPdu.userData = tableInsertItemPdu.toArrayBuffer(); | ||
| 127 | + | ||
| 128 | + //同步 | ||
| 129 | + let adapterItemPdu = new pdu['RCAdapterItemPdu']; | ||
| 130 | + adapterItemPdu.type = pdu.RCPDU_REG_UPDATE_OBJ; | ||
| 131 | + adapterItemPdu.itemData = updateObjPdu.toArrayBuffer(); | ||
| 132 | + | ||
| 133 | + let adapterPdu = new pdu['RCAdapterPdu']; | ||
| 134 | + adapterPdu.type = pdu.RCPDU_REG_ADAPTER; | ||
| 135 | + adapterPdu.item.push(adapterItemPdu); | ||
| 136 | + | ||
| 137 | + loger.log("发送更新文档.itemIdx=" + tableItemPdu.itemIdx); | ||
| 138 | + this.sendUniform(adapterPdu, true); | ||
| 150 | } | 139 | } |
| 151 | 140 | ||
| 152 | - var fileType="jpg"; | ||
| 153 | - switch (_param.type){ | ||
| 154 | - case "jpg": | ||
| 155 | - fileType="jpg"; | ||
| 156 | - fullPath=this.replacePathType(fullPath)+".jpg"; | ||
| 157 | - break; | ||
| 158 | - case "png": | ||
| 159 | - fileType="png"; | ||
| 160 | - fullPath=this.replacePathType(fullPath)+".png"; | ||
| 161 | - break; | ||
| 162 | - default : | ||
| 163 | - //不做处理,直接返回拼接的地址 | ||
| 164 | - break; | 141 | + //获取文档的图片完整地址 |
| 142 | + getDocImageFullPath(_param) { | ||
| 143 | + if (_param == null || _param.relativeUrl == null || _param.relativeUrl == "") { | ||
| 144 | + loger.warn('获取文档完整地址,传递的参数不对.', _param); | ||
| 145 | + return []; | ||
| 146 | + } | ||
| 147 | + | ||
| 148 | + let port = (GlobalConfig.DOCServerPort == "" || GlobalConfig.DOCServerPort == null) ? "" : ":" + GlobalConfig.DOCServerPort; | ||
| 149 | + let fullPath = GlobalConfig.DOCServerIP + port + _param.relativeUrl; | ||
| 150 | + if (fullPath && fullPath.indexOf("http://") < 0) { | ||
| 151 | + fullPath = "http://" + fullPath; | ||
| 152 | + } | ||
| 153 | + | ||
| 154 | + var fileType = "jpg"; | ||
| 155 | + switch (_param.type) { | ||
| 156 | + case "jpg": | ||
| 157 | + fileType = "jpg"; | ||
| 158 | + fullPath = this.replacePathType(fullPath) + ".jpg"; | ||
| 159 | + break; | ||
| 160 | + case "png": | ||
| 161 | + fileType = "png"; | ||
| 162 | + fullPath = this.replacePathType(fullPath) + ".png"; | ||
| 163 | + break; | ||
| 164 | + default : | ||
| 165 | + //不做处理,直接返回拼接的地址 | ||
| 166 | + break; | ||
| 167 | + } | ||
| 168 | + | ||
| 169 | + if (_param.pageNum && parseInt(_param.pageNum) > 1) { | ||
| 170 | + //如果是多页的,需要返回序列 | ||
| 171 | + var lastIndex = fullPath.lastIndexOf("/"); | ||
| 172 | + if (lastIndex > 0) { | ||
| 173 | + let newPath = fullPath.substr(0, lastIndex); | ||
| 174 | + let pathArr = []; | ||
| 175 | + //页数从1开始 | ||
| 176 | + for (let i = 1; i <= _param.pageNum; i++) { | ||
| 177 | + pathArr.push(newPath + "/" + i + "." + fileType); | ||
| 178 | + } | ||
| 179 | + return pathArr; | ||
| 180 | + } else { | ||
| 181 | + return [fullPath]; | ||
| 182 | + } | ||
| 183 | + } else { | ||
| 184 | + return [fullPath]; | ||
| 185 | + } | ||
| 165 | } | 186 | } |
| 166 | 187 | ||
| 167 | - if(_param.pageNum&&parseInt(_param.pageNum)>1){ | ||
| 168 | - //如果是多页的,需要返回序列 | ||
| 169 | - var lastIndex=fullPath.lastIndexOf("/"); | ||
| 170 | - if(lastIndex>0){ | ||
| 171 | - let newPath=fullPath.substr(0,lastIndex); | ||
| 172 | - let pathArr=[]; | ||
| 173 | - //页数从1开始 | ||
| 174 | - for(let i=1;i<=_param.pageNum;i++){ | ||
| 175 | - pathArr.push(newPath+"/"+i+"."+fileType); | ||
| 176 | - } | ||
| 177 | - return pathArr; | ||
| 178 | - }else { | 188 | + //获取文档的pdf完整地址 |
| 189 | + getDocPDFFullPath(_param) { | ||
| 190 | + if (_param == null || _param.relativeUrl == null || _param.relativeUrl == "") { | ||
| 191 | + loger.warn('获取文档完整地址,传递的参数不对.', _param); | ||
| 192 | + return []; | ||
| 193 | + } | ||
| 194 | + let port = (GlobalConfig.DOCServerPort == "" || GlobalConfig.DOCServerPort == null) ? "" : ":" + GlobalConfig.DOCServerPort; | ||
| 195 | + let fullPath = GlobalConfig.DOCServerIP + port + _param.relativeUrl; | ||
| 196 | + if (fullPath && fullPath.indexOf("http://") < 0) { | ||
| 197 | + fullPath = "http://" + fullPath; | ||
| 198 | + } | ||
| 199 | + fullPath = this.replacePathType(fullPath) + ".pdf"; | ||
| 179 | return [fullPath]; | 200 | return [fullPath]; |
| 180 | - } | ||
| 181 | - }else { | ||
| 182 | - return [fullPath]; | ||
| 183 | } | 201 | } |
| 184 | - } | ||
| 185 | 202 | ||
| 186 | - //获取文档的pdf完整地址 | ||
| 187 | - getDocPDFFullPath(_param){ | ||
| 188 | - if(_param==null||_param.relativeUrl==null||_param.relativeUrl==""){ | ||
| 189 | - loger.warn('获取文档完整地址,传递的参数不对.',_param); | ||
| 190 | - return []; | ||
| 191 | - } | ||
| 192 | - let port = (GlobalConfig.DOCServerPort == "" || GlobalConfig.DOCServerPort == null) ? "":":" + GlobalConfig.DOCServerPort; | ||
| 193 | - let fullPath=GlobalConfig.DOCServerIP+port+_param.relativeUrl; | ||
| 194 | - if(fullPath&&fullPath.indexOf("http://")<0){ | ||
| 195 | - fullPath="http://"+fullPath; | ||
| 196 | - } | ||
| 197 | - fullPath=this.replacePathType(fullPath)+".pdf"; | ||
| 198 | - return [fullPath]; | ||
| 199 | - } | ||
| 200 | - | ||
| 201 | - // 去除文件的后缀格式名称 | ||
| 202 | - replacePathType(_path){ | ||
| 203 | - let path=_path; | ||
| 204 | - path=path.replace(/.jpg/g,""); | ||
| 205 | - path=path.replace(/.png/g,""); | ||
| 206 | - path=path.replace(/.swf/g,""); | ||
| 207 | - path=path.replace(/.pdf/g,""); | ||
| 208 | - return path; | ||
| 209 | - } | ||
| 210 | - | ||
| 211 | - //切换文档 | ||
| 212 | - documentSwitchDoc(paramInfo){ | ||
| 213 | - loger.log('切换文档,documentSwitchDoc'); | ||
| 214 | - loger.log(paramInfo); | ||
| 215 | - if(paramInfo==null||paramInfo.itemIdx==null){ | ||
| 216 | - loger.warn('documentSwitch失败,参数错误',paramInfo); | ||
| 217 | - this._emit(MessageTypes.MCU_ERROR,MessageTypes.ERR_APE_INTERFACE_PARAM_WRONG); | ||
| 218 | - return; | 203 | + // 去除文件的后缀格式名称 |
| 204 | + replacePathType(_path) { | ||
| 205 | + let path = _path; | ||
| 206 | + path = path.replace(/.jpg/g, ""); | ||
| 207 | + path = path.replace(/.png/g, ""); | ||
| 208 | + path = path.replace(/.swf/g, ""); | ||
| 209 | + path = path.replace(/.pdf/g, ""); | ||
| 210 | + return path; | ||
| 219 | } | 211 | } |
| 220 | 212 | ||
| 221 | - if(paramInfo.itemIdx==GlobalConfig.activeDocId&&GlobalConfig.activeDocId!=0){ | ||
| 222 | - loger.warn('文档已经显示',paramInfo.itemIdx,GlobalConfig.activeDocId); | ||
| 223 | - return; | ||
| 224 | - } | 213 | + //切换文档 |
| 214 | + documentSwitchDoc(paramInfo) { | ||
| 215 | + loger.log('切换文档,documentSwitchDoc->', paramInfo); | ||
| 225 | 216 | ||
| 226 | - //更新切换之前的文档的数据,要显示当前切换的文档,上一个文档需要隐藏 | ||
| 227 | - let oldDocModel; | ||
| 228 | - if(GlobalConfig.activeDocId!=0){ | ||
| 229 | - oldDocModel=this.docList[GlobalConfig.activeDocId]; | ||
| 230 | - if(oldDocModel){ | ||
| 231 | - oldDocModel.action=ApeConsts.DOC_ACTION_NORMAL; | ||
| 232 | - oldDocModel.visible=false;//设置为不可见 | ||
| 233 | - } | ||
| 234 | - } | 217 | + if (GlobalConfig.isRecordPlayBack) { |
| 218 | + loger.warn('录制回放状态不允许切换文档'); | ||
| 219 | + return; | ||
| 220 | + } | ||
| 235 | 221 | ||
| 236 | - //获取已经存在的数据 | ||
| 237 | - let docDataModel= this.docList[paramInfo.itemIdx]; | ||
| 238 | - if(docDataModel==null){ | ||
| 239 | - loger.warn('documentSwitch失败,文档不存在',paramInfo); | ||
| 240 | - this._emit(MessageTypes.MCU_ERROR,MessageTypes.ERR_APE_INTERFACE_PARAM_WRONG); | ||
| 241 | - return; | ||
| 242 | - } | 222 | + if (paramInfo == null || paramInfo.itemIdx == null) { |
| 223 | + loger.warn('documentSwitch失败,参数错误', paramInfo); | ||
| 224 | + this._emit(MessageTypes.MCU_ERROR, MessageTypes.ERR_APE_INTERFACE_PARAM_WRONG); | ||
| 225 | + return; | ||
| 226 | + } | ||
| 243 | 227 | ||
| 244 | - //更新当前选择的文档数据的字段 | ||
| 245 | - docDataModel.action=ApeConsts.DOC_ACTION_SWITCH_DOC; | ||
| 246 | - docDataModel.visible=paramInfo.visible||false;//默认是false | 228 | + if (paramInfo.itemIdx == GlobalConfig.activeDocId && GlobalConfig.activeDocId != 0) { |
| 229 | + loger.warn('文档已经显示', paramInfo.itemIdx, GlobalConfig.activeDocId); | ||
| 230 | + return; | ||
| 231 | + } | ||
| 247 | 232 | ||
| 248 | - //loger.log('切换文档,当前文档和上一个显示的文档都需要更新状态'); | ||
| 249 | - loger.log({"oldDoc":oldDocModel,"nowDoc":docDataModel}); | ||
| 250 | - //更新当前选择的文档 | ||
| 251 | - this.updaterDoc(docDataModel,docDataModel.itemIdx); | 233 | + //更新切换之前的文档的数据,要显示当前切换的文档,上一个文档需要隐藏 |
| 234 | + let oldDocModel; | ||
| 235 | + if (GlobalConfig.activeDocId != 0) { | ||
| 236 | + oldDocModel = this.docList[GlobalConfig.activeDocId]; | ||
| 237 | + if (oldDocModel) { | ||
| 238 | + oldDocModel.action = ApeConsts.DOC_ACTION_NORMAL; | ||
| 239 | + oldDocModel.visible = false;//设置为不可见 | ||
| 240 | + } | ||
| 241 | + } | ||
| 252 | 242 | ||
| 253 | - //更新上一个文档 隐藏 | ||
| 254 | - if(oldDocModel){ | ||
| 255 | - this.updaterDoc(oldDocModel,oldDocModel.itemIdx); | ||
| 256 | - } | ||
| 257 | - } | ||
| 258 | - | ||
| 259 | - | ||
| 260 | - //文档翻页 | ||
| 261 | - documentSwitchPage(paramInfo){ | ||
| 262 | - loger.log('文档翻页,documentSwitchPage'); | ||
| 263 | - loger.log(paramInfo); | ||
| 264 | - //console.log(this.docList); | ||
| 265 | - //获取已经存在的数据 | ||
| 266 | - let docDataModel= this.docList[paramInfo.itemIdx]; | ||
| 267 | - //console.log(docDataModelPdu); | ||
| 268 | - //console.log(docDataModel); | ||
| 269 | - if(docDataModel==null){ | ||
| 270 | - loger.log('documentSwitchPage->,文档不存在',paramInfo); | ||
| 271 | - this._emit(MessageTypes.MCU_ERROR,MessageTypes.ERR_APE_INTERFACE_PARAM_WRONG); | ||
| 272 | - return; | 243 | + //获取已经存在的数据 |
| 244 | + let docDataModel = this.docList[paramInfo.itemIdx]; | ||
| 245 | + if (docDataModel == null) { | ||
| 246 | + loger.warn('documentSwitch失败,文档不存在', paramInfo); | ||
| 247 | + this._emit(MessageTypes.MCU_ERROR, MessageTypes.ERR_APE_INTERFACE_PARAM_WRONG); | ||
| 248 | + return; | ||
| 249 | + } | ||
| 250 | + | ||
| 251 | + //更新当前选择的文档数据的字段 | ||
| 252 | + docDataModel.action = ApeConsts.DOC_ACTION_SWITCH_DOC; | ||
| 253 | + docDataModel.visible = paramInfo.visible || false;//默认是false | ||
| 254 | + | ||
| 255 | + //loger.log('切换文档,当前文档和上一个显示的文档都需要更新状态'); | ||
| 256 | + loger.log({"oldDoc": oldDocModel, "nowDoc": docDataModel}); | ||
| 257 | + //更新当前选择的文档 | ||
| 258 | + this.updaterDoc(docDataModel, docDataModel.itemIdx); | ||
| 259 | + | ||
| 260 | + //更新上一个文档 隐藏 | ||
| 261 | + if (oldDocModel) { | ||
| 262 | + this.updaterDoc(oldDocModel, oldDocModel.itemIdx); | ||
| 263 | + } | ||
| 273 | } | 264 | } |
| 274 | - //更新数据的字段 | ||
| 275 | - docDataModel.action=ApeConsts.DOC_ACTION_SWITCH_PAGE; | ||
| 276 | - docDataModel.curPageNo=parseInt(paramInfo.curPageNo)||1; | ||
| 277 | - if(docDataModel.curPageNo<1){ | ||
| 278 | - docDataModel.curPageNo=1;//默认值最小是1 | 265 | + |
| 266 | + | ||
| 267 | + //文档翻页 | ||
| 268 | + documentSwitchPage(paramInfo) { | ||
| 269 | + loger.log('文档翻页,documentSwitchPage'); | ||
| 270 | + loger.log(paramInfo); | ||
| 271 | + //console.log(this.docList); | ||
| 272 | + //获取已经存在的数据 | ||
| 273 | + let docDataModel = this.docList[paramInfo.itemIdx]; | ||
| 274 | + //console.log(docDataModelPdu); | ||
| 275 | + //console.log(docDataModel); | ||
| 276 | + if (docDataModel == null) { | ||
| 277 | + loger.log('documentSwitchPage->,文档不存在', paramInfo); | ||
| 278 | + this._emit(MessageTypes.MCU_ERROR, MessageTypes.ERR_APE_INTERFACE_PARAM_WRONG); | ||
| 279 | + return; | ||
| 280 | + } | ||
| 281 | + //更新数据的字段 | ||
| 282 | + docDataModel.action = ApeConsts.DOC_ACTION_SWITCH_PAGE; | ||
| 283 | + docDataModel.curPageNo = parseInt(paramInfo.curPageNo) || 1; | ||
| 284 | + if (docDataModel.curPageNo < 1) { | ||
| 285 | + docDataModel.curPageNo = 1;//默认值最小是1 | ||
| 286 | + } | ||
| 287 | + this.updaterDoc(docDataModel, docDataModel.itemIdx); | ||
| 279 | } | 288 | } |
| 280 | - this.updaterDoc(docDataModel,docDataModel.itemIdx); | ||
| 281 | - } | ||
| 282 | - | ||
| 283 | - //文档切换显示模式 | ||
| 284 | - documentSwitchShowModel(paramInfo){ | ||
| 285 | - loger.log('documentSwitchShowModel',paramInfo); | ||
| 286 | - //获取已经存在的数据 | ||
| 287 | - let docDataModel= this.docList[paramInfo.itemIdx]; | ||
| 288 | - | ||
| 289 | - if(docDataModel==null){ | ||
| 290 | - loger.log('documentSwitchShowModel->文档不存在',paramInfo); | ||
| 291 | - this._emit(MessageTypes.MCU_ERROR,MessageTypes.ERR_APE_INTERFACE_PARAM_WRONG); | ||
| 292 | - return; | 289 | + |
| 290 | + //文档切换显示模式 | ||
| 291 | + documentSwitchShowModel(paramInfo) { | ||
| 292 | + loger.log('documentSwitchShowModel', paramInfo); | ||
| 293 | + //获取已经存在的数据 | ||
| 294 | + let docDataModel = this.docList[paramInfo.itemIdx]; | ||
| 295 | + | ||
| 296 | + if (docDataModel == null) { | ||
| 297 | + loger.log('documentSwitchShowModel->文档不存在', paramInfo); | ||
| 298 | + this._emit(MessageTypes.MCU_ERROR, MessageTypes.ERR_APE_INTERFACE_PARAM_WRONG); | ||
| 299 | + return; | ||
| 300 | + } | ||
| 301 | + //更新数据的字段 | ||
| 302 | + docDataModel.action = ApeConsts.DOC_ACTION_SWITCH_PAGE; | ||
| 303 | + docDataModel.curPageNo = parseInt(paramInfo.curPageNo) || 1; | ||
| 304 | + if (docDataModel.curPageNo < 1) { | ||
| 305 | + docDataModel.curPageNo = 1;//默认值最小是1 | ||
| 306 | + } | ||
| 307 | + this.updaterDoc(docDataModel, docDataModel.itemIdx); | ||
| 293 | } | 308 | } |
| 294 | - //更新数据的字段 | ||
| 295 | - docDataModel.action=ApeConsts.DOC_ACTION_SWITCH_PAGE; | ||
| 296 | - docDataModel.curPageNo=parseInt(paramInfo.curPageNo)||1; | ||
| 297 | - if(docDataModel.curPageNo<1){ | ||
| 298 | - docDataModel.curPageNo=1;//默认值最小是1 | 309 | + |
| 310 | + //缩放/滚动/显示模式 | ||
| 311 | + documentCommand(paramInfo) { | ||
| 312 | + //获取已经存在的数据 | ||
| 313 | + let docDataModel = this.docList[paramInfo.itemIdx]; | ||
| 314 | + if (docDataModel == null) { | ||
| 315 | + loger.log('documentCommand失败,文档不存在', paramInfo); | ||
| 316 | + this._emit(MessageTypes.MCU_ERROR, MessageTypes.ERR_APE_INTERFACE_PARAM_WRONG); | ||
| 317 | + return; | ||
| 318 | + } | ||
| 319 | + //更新数据的字段 | ||
| 320 | + docDataModel.action = ApeConsts.DOC_ACTION_COMMAND; | ||
| 321 | + docDataModel.showType = parseInt(paramInfo.showType) || 0;//0;//完整显示;1;//按宽度显示;2;//按高度显示 | ||
| 322 | + this.updaterDoc(docDataModel, docDataModel.itemIdx); | ||
| 299 | } | 323 | } |
| 300 | - this.updaterDoc(docDataModel,docDataModel.itemIdx); | ||
| 301 | - } | ||
| 302 | - | ||
| 303 | - //缩放/滚动/显示模式 | ||
| 304 | - documentCommand(paramInfo){ | ||
| 305 | - //获取已经存在的数据 | ||
| 306 | - let docDataModel= this.docList[paramInfo.itemIdx]; | ||
| 307 | - if(docDataModel==null){ | ||
| 308 | - loger.log('documentCommand失败,文档不存在',paramInfo); | ||
| 309 | - this._emit(MessageTypes.MCU_ERROR,MessageTypes.ERR_APE_INTERFACE_PARAM_WRONG); | ||
| 310 | - return; | 324 | + |
| 325 | + //删除所有文档 | ||
| 326 | + documentDeleteAll(_param) { | ||
| 327 | + for (let key in this.docList) { | ||
| 328 | + //console.log("key:"+key); | ||
| 329 | + loger.log("删除文档数据,itemIdx:" + key); | ||
| 330 | + this.documentDelete({"itemIdx": key}); | ||
| 331 | + } | ||
| 311 | } | 332 | } |
| 312 | - //更新数据的字段 | ||
| 313 | - docDataModel.action=ApeConsts.DOC_ACTION_COMMAND; | ||
| 314 | - docDataModel.showType=parseInt(paramInfo.showType)||0;//0;//完整显示;1;//按宽度显示;2;//按高度显示 | ||
| 315 | - this.updaterDoc(docDataModel,docDataModel.itemIdx); | ||
| 316 | - } | ||
| 317 | - | ||
| 318 | - //删除所有文档 | ||
| 319 | - documentDeleteAll(_param){ | ||
| 320 | - for (let key in this.docList){ | ||
| 321 | - //console.log("key:"+key); | ||
| 322 | - loger.log("删除文档数据,itemIdx:"+key); | ||
| 323 | - this.documentDelete({"itemIdx":key}); | 333 | + |
| 334 | + //删除文档 | ||
| 335 | + documentDelete(paramInfo) { | ||
| 336 | + //{"itemIdx":itemIdx} | ||
| 337 | + let tableDeleteItemPdu = new pdu['RCRegistryTableDeleteItemPdu']; | ||
| 338 | + //optional RCPduType_E type = 1 [default = RCPDU_REG_TABLE_DELETE_PDU]; | ||
| 339 | + // repeated uint32 item_idx = 2; | ||
| 340 | + tableDeleteItemPdu.type = pdu.RCPDU_REG_TABLE_DELETE_PDU;// | ||
| 341 | + tableDeleteItemPdu.itemIdx = parseInt(paramInfo.itemIdx);//这里需要设置要删除的数据的itemIdx,每条数据的这个id都不一样 | ||
| 342 | + | ||
| 343 | + let updateObjPdu = new pdu['RCRegistryUpdateObjPdu']; | ||
| 344 | + updateObjPdu.objId = ApeConsts.DOCSHARING_OBJ_TABLE_ID;// updateObjPdu.objId = ApeConsts.DOCSHARING_OBJ_TABLE_ID_H5; | ||
| 345 | + updateObjPdu.subType = tableDeleteItemPdu.type; | ||
| 346 | + updateObjPdu.userData = tableDeleteItemPdu.toArrayBuffer(); | ||
| 347 | + | ||
| 348 | + //同步 | ||
| 349 | + let adapterItemPdu = new pdu['RCAdapterItemPdu']; | ||
| 350 | + adapterItemPdu.type = pdu.RCPDU_REG_UPDATE_OBJ; | ||
| 351 | + adapterItemPdu.itemData = updateObjPdu.toArrayBuffer(); | ||
| 352 | + | ||
| 353 | + let adapterPdu = new pdu['RCAdapterPdu']; | ||
| 354 | + adapterPdu.type = pdu.RCPDU_REG_ADAPTER; | ||
| 355 | + adapterPdu.item.push(adapterItemPdu); | ||
| 356 | + | ||
| 357 | + loger.log("文档发送删除数据=============" + tableDeleteItemPdu.itemIdx); | ||
| 358 | + this.sendUniform(adapterPdu, true); | ||
| 324 | } | 359 | } |
| 325 | - } | ||
| 326 | - | ||
| 327 | - //删除文档 | ||
| 328 | - documentDelete(paramInfo){ | ||
| 329 | - //{"itemIdx":itemIdx} | ||
| 330 | - let tableDeleteItemPdu = new pdu['RCRegistryTableDeleteItemPdu']; | ||
| 331 | - //optional RCPduType_E type = 1 [default = RCPDU_REG_TABLE_DELETE_PDU]; | ||
| 332 | - // repeated uint32 item_idx = 2; | ||
| 333 | - tableDeleteItemPdu.type = pdu.RCPDU_REG_TABLE_DELETE_PDU;// | ||
| 334 | - tableDeleteItemPdu.itemIdx=parseInt(paramInfo.itemIdx);//这里需要设置要删除的数据的itemIdx,每条数据的这个id都不一样 | ||
| 335 | - | ||
| 336 | - let updateObjPdu = new pdu['RCRegistryUpdateObjPdu']; | ||
| 337 | - updateObjPdu.objId = ApeConsts.DOCSHARING_OBJ_TABLE_ID;// updateObjPdu.objId = ApeConsts.DOCSHARING_OBJ_TABLE_ID_H5; | ||
| 338 | - updateObjPdu.subType = tableDeleteItemPdu.type; | ||
| 339 | - updateObjPdu.userData = tableDeleteItemPdu.toArrayBuffer(); | ||
| 340 | - | ||
| 341 | - //同步 | ||
| 342 | - let adapterItemPdu = new pdu['RCAdapterItemPdu']; | ||
| 343 | - adapterItemPdu.type = pdu.RCPDU_REG_UPDATE_OBJ; | ||
| 344 | - adapterItemPdu.itemData = updateObjPdu.toArrayBuffer(); | ||
| 345 | - | ||
| 346 | - let adapterPdu = new pdu['RCAdapterPdu']; | ||
| 347 | - adapterPdu.type = pdu.RCPDU_REG_ADAPTER; | ||
| 348 | - adapterPdu.item.push(adapterItemPdu); | ||
| 349 | - | ||
| 350 | - loger.log("文档发送删除数据============="+tableDeleteItemPdu.itemIdx); | ||
| 351 | - this.sendUniform(adapterPdu,true); | ||
| 352 | - } | ||
| 353 | - | ||
| 354 | - /////收到消息处理///////////////////////////////////////////////////////////////////////////////// | ||
| 355 | - tableInsertHandler(owner, itemIdx, itemData) { | ||
| 356 | - //this.tableUpdateHandler(owner, tableId, itemData); | ||
| 357 | - //loger.log('tableInsertHandler---',itemData); | ||
| 358 | - let itemDataInfo = this.unPackPdu(owner, itemIdx, itemData); | ||
| 359 | - this.docList[itemIdx] = itemDataInfo; | ||
| 360 | - | ||
| 361 | - if(itemDataInfo.visible=="true"||itemDataInfo.visible==true){ | ||
| 362 | - GlobalConfig.activeDocId=itemDataInfo.itemIdx;//当前激活的文档ID | ||
| 363 | - GlobalConfig.activeDocCurPage=itemDataInfo.curPageNo;//当前激活的文档的当前页 | ||
| 364 | - loger.log('tableInsertHandler 设置当前激活的文档id'); | 360 | + |
| 361 | + /////收到消息处理///////////////////////////////////////////////////////////////////////////////// | ||
| 362 | + tableInsertHandler(owner, itemIdx, itemData) { | ||
| 363 | + //this.tableUpdateHandler(owner, tableId, itemData); | ||
| 364 | + //loger.log('tableInsertHandler---',itemData); | ||
| 365 | + let itemDataInfo = this.unPackPdu(owner, itemIdx, itemData); | ||
| 366 | + this.docList[itemIdx] = itemDataInfo; | ||
| 367 | + | ||
| 368 | + if (itemDataInfo.visible == "true" || itemDataInfo.visible == true) { | ||
| 369 | + GlobalConfig.activeDocId = itemDataInfo.itemIdx;//当前激活的文档ID | ||
| 370 | + GlobalConfig.activeDocCurPage = itemDataInfo.curPageNo;//当前激活的文档的当前页 | ||
| 371 | + loger.log('tableInsertHandler 设置当前激活的文档id'); | ||
| 372 | + } | ||
| 373 | + loger.log('tableInsertHandler->', itemDataInfo); | ||
| 374 | + this._emit(MessageTypes.DOC_UPDATE, itemDataInfo);//用添加和更新都统一DOC_UPDATE | ||
| 375 | + | ||
| 376 | + //文档数据更新完毕,如果当前没有显示的文档,默认选择一个显示 | ||
| 377 | + if (GlobalConfig.activeDocId < 1 && itemDataInfo) { | ||
| 378 | + let paramInfo = { | ||
| 379 | + "itemIdx": itemDataInfo.itemIdx, | ||
| 380 | + "visible": true | ||
| 381 | + }; | ||
| 382 | + this.documentSwitchDoc(paramInfo); | ||
| 383 | + } | ||
| 365 | } | 384 | } |
| 366 | 385 | ||
| 367 | - loger.log('tableInsertHandler 发送给客户端'); | ||
| 368 | - loger.log(itemDataInfo); | ||
| 369 | - this._emit(MessageTypes.DOC_UPDATE,itemDataInfo);//用添加和更新都统一DOC_UPDATE | ||
| 370 | - } | ||
| 371 | - | ||
| 372 | - tableDeleteHandler(object_id, tableDeleteData){ | ||
| 373 | - loger.log('tableDeleteHandler',object_id,tableDeleteData);//["tableDeleteHandler",1179649,{"type":231,"itemIdx":[1486301768]}] | ||
| 374 | - if(tableDeleteData&&tableDeleteData.itemIdx){ | ||
| 375 | - let len=tableDeleteData.itemIdx.length; | ||
| 376 | - let itemIdxs=tableDeleteData.itemIdx; | ||
| 377 | - for (let i=0;i<len;i++){ | ||
| 378 | - if(this.docList[itemIdxs[i]]){ | ||
| 379 | - loger.log("删除文档数据:",itemIdxs[i]); | ||
| 380 | - //this._emit(MessageTypes.DOC_DELETE, {"itemIdx": itemIdxs[i]}); | ||
| 381 | - let itemDataInfo=this.docList[itemIdxs[i]]; | ||
| 382 | - if(itemDataInfo&&(itemDataInfo.visible=="true"||itemDataInfo.visible==true)){ | ||
| 383 | - GlobalConfig.activeDocId=0;//当前激活的文档ID | ||
| 384 | - GlobalConfig.activeDocCurPage=1;//当前激活的文档的当前页 | ||
| 385 | - loger.log('tableDeleteHandler 设置当前激活的文档id'); | ||
| 386 | - } | ||
| 387 | - this._emit(MessageTypes.DOC_DELETE, {"itemIdx": itemIdxs[i]}); | ||
| 388 | - delete this.docList[itemIdxs[i]]; | ||
| 389 | - } | ||
| 390 | - } | 386 | + tableDeleteHandler(object_id, tableDeleteData) { |
| 387 | + loger.log('tableDeleteHandler', object_id, tableDeleteData);//["tableDeleteHandler",1179649,{"type":231,"itemIdx":[1486301768]}] | ||
| 388 | + if (tableDeleteData && tableDeleteData.itemIdx) { | ||
| 389 | + let len = tableDeleteData.itemIdx.length; | ||
| 390 | + let itemIdxs = tableDeleteData.itemIdx; | ||
| 391 | + for (let i = 0; i < len; i++) { | ||
| 392 | + if (this.docList[itemIdxs[i]]) { | ||
| 393 | + loger.log("删除文档数据:", itemIdxs[i]); | ||
| 394 | + //this._emit(MessageTypes.DOC_DELETE, {"itemIdx": itemIdxs[i]}); | ||
| 395 | + let itemDataInfo = this.docList[itemIdxs[i]]; | ||
| 396 | + if (itemDataInfo && (itemDataInfo.visible == "true" || itemDataInfo.visible == true)) { | ||
| 397 | + GlobalConfig.activeDocId = 0;//当前激活的文档ID | ||
| 398 | + GlobalConfig.activeDocCurPage = 1;//当前激活的文档的当前页 | ||
| 399 | + loger.log('tableDeleteHandler->当前显示的文档'); | ||
| 400 | + } | ||
| 401 | + this._emit(MessageTypes.DOC_DELETE, {"itemIdx": itemIdxs[i]}); | ||
| 402 | + delete this.docList[itemIdxs[i]]; | ||
| 403 | + } | ||
| 404 | + } | ||
| 405 | + } | ||
| 391 | } | 406 | } |
| 392 | - } | ||
| 393 | - tableUpdateHandler(owner, itemIdx, itemData) { | ||
| 394 | - //let itemDataInfo = pdu['RCDocSendDataRequestPdu'].decode(itemData); | ||
| 395 | - let itemDataInfo = this.unPackPdu(owner, itemIdx, itemData); | ||
| 396 | - if(itemDataInfo!=null){ | ||
| 397 | - this.docList[itemIdx] = itemDataInfo; | ||
| 398 | - | ||
| 399 | -/* switch (itemDataInfo.action){ | ||
| 400 | - case DOC_ACTION_SWITCH_DOC: | ||
| 401 | - break; | ||
| 402 | - case DOC_ACTION_COMMAND: | ||
| 403 | - break; | ||
| 404 | - case DOC_ACTION_NORMAL: | ||
| 405 | - break; | ||
| 406 | - default : | ||
| 407 | - break; | ||
| 408 | - }*/ | ||
| 409 | - //GlobalConfig.activeDocId=0;//默认id | ||
| 410 | - // GlobalConfig.activeDocCurPage=1;//默认页数 | ||
| 411 | - if(itemDataInfo&&(itemDataInfo.visible=="true"||itemDataInfo.visible==true)){ | ||
| 412 | - GlobalConfig.activeDocId=itemDataInfo.itemIdx;//当前激活的文档ID | ||
| 413 | - GlobalConfig.activeDocCurPage=itemDataInfo.curPageNo;//当前激活的文档的当前页 | ||
| 414 | - loger.log('tableUpdateHandler 设置当前激活的文档id'); | ||
| 415 | - } | ||
| 416 | - loger.log('tableUpdateHandler 发送给客户端'); | ||
| 417 | - loger.log(itemDataInfo); | ||
| 418 | - this._emit(MessageTypes.DOC_UPDATE,itemDataInfo); | ||
| 419 | - | ||
| 420 | - }else { | ||
| 421 | - loger.log('tableUpdateHandler 数据无效--> itemIdx',itemIdx); | 407 | + |
| 408 | + tableUpdateHandler(owner, itemIdx, itemData) { | ||
| 409 | + //这个方法废弃,更新用tableUpdateApeHandler方法 | ||
| 410 | + /* let itemDataInfo = this.unPackPdu(owner, itemIdx, itemData); | ||
| 411 | + if(itemDataInfo!=null){ | ||
| 412 | + this.docList[itemIdx] = itemDataInfo; | ||
| 413 | + if(itemDataInfo&&(itemDataInfo.visible=="true"||itemDataInfo.visible==true)){ | ||
| 414 | + GlobalConfig.activeDocId=itemDataInfo.itemIdx;//当前激活的文档ID | ||
| 415 | + GlobalConfig.activeDocCurPage=itemDataInfo.curPageNo;//当前激活的文档的当前页 | ||
| 416 | + loger.log('tableUpdateHandler 设置当前激活的文档id'); | ||
| 417 | + } | ||
| 418 | + loger.log('tableUpdateHandler 发送给客户端'); | ||
| 419 | + loger.log(itemDataInfo); | ||
| 420 | + this._emit(MessageTypes.DOC_UPDATE,itemDataInfo); | ||
| 421 | + | ||
| 422 | + }else { | ||
| 423 | + loger.log('tableUpdateHandler 数据无效--> itemIdx',itemIdx); | ||
| 424 | + }*/ | ||
| 422 | } | 425 | } |
| 423 | 426 | ||
| 424 | - } | ||
| 425 | - onJoinChannelHandlerSuccess(){ | ||
| 426 | - loger.log(this._session_name + ' onJoinChannelHandlerSuccess==========================='); | ||
| 427 | - if (this._apeDelayed) { | ||
| 428 | - // this._apeDelayedMsgs.push(regBuffer); | ||
| 429 | - // this._apeDelayedStart(); | ||
| 430 | - setTimeout(() => { | ||
| 431 | - this._emit(DocApe.DOC_JOIN_CHANNEL_SUCCESS); | ||
| 432 | - },(GlobalConfig.mcuDelay+GlobalConfig.docDelay)|| 12000+GlobalConfig.docDelay); | ||
| 433 | - }else { | ||
| 434 | - setTimeout(() => { | ||
| 435 | - this._emit(DocApe.DOC_JOIN_CHANNEL_SUCCESS); | ||
| 436 | - },GlobalConfig.docDelay); | 427 | + tableUpdateApeHandler(_tableUpdateItems, _seekTime) { |
| 428 | + let tableUpdateItemsLen = _tableUpdateItems.length; | ||
| 429 | + loger.log('tableUpdateApeHandler', "activeDocId->", GlobalConfig.activeDocId, "tableUpdateItemsLen->", tableUpdateItemsLen); | ||
| 430 | + for (let i = 0; i < tableUpdateItemsLen; ++i) { | ||
| 431 | + let tableItem = _tableUpdateItems[i]; | ||
| 432 | + let itemDataInfo = this.unPackPdu(tableItem.owner, tableItem.itemIdx, tableItem.itemData); | ||
| 433 | + if (itemDataInfo != null) { | ||
| 434 | + this.docList[tableItem.itemIdx] = itemDataInfo; | ||
| 435 | + if (itemDataInfo && (itemDataInfo.visible == "true" || itemDataInfo.visible == true)) { | ||
| 436 | + GlobalConfig.activeDocId = itemDataInfo.itemIdx;//当前激活的文档ID | ||
| 437 | + GlobalConfig.activeDocCurPage = itemDataInfo.curPageNo;//当前激活的文档的当前页 | ||
| 438 | + loger.log('tableUpdateHandler 设置当前激活的文档id->', GlobalConfig.activeDocId, "curPageNum->", GlobalConfig.activeDocCurPage); | ||
| 439 | + } | ||
| 440 | + loger.log('doc->', itemDataInfo); | ||
| 441 | + this._emit(MessageTypes.DOC_UPDATE, itemDataInfo); | ||
| 442 | + } else { | ||
| 443 | + loger.log('tableUpdateHandler 数据无效--> itemIdx', itemIdx); | ||
| 444 | + } | ||
| 445 | + } | ||
| 446 | + this._showDefaultDoc(); | ||
| 437 | } | 447 | } |
| 438 | - } | ||
| 439 | 448 | ||
| 440 | - //检查文档是否已经存在,如果存在 返回true,否则返回false | ||
| 441 | - checkDocId(_docId){ | ||
| 442 | - if(_docId==null){ | ||
| 443 | - loger.warn('checkDocId _docId参数为null'); | ||
| 444 | - return true; | 449 | + //果当前没有显示的文档,默认选择一个显示文档 |
| 450 | + _showDefaultDoc() { | ||
| 451 | + //显示默认文档条件->1.非录制回放状态下 2.只有host有权限操作 3.当前激活的文档id不为0 | ||
| 452 | + if (GlobalConfig.isRecordPlayBack || !GlobalConfig.isHost || GlobalConfig.activeDocId > 0) { | ||
| 453 | + return; | ||
| 454 | + } | ||
| 455 | + | ||
| 456 | + let tempDocItemIdx;//临时记录文档数据,用于显示默认文档 | ||
| 457 | + for (let key in this.docList) { | ||
| 458 | + tempDocItemIdx= this.docList[key]; | ||
| 459 | + if (tempDocItemIdx) { | ||
| 460 | + loger.log("选择一个文档作为默认文档显示->", tempDocItemIdx); | ||
| 461 | + let paramInfo = { | ||
| 462 | + "itemIdx": tempDocItemIdx, | ||
| 463 | + "visible": true | ||
| 464 | + }; | ||
| 465 | + this.documentSwitchDoc(paramInfo); | ||
| 466 | + //选择完成就跳出循环 | ||
| 467 | + return; | ||
| 468 | + } | ||
| 469 | + } | ||
| 445 | } | 470 | } |
| 446 | - //遍历查找 | ||
| 447 | - for (let key in this.docList){ | ||
| 448 | - let item=this.docList[key]; | ||
| 449 | - loger.log('item.docId==============_docId',item.docId,_docId); | ||
| 450 | - if(item&&item.docId==_docId){ | ||
| 451 | - return true; | ||
| 452 | - } | 471 | + |
| 472 | + onJoinChannelHandlerSuccess() { | ||
| 473 | + loger.log(this._session_name + ' onJoinChannelHandlerSuccess==========================='); | ||
| 474 | + if (this._apeDelayed) { | ||
| 475 | + // this._apeDelayedMsgs.push(regBuffer); | ||
| 476 | + // this._apeDelayedStart(); | ||
| 477 | + setTimeout(() => { | ||
| 478 | + this._emit(DocApe.DOC_JOIN_CHANNEL_SUCCESS); | ||
| 479 | + }, (GlobalConfig.mcuDelay + GlobalConfig.docDelay) || 12000 + GlobalConfig.docDelay); | ||
| 480 | + } else { | ||
| 481 | + setTimeout(() => { | ||
| 482 | + this._emit(DocApe.DOC_JOIN_CHANNEL_SUCCESS); | ||
| 483 | + }, GlobalConfig.docDelay); | ||
| 484 | + } | ||
| 453 | } | 485 | } |
| 454 | 486 | ||
| 455 | - //储存的数据中没有查找到 | ||
| 456 | - return false; | ||
| 457 | - } | ||
| 458 | - | ||
| 459 | - ///////数据的封包和解包///////////////////////////////////////// | ||
| 460 | - packPdu(_param,_itemIdx){ | ||
| 461 | - loger.log("文档===packPdu "); | ||
| 462 | - //验证坐标点集合数组是否合法 | ||
| 463 | - if(_param==null||_itemIdx==null){ | ||
| 464 | - this._emit(MessageTypes.MCU_ERROR,MessageTypes.ERR_APE_INTERFACE_PARAM_WRONG); | ||
| 465 | - return null; | 487 | + //检查文档是否已经存在,如果存在 返回true,否则返回false |
| 488 | + checkDocId(_docId) { | ||
| 489 | + if (_docId == null) { | ||
| 490 | + loger.warn('checkDocId _docId参数为null'); | ||
| 491 | + return true; | ||
| 492 | + } | ||
| 493 | + //遍历查找 | ||
| 494 | + for (let key in this.docList) { | ||
| 495 | + let item = this.docList[key]; | ||
| 496 | + loger.log('item.docId==============_docId', item.docId, _docId); | ||
| 497 | + if (item && item.docId == _docId) { | ||
| 498 | + return true; | ||
| 499 | + } | ||
| 500 | + } | ||
| 501 | + | ||
| 502 | + //储存的数据中没有查找到 | ||
| 503 | + return false; | ||
| 466 | } | 504 | } |
| 467 | 505 | ||
| 468 | - /* message RCDocSendDataModelPdu { | ||
| 469 | - required uint32 item_idx=1;//唯一标识 | ||
| 470 | - required uint32 owner=2; | ||
| 471 | - optional uint32 from=3; | ||
| 472 | - optional uint32 cur_page_no=4; | ||
| 473 | - optional uint32 page_num =5; | ||
| 474 | - optional string file_type=6; | ||
| 475 | - optional string creat_user_id=7;//创建文档userid | ||
| 476 | - optional string relative_url=8;//文档相对地址 | ||
| 477 | - optional string url =9;//文档地址 | ||
| 478 | - optional uint32 cur_V=10; | ||
| 479 | - optional uint32 cur_H=11; | ||
| 480 | - optional uint32 scale=12; | ||
| 481 | - optional bool visible=13; | ||
| 482 | - optional uint32 action=14;//0,无操作, 1翻页 /缩放/滚动、2.显示/隐藏 | ||
| 483 | - optional string doc_id=15;//文档在服务器数据库中的唯一id | ||
| 484 | - optional string file_name=16;//文档的名字 | ||
| 485 | - optional string dynamic_TS=17;//"dynamicTransferStatic": "0" | ||
| 486 | - optional string md5=18;//md5 | ||
| 487 | - optional uint32 show_type=19;//显示模式 | ||
| 488 | - }*/ | ||
| 489 | - | ||
| 490 | - //判断type类型,根据type设置不同的参数 | ||
| 491 | - let docModelPdu =new pdu['RCDocSendDataModelPdu']; | ||
| 492 | - docModelPdu.itemIdx=_itemIdx; | ||
| 493 | - docModelPdu.owner=GlobalConfig.nodeId; | ||
| 494 | - docModelPdu.from=GlobalConfig.nodeId; | ||
| 495 | - docModelPdu.curPageNo = _param.curPageNo||1; | ||
| 496 | - docModelPdu.pageNum = _param.pageNum||1; | ||
| 497 | - docModelPdu.fileType=_param.fileType||""; | ||
| 498 | - docModelPdu.creatUserId=_param.creatUserId||"0"; | ||
| 499 | - docModelPdu.url ="";//这个地址没用到,数据太长占用资源 暂停使用//"http://101.200.150.192/DocSharing/data/h5test/20170206-171100025/7e9c4178cac1133e0dd9d5b583439122.jpg"; | ||
| 500 | - docModelPdu.relativeUrl=_param.relativeUrl||"";//"/DocSharing/data/h5test/20170206-171100025/7e9c4178cac1133e0dd9d5b583439122.jpg"; | ||
| 501 | - docModelPdu.curV=_param.curV||0; | ||
| 502 | - docModelPdu.curH=_param.curH||0; | ||
| 503 | - docModelPdu.scale=_param.scale||100;//按百分比 | ||
| 504 | - docModelPdu.visible= _param.visible||false; | ||
| 505 | - docModelPdu.action=_param.action||ApeConsts.DOC_ACTION_NORMAL;//0,无操作, 1翻页、2.显示/隐藏, 3缩放/滚动 | ||
| 506 | - docModelPdu.docId=_param.docId||"";//文档在服务器数据库中的唯一id,必须有 | ||
| 507 | - docModelPdu.md5=_param.md5||"";//MD5 | ||
| 508 | - docModelPdu.fileName=_param.fileName||"doc_"+_itemIdx;//文档的名字 | ||
| 509 | - docModelPdu.dynamicTS=_param.dynamicTS||"0";//文档上传后返回值中的字段dynamicTransferStatic | ||
| 510 | - docModelPdu.showType=_param.showType||0;//文档显示模式 | ||
| 511 | - loger.log(docModelPdu); | ||
| 512 | - return docModelPdu; | ||
| 513 | - } | ||
| 514 | - | ||
| 515 | - unPackPdu(owner, itemIdx,itemData){ | ||
| 516 | - loger.log("文档===unPackPdu "); | ||
| 517 | - if(owner==null||itemIdx==null||itemData==null){ | ||
| 518 | - this._emit(MessageTypes.MCU_ERROR,MessageTypes.ERR_APE_INTERFACE_PARAM_WRONG); | ||
| 519 | - return null; | 506 | + ///////数据的封包和解包///////////////////////////////////////// |
| 507 | + packPdu(_param, _itemIdx) { | ||
| 508 | + loger.log("文档===packPdu "); | ||
| 509 | + //验证坐标点集合数组是否合法 | ||
| 510 | + if (_param == null || _itemIdx == null) { | ||
| 511 | + this._emit(MessageTypes.MCU_ERROR, MessageTypes.ERR_APE_INTERFACE_PARAM_WRONG); | ||
| 512 | + return null; | ||
| 513 | + } | ||
| 514 | + | ||
| 515 | + /* message RCDocSendDataModelPdu { | ||
| 516 | + required uint32 item_idx=1;//唯一标识 | ||
| 517 | + required uint32 owner=2; | ||
| 518 | + optional uint32 from=3; | ||
| 519 | + optional uint32 cur_page_no=4; | ||
| 520 | + optional uint32 page_num =5; | ||
| 521 | + optional string file_type=6; | ||
| 522 | + optional string creat_user_id=7;//创建文档userid | ||
| 523 | + optional string relative_url=8;//文档相对地址 | ||
| 524 | + optional string url =9;//文档地址 | ||
| 525 | + optional uint32 cur_V=10; | ||
| 526 | + optional uint32 cur_H=11; | ||
| 527 | + optional uint32 scale=12; | ||
| 528 | + optional bool visible=13; | ||
| 529 | + optional uint32 action=14;//0,无操作, 1翻页 /缩放/滚动、2.显示/隐藏 | ||
| 530 | + optional string doc_id=15;//文档在服务器数据库中的唯一id | ||
| 531 | + optional string file_name=16;//文档的名字 | ||
| 532 | + optional string dynamic_TS=17;//"dynamicTransferStatic": "0" | ||
| 533 | + optional string md5=18;//md5 | ||
| 534 | + optional uint32 show_type=19;//显示模式 | ||
| 535 | + }*/ | ||
| 536 | + | ||
| 537 | + //判断type类型,根据type设置不同的参数 | ||
| 538 | + let docModelPdu = new pdu['RCDocSendDataModelPdu']; | ||
| 539 | + docModelPdu.itemIdx = _itemIdx; | ||
| 540 | + docModelPdu.owner = GlobalConfig.nodeId; | ||
| 541 | + docModelPdu.from = GlobalConfig.nodeId; | ||
| 542 | + docModelPdu.curPageNo = _param.curPageNo || 1; | ||
| 543 | + docModelPdu.pageNum = _param.pageNum || 1; | ||
| 544 | + docModelPdu.fileType = _param.fileType || ""; | ||
| 545 | + docModelPdu.creatUserId = _param.creatUserId || "0"; | ||
| 546 | + docModelPdu.url = "";//这个地址没用到,数据太长占用资源 暂停使用//"http://101.200.150.192/DocSharing/data/h5test/20170206-171100025/7e9c4178cac1133e0dd9d5b583439122.jpg"; | ||
| 547 | + docModelPdu.relativeUrl = _param.relativeUrl || "";//"/DocSharing/data/h5test/20170206-171100025/7e9c4178cac1133e0dd9d5b583439122.jpg"; | ||
| 548 | + docModelPdu.curV = _param.curV || 0; | ||
| 549 | + docModelPdu.curH = _param.curH || 0; | ||
| 550 | + docModelPdu.scale = _param.scale || 100;//按百分比 | ||
| 551 | + docModelPdu.visible = _param.visible || false; | ||
| 552 | + docModelPdu.action = _param.action || ApeConsts.DOC_ACTION_NORMAL;//0,无操作, 1翻页、2.显示/隐藏, 3缩放/滚动 | ||
| 553 | + docModelPdu.docId = _param.docId || "";//文档在服务器数据库中的唯一id,必须有 | ||
| 554 | + docModelPdu.md5 = _param.md5 || "";//MD5 | ||
| 555 | + docModelPdu.fileName = _param.fileName || "doc_" + _itemIdx;//文档的名字 | ||
| 556 | + docModelPdu.dynamicTS = _param.dynamicTS || "0";//文档上传后返回值中的字段dynamicTransferStatic | ||
| 557 | + docModelPdu.showType = _param.showType || 0;//文档显示模式 | ||
| 558 | + loger.log(docModelPdu); | ||
| 559 | + return docModelPdu; | ||
| 520 | } | 560 | } |
| 521 | 561 | ||
| 522 | - try{ | ||
| 523 | - let docModelPdu= pdu['RCDocSendDataModelPdu'].decode(itemData); | ||
| 524 | - //loger.log(docModelPdu); | ||
| 525 | - return docModelPdu; | ||
| 526 | - }catch (err){ | ||
| 527 | - loger.log("文档收到数据 unPackPdu Pdu解析错误,itemIdx="+itemIdx+" err:"+err.message); | 562 | + unPackPdu(owner, itemIdx, itemData) { |
| 563 | + loger.log("文档===unPackPdu "); | ||
| 564 | + if (owner == null || itemIdx == null || itemData == null) { | ||
| 565 | + this._emit(MessageTypes.MCU_ERROR, MessageTypes.ERR_APE_INTERFACE_PARAM_WRONG); | ||
| 566 | + return null; | ||
| 567 | + } | ||
| 568 | + | ||
| 569 | + try { | ||
| 570 | + let docModelPdu = pdu['RCDocSendDataModelPdu'].decode(itemData); | ||
| 571 | + //loger.log(docModelPdu); | ||
| 572 | + return docModelPdu; | ||
| 573 | + } catch (err) { | ||
| 574 | + loger.log("文档收到数据 unPackPdu Pdu解析错误,itemIdx=" + itemIdx + " err:" + err.message); | ||
| 575 | + } | ||
| 576 | + return null; | ||
| 528 | } | 577 | } |
| 529 | - return null; | ||
| 530 | - } | ||
| 531 | 578 | ||
| 532 | 579 | ||
| 533 | } | 580 | } |
-
请 注册 或 登录 后发表评论