李勇

1.修改白板模块的对外接口,简化外部事件的监听

此 diff 太大无法显示。
... ... @@ -115,6 +115,7 @@ export default class MessageEntrance extends Emiter {
this.sendInsertAnnotaion=this._sendInsertAnnotaion;
this.sendDeleteAnnotaion=this._sendDeleteAnnotaion;
this.sendDeleteAllAnnotation=this._sendDeleteAllAnnotation;
this.sendGotoPrev=this._sendGotoPrev;
//DocApe
this.sendDocumentUpload= this._sendDocumentUpload;//上传文档
... ... @@ -475,6 +476,13 @@ export default class MessageEntrance extends Emiter {
_whiteboard_ape.sendDeleteAllAnnotation(_param);
}
}
//返回上一步标注
_sendGotoPrev(_param){
if(_whiteboard_ape){
_whiteboard_ape.gotoPrev(_param);
}
}
//DocApe
//上传文档
... ...
... ... @@ -47,10 +47,11 @@ MessageTypes.DOC_UPDATE = 'document.update';//更新文档
MessageTypes.DOC_DELETE='document.delete';//删除文档
MessageTypes.DOC_ANNOTATION = 'document.annotation';//笔记
//笔记事件定义
//白板笔记事件定义
MessageTypes.WHITEBOARD_ANNOTATION_UPDATE = 'whiteboard.annotation.update';
MessageTypes.WHITEBOARD_ANNOTAION_INSERT = 'whiteboard.annotation.insert';
MessageTypes.WHITEBOARD_ANNOTAION_DELETE = 'whiteboard.annotation.delete';
//MessageTypes.WHITEBOARD_ANNOTAION_INSERT = 'whiteboard.annotation.insert';
//MessageTypes.WHITEBOARD_ANNOTAION_DELETE = 'whiteboard.annotation.delete';
//MessageTypes.WHITEBOARD_ANNOTATION_CLEAR = 'whiteboard.annotation.clear';
//音频
... ...
... ... @@ -160,7 +160,7 @@ export default class Ape extends Emiter {
let tableInsertItemsLen = tableInsertItems.length;
for (let i = 0; i < tableInsertItemsLen; ++i) {
let insertItem = tableInsertItems[i];
console.log("insertItem",insertItem);
loger.log("insertItem",insertItem);
this.tableInsertHandler(insertItem.owner, insertItem.itemIdx, insertItem.itemData);
}
break;
... ... @@ -173,7 +173,7 @@ export default class Ape extends Emiter {
let tableUpdateData = pdu['RCRegistryTableUpdateItemPdu'].decode(user_data);
let tableUpdateItems = tableUpdateData.items;
let tableUpdateItemsLen= tableUpdateItems.length;
console.log("RCRegistryTableUpdateItemPdu "+tableUpdateItemsLen);
loger.log("RCRegistryTableUpdateItemPdu "+tableUpdateItemsLen);
console.log(tableUpdateData);
for (let i = 0; i < tableUpdateItemsLen; ++i) {
... ... @@ -209,7 +209,6 @@ export default class Ape extends Emiter {
tableDeleteHandler(tableId, record) {
loger.warn(this._session_name + ' tableDelHandler 应有子类具体覆盖处理.');
}
onJoinChannelHandlerSuccess(){
loger.warn(this._session_name + ' onJoinChannelHandlerSuccess 应有子类具体覆盖处理.');
}
... ...
... ... @@ -33,379 +33,344 @@ const TYPE_CIRCLE=3;//圆形
const TYPE_TEXT=4;//文本
class WhiteBoardApe extends Ape {
constructor() {
super(
ApeConsts.WHITEBOARD_SESSION_ID,
ApeConsts.WHITEBOARD_SESSION_NAME,
ApeConsts.WHITEBOARD_SESSION_TAG
);
// properties
this.annoInfos = {};
// 白板延迟
// this._apeDelayed = true;
//Ape Models
this.registerKey(this._session_id, this._session_name, this._session_tag, new ArrayBuffer);
this.registerObj(pdu.RCPDU_REG_REGISTER_TABLE, ApeConsts.WHITEBOARD_OBJ_TABLE_ID,
ApeConsts.WHITEBOARD_OBJ_TABLE_NAME, ApeConsts.WHITEBOARD_OBJ_TABLE_TAG, 0, new ArrayBuffer);
// ape listeners
this.on(pdu.RCPDU_SESSION_JOIN_RESPONSE, this._joinSessionHandler.bind(this));
//this.on(pdu.RCPDU_CONFERENCE_SEND_DATA_REQUEST, this.whiteboardMsgComingHandler.bind(this));//这个是会议消息类型,flash里在使用这里不再使用,各个模块的消息由模块自己来处理
}
_joinSessionHandler(_data) {
loger.log("RCPDU_SESSION_JOIN_RESPONSE");
}
/////////////发送数据操作//////////////////////////////////////////////////////
// 添加标注,发送信息
sendInsetAnnotaion(_param){
/* itemIdx=parseInt(Date.now()/1000);
let whiteBoardModelPdu =new pdu['RCWhiteBoardDataModel'];
whiteBoardModelPdu.id =itemIdx;
whiteBoardModelPdu.initiator =GlobalConfig.nodeId;
whiteBoardModelPdu.pointGroup =EngineUtils.arrayToJsonString([{"w":10,"h":20},{"w":10,"h":20},{"w":10,"h":20},{"w":10,"h":20}]);
whiteBoardModelPdu.type = 3;
*/
/* let whiteBoardModelPdu =new pdu['RCWhiteBoardDataModel'];
whiteBoardModelPdu.id =ApeConsts.WHITEBOARD_OBJ_TABLE_ID;
whiteBoardModelPdu.initiator =GlobalConfig.nodeId;
whiteBoardModelPdu.pointGroup =EngineUtils.arrayToJsonString([{"w":133,"h":20},{"w":1313,"h":20},{"w":313,"h":20},{"w":10,"h":20}]);
whiteBoardModelPdu.type = 3;
*/
if(_param==null||EngineUtils.isEmptyObject(_param)){
loger.log('sendInsetAnnotaion失败,参数错误');
this._emit(MessageTypes.MCU_ERROR,MessageTypes.ERR_APE_INTERFACE_PARAM_WRONG);
return ;
constructor() {
super(
ApeConsts.WHITEBOARD_SESSION_ID,
ApeConsts.WHITEBOARD_SESSION_NAME,
ApeConsts.WHITEBOARD_SESSION_TAG
);
// properties
this.annoInfos = {};//储存所有的标注数据
this.insertHistory=[];//添加的白板记录,用于撤回操作
// 白板延迟
// this._apeDelayed = true;
//Ape Models
this.registerKey(this._session_id, this._session_name, this._session_tag, new ArrayBuffer);
this.registerObj(pdu.RCPDU_REG_REGISTER_TABLE, ApeConsts.WHITEBOARD_OBJ_TABLE_ID,
ApeConsts.WHITEBOARD_OBJ_TABLE_NAME, ApeConsts.WHITEBOARD_OBJ_TABLE_TAG, 0, new ArrayBuffer);
// ape listeners
this.on(pdu.RCPDU_SESSION_JOIN_RESPONSE, this._joinSessionHandler.bind(this));
//this.on(pdu.RCPDU_CONFERENCE_SEND_DATA_REQUEST, this.whiteboardMsgComingHandler.bind(this));//这个是会议消息类型,flash里在使用这里不再使用,各个模块的消息由模块自己来处理
}
itemIdx=EngineUtils.creatTimestamp();
let whiteBoardModelPdu = this.packPdu(_param,itemIdx);
if(whiteBoardModelPdu==null){
loger.log('sendInsetAnnotaion失败,参数错误');
this._emit(MessageTypes.MCU_ERROR,MessageTypes.ERR_APE_INTERFACE_PARAM_WRONG);
return ;
}
console.log(whiteBoardModelPdu);
let tableItemPdu = new pdu['RCRegistryTableItemPdu'];
tableItemPdu.itemIdx=itemIdx;//直接用时间戳作为id
tableItemPdu.registerObjId=ApeConsts.WHITEBOARD_OBJ_TABLE_ID;
tableItemPdu.owner = 0;//收到flash的是这个值,不清楚先写固定
tableItemPdu.itemData =whiteBoardModelPdu.toArrayBuffer();
//insert
let tableInsertItemPdu = new pdu['RCRegistryTableInsertItemPdu'];
//optional RCPduType_E type = 1 [default = RCPDU_REG_TABLE_UPDATE_PDU];
//repeated RCRegistryTableItemPdu items = 2;
tableInsertItemPdu.type = pdu.RCPDU_REG_TABLE_INSERT_PDU;//
tableInsertItemPdu.items.push(tableItemPdu);
let updateObjPdu = new pdu['RCRegistryUpdateObjPdu'];
updateObjPdu.objId = ApeConsts.WHITEBOARD_OBJ_TABLE_ID;
updateObjPdu.subType = tableInsertItemPdu.type;
updateObjPdu.userData = tableInsertItemPdu.toArrayBuffer();
//同步
let adapterItemPdu = new pdu['RCAdapterItemPdu'];
adapterItemPdu.type = pdu.RCPDU_REG_UPDATE_OBJ;
adapterItemPdu.itemData = updateObjPdu.toArrayBuffer();
let adapterPdu = new pdu['RCAdapterPdu'];
adapterPdu.type = pdu.RCPDU_REG_ADAPTER;
adapterPdu.item.push(adapterItemPdu);
console.log("添加白板数据=====itemIdx="+tableItemPdu.itemIdx);
this.sendUniform(adapterPdu,true);
}
//删除所有标注
sendDeleteAllAnnotation(_param){
for (let key in this.annoInfos){
//console.log("key:"+key);
console.log("删除白板数据,itemIdx:"+key);
this.sendDeleteAnnotaion({"itemIdx":key});
_joinSessionHandler(_data) {
loger.log("RCPDU_SESSION_JOIN_RESPONSE");
this.insertHistory=[];
}
}
//删除标注,发送信息
sendDeleteAnnotaion(_param){
//{"itemIdx":itemIdx}
let tableDeleteItemPdu = new pdu['RCRegistryTableDeleteItemPdu'];
//optional RCPduType_E type = 1 [default = RCPDU_REG_TABLE_DELETE_PDU];
// repeated uint32 item_idx = 2;
tableDeleteItemPdu.type = pdu.RCPDU_REG_TABLE_DELETE_PDU;//
tableDeleteItemPdu.itemIdx=parseInt(_param.itemIdx);//这里需要设置要删除的数据的itemIdx,每条数据的这个id都不一样
let updateObjPdu = new pdu['RCRegistryUpdateObjPdu'];
updateObjPdu.objId = ApeConsts.WHITEBOARD_OBJ_TABLE_ID;
updateObjPdu.subType = tableDeleteItemPdu.type;
updateObjPdu.userData = tableDeleteItemPdu.toArrayBuffer();
//同步
let adapterItemPdu = new pdu['RCAdapterItemPdu'];
adapterItemPdu.type = pdu.RCPDU_REG_UPDATE_OBJ;
adapterItemPdu.itemData = updateObjPdu.toArrayBuffer();
let adapterPdu = new pdu['RCAdapterPdu'];
adapterPdu.type = pdu.RCPDU_REG_ADAPTER;
adapterPdu.item.push(adapterItemPdu);
console.log("白板发送删除数据============="+tableDeleteItemPdu.itemIdx);
this.sendUniform(adapterPdu,true);
}
//更新标注
sendUpdaterAnnotaion(_param){
if(_param==null||EngineUtils.isEmptyObject(_param)){
loger.log('sendUpdaterAnnotaion失败,参数错误');
this._emit(MessageTypes.MCU_ERROR,MessageTypes.ERR_APE_INTERFACE_PARAM_WRONG);
return ;
}
/* let whiteBoardModelPdu =new pdu['RCWhiteBoardDataModel'];
whiteBoardModelPdu.id =ApeConsts.WHITEBOARD_OBJ_TABLE_ID;
whiteBoardModelPdu.initiator =GlobalConfig.nodeId;
whiteBoardModelPdu.pointGroup =EngineUtils.arrayToJsonString([{"w":133,"h":20},{"w":1313,"h":20},{"w":313,"h":20},{"w":10,"h":20}]);
whiteBoardModelPdu.type = 3;
*/
itemIdx=_param.itemIdx;
let whiteBoardModelPdu = this.packPdu(_param,itemIdx);
//console.log(whiteBoardModelPdu);
if(whiteBoardModelPdu==null){
loger.log('sendInsetAnnotaion失败,参数错误');
this._emit(MessageTypes.MCU_ERROR,MessageTypes.ERR_APE_INTERFACE_PARAM_WRONG);
return ;
}
let tableItemPdu = new pdu['RCRegistryTableItemPdu'];
tableItemPdu.itemIdx=itemIdx;
tableItemPdu.owner = 0;//收到flash的是这个值,不清楚先写固定
tableItemPdu.registerObjId=ApeConsts.WHITEBOARD_OBJ_TABLE_ID;
tableItemPdu.itemData =whiteBoardModelPdu.toArrayBuffer();
//updater
let whiteBoardUpdateItem = new pdu['RCRegistryTableUpdateItemPdu'];
//optional RCPduType_E type = 1 [default = RCPDU_REG_TABLE_UPDATE_PDU];
//repeated RCRegistryTableItemPdu items = 2;
whiteBoardUpdateItem.type = pdu.RCPDU_REG_TABLE_UPDATE_PDU;//
whiteBoardUpdateItem.items.push(tableItemPdu);
let updateObjPdu = new pdu['RCRegistryUpdateObjPdu'];
updateObjPdu.objId = ApeConsts.WHITEBOARD_OBJ_TABLE_ID;
updateObjPdu.subType = whiteBoardUpdateItem.type;
updateObjPdu.userData = whiteBoardUpdateItem.toArrayBuffer();
//同步
let adapterItemPdu = new pdu['RCAdapterItemPdu'];
adapterItemPdu.type = pdu.RCPDU_REG_UPDATE_OBJ;
adapterItemPdu.itemData = updateObjPdu.toArrayBuffer();
let adapterPdu = new pdu['RCAdapterPdu'];
adapterPdu.type = pdu.RCPDU_REG_ADAPTER;
adapterPdu.item.push(adapterItemPdu);
console.log("白板发送更新数据===============22");
this.sendUniform(adapterPdu,true);
}
///////白板数据的封包和解包/////////////////////////////////////////
packPdu(_param,_itemIdx){
/* required uint32 type= 1;//白板类型
required uint32 id= 2;//id 每一次绘制的唯一标识
required uint32 initiator=3; //绘制来自谁
optional string pointGroup=4; //坐标点集数组的JSON字符串
optional string color= 5 [default = "#000000"]; //颜色
optional uint32 thickness= 6 ;//线条粗细
optional uint32 radius= 7;//园的半径
optional uint32 fontSize= 8;//字体大小
optional uint32 fontName= 9;//字体名称
optional uint32 text= 10;//文本内容*/
//验证坐标点集合数组是否合法
if(_param.pointGroup==null||_param.pointGroup.length<1){
this._emit(MessageTypes.MCU_ERROR,MessageTypes.ERR_APE_INTERFACE_PARAM_WRONG);
return null;
}
//判断type类型,根据type设置不同的参数
let whiteBoardModelPdu =new pdu['RCWhiteBoardDataModelPdu'];
switch (_param.type){
case TYPE_BIGHT:
break;
case TYPE_LINE:
break;
case TYPE_RECT:
/////////////发送数据操作//////////////////////////////////////////////////////
// 添加标注,发送信息
sendInsetAnnotaion(_param){
if(_param==null||EngineUtils.isEmptyObject(_param)){
loger.log('sendInsetAnnotaion失败,参数错误');
this._emit(MessageTypes.MCU_ERROR,MessageTypes.ERR_APE_INTERFACE_PARAM_WRONG);
return ;
}
itemIdx=EngineUtils.creatTimestamp();
let whiteBoardModelPdu = this.packPdu(_param,itemIdx);
if(whiteBoardModelPdu==null){
loger.log('sendInsetAnnotaion失败,参数错误');
this._emit(MessageTypes.MCU_ERROR,MessageTypes.ERR_APE_INTERFACE_PARAM_WRONG);
return ;
}
console.log(whiteBoardModelPdu);
//储存记录,用于返回上一步操作
this.insertHistory.push(whiteBoardModelPdu);
let tableItemPdu = new pdu['RCRegistryTableItemPdu'];
tableItemPdu.itemIdx=itemIdx;//直接用时间戳作为id
tableItemPdu.registerObjId=ApeConsts.WHITEBOARD_OBJ_TABLE_ID;
tableItemPdu.owner = 0;//收到flash的是这个值,不清楚先写固定
tableItemPdu.itemData =whiteBoardModelPdu.toArrayBuffer();
//insert
let tableInsertItemPdu = new pdu['RCRegistryTableInsertItemPdu'];
//optional RCPduType_E type = 1 [default = RCPDU_REG_TABLE_UPDATE_PDU];
//repeated RCRegistryTableItemPdu items = 2;
tableInsertItemPdu.type = pdu.RCPDU_REG_TABLE_INSERT_PDU;//
tableInsertItemPdu.items.push(tableItemPdu);
let updateObjPdu = new pdu['RCRegistryUpdateObjPdu'];
updateObjPdu.objId = ApeConsts.WHITEBOARD_OBJ_TABLE_ID;
updateObjPdu.subType = tableInsertItemPdu.type;
updateObjPdu.userData = tableInsertItemPdu.toArrayBuffer();
//同步
let adapterItemPdu = new pdu['RCAdapterItemPdu'];
adapterItemPdu.type = pdu.RCPDU_REG_UPDATE_OBJ;
adapterItemPdu.itemData = updateObjPdu.toArrayBuffer();
let adapterPdu = new pdu['RCAdapterPdu'];
adapterPdu.type = pdu.RCPDU_REG_ADAPTER;
adapterPdu.item.push(adapterItemPdu);
console.log("添加白板数据=====itemIdx="+tableItemPdu.itemIdx);
this.sendUniform(adapterPdu,true);
}
//撤销上一步
gotoPrev(){
loger.log("白板返回上一步");
if(this.insertHistory==null||this.insertHistory.length<1){
loger.warn("无法继续上一步操作,已经没有可以撤销的数据");
return;
}
console.log(this.insertHistory);
this.sendDeleteAnnotaion(this.insertHistory.pop());
}
//删除所有标注
sendDeleteAllAnnotation(_param){
for (let key in this.annoInfos){
//console.log("key:"+key);
console.log("删除白板数据,itemIdx:"+key);
this.sendDeleteAnnotaion({"itemIdx":key});
}
}
//删除标注,发送信息
sendDeleteAnnotaion(_param){
if(_param==null){
loger.warn("要删除的数据不存在");
return;
}
//{"itemIdx":itemIdx}
let tableDeleteItemPdu = new pdu['RCRegistryTableDeleteItemPdu'];
//optional RCPduType_E type = 1 [default = RCPDU_REG_TABLE_DELETE_PDU];
// repeated uint32 item_idx = 2;
tableDeleteItemPdu.type = pdu.RCPDU_REG_TABLE_DELETE_PDU;//
tableDeleteItemPdu.itemIdx=parseInt(_param.itemIdx);//这里需要设置要删除的数据的itemIdx,每条数据的这个id都不一样
let updateObjPdu = new pdu['RCRegistryUpdateObjPdu'];
updateObjPdu.objId = ApeConsts.WHITEBOARD_OBJ_TABLE_ID;
updateObjPdu.subType = tableDeleteItemPdu.type;
updateObjPdu.userData = tableDeleteItemPdu.toArrayBuffer();
//同步
let adapterItemPdu = new pdu['RCAdapterItemPdu'];
adapterItemPdu.type = pdu.RCPDU_REG_UPDATE_OBJ;
adapterItemPdu.itemData = updateObjPdu.toArrayBuffer();
let adapterPdu = new pdu['RCAdapterPdu'];
adapterPdu.type = pdu.RCPDU_REG_ADAPTER;
adapterPdu.item.push(adapterItemPdu);
console.log("白板发送删除数据============="+tableDeleteItemPdu.itemIdx);
this.sendUniform(adapterPdu,true);
}
//更新标注
sendUpdaterAnnotaion(_param){
if(_param==null||EngineUtils.isEmptyObject(_param)){
loger.log('sendUpdaterAnnotaion失败,参数错误');
this._emit(MessageTypes.MCU_ERROR,MessageTypes.ERR_APE_INTERFACE_PARAM_WRONG);
return ;
}
itemIdx=_param.itemIdx;
let whiteBoardModelPdu = this.packPdu(_param,itemIdx);
//console.log(whiteBoardModelPdu);
if(whiteBoardModelPdu==null){
loger.log('sendInsetAnnotaion失败,参数错误');
this._emit(MessageTypes.MCU_ERROR,MessageTypes.ERR_APE_INTERFACE_PARAM_WRONG);
return ;
}
let tableItemPdu = new pdu['RCRegistryTableItemPdu'];
tableItemPdu.itemIdx=itemIdx;
tableItemPdu.owner = 0;//收到flash的是这个值,不清楚先写固定
tableItemPdu.registerObjId=ApeConsts.WHITEBOARD_OBJ_TABLE_ID;
tableItemPdu.itemData =whiteBoardModelPdu.toArrayBuffer();
//updater
let whiteBoardUpdateItem = new pdu['RCRegistryTableUpdateItemPdu'];
//optional RCPduType_E type = 1 [default = RCPDU_REG_TABLE_UPDATE_PDU];
//repeated RCRegistryTableItemPdu items = 2;
whiteBoardUpdateItem.type = pdu.RCPDU_REG_TABLE_UPDATE_PDU;//
whiteBoardUpdateItem.items.push(tableItemPdu);
let updateObjPdu = new pdu['RCRegistryUpdateObjPdu'];
updateObjPdu.objId = ApeConsts.WHITEBOARD_OBJ_TABLE_ID;
updateObjPdu.subType = whiteBoardUpdateItem.type;
updateObjPdu.userData = whiteBoardUpdateItem.toArrayBuffer();
//同步
let adapterItemPdu = new pdu['RCAdapterItemPdu'];
adapterItemPdu.type = pdu.RCPDU_REG_UPDATE_OBJ;
adapterItemPdu.itemData = updateObjPdu.toArrayBuffer();
let adapterPdu = new pdu['RCAdapterPdu'];
adapterPdu.type = pdu.RCPDU_REG_ADAPTER;
adapterPdu.item.push(adapterItemPdu);
console.log("白板发送更新数据===============22");
this.sendUniform(adapterPdu,true);
}
/////收到消息处理/////////////////////////////////////////////////////////////////////////////////
/* whiteboardMsgComingHandler(_data) {
//flash RCConferenceSendDataRequestPdu
//loger.warn('whiteboardMsgComingHandler needs to be handled.');
//const recordInfo = pdu['RCWhiteboardDataRequestPdu'].decode(pdu);
//loger.log("whiteboardMsgComingHandler",recordInfo);
let receiveInfo = pdu['RCConferenceSendDataRequestPdu'].decode(_data);
loger.log("whiteboardMsgComingHandler",receiveInfo);
}*/
tableInsertHandler(owner, itemIdx,itemData) {
let whiteBoardModel=this.unPackPdu(owner, itemIdx,itemData);
loger.log('tableInsertHandler',whiteBoardModel);
if(whiteBoardModel){
if(GlobalConfig.activeDocId==whiteBoardModel.parentId&&GlobalConfig.activeDocCurPage==whiteBoardModel.curPageNo){
loger.log('WHITEBOARD_ANNOTAION_INSERT 显示到界面上',whiteBoardModel);
//this._emit(MessageTypes.WHITEBOARD_ANNOTAION_INSERT,whiteBoardModel);
this.insertAandShowAnnotaion(whiteBoardModel);
}
}
}
tableUpdateHandler(owner, itemIdx, itemData) {
let whiteBoardModel=this.unPackPdu(owner, itemIdx,itemData);
loger.log('tableUpdateHandler',whiteBoardModel);
this.updateAandShowAnnotaion();
}
tableDeleteHandler(object_id, tableDeleteData){
// console.log("白板收到数据,tableDeleteHandler object_id="+object_id);//((18<< 16) + 1)=1179649
loger.log('tableDeleteHandler',object_id,tableDeleteData);//["tableDeleteHandler",1179649,{"type":231,"itemIdx":[1486301768]}]
if(tableDeleteData&&tableDeleteData.itemIdx){
let len=tableDeleteData.itemIdx.length;
let itemIdxs=tableDeleteData.itemIdx;
for (let i=0;i<len;i++){
if(this.annoInfos[itemIdxs[i]]){
loger.log("删除白板数据:",itemIdxs[i]);
//this._emit(MessageTypes.WHITEBOARD_ANNOTAION_DELETE,{ "itemIdx":itemIdxs[i]});
delete this.annoInfos[itemIdxs[i]];
}
}
}
this.updateAandShowAnnotaion();
}
//文档更新,白板也要更新
docUpdateHandler(_data){
loger.log("白板收到文档更新的消息docUpdateHandler",_data);
this.updateAandShowAnnotaion();
}
//删除白板数据
docDeleteHandler(_parentId){
loger.log("白板收到文档删除的消息docDeleteHandler",_parentId);
for (let key in this.annoInfos){
let item=this.annoInfos[key];
if(item&&item.parentId==_parentId){
loger.log("文档删除,白板数据也删除,itemIdx:"+key,"_parentId:",_parentId);
this.sendDeleteAnnotaion({"itemIdx":key});
}
}
}
//增量添加标注
insertAandShowAnnotaion(_item){
let annotaionItems=[_item];
var updateObj={
"isFresh":false,
"annotaionItems":annotaionItems
}
this._emit(MessageTypes.WHITEBOARD_ANNOTATION_UPDATE,updateObj);
}
//整体更新并且显示标注
updateAandShowAnnotaion(){
let annotaionItems=[];
for (let key in this.annoInfos){
let item=this.annoInfos[key];
if(item&&item.parentId==GlobalConfig.activeDocId&&item.curPageNo==GlobalConfig.activeDocCurPage){
annotaionItems.push(item);
loger.log("显示和文档对应的白板数据docUpdateHandler",item);
}else{
loger.log("不显示白板数据docUpdateHandler",item);
}
}
var updateObj={
"isFresh":true,
"annotaionItems":annotaionItems
}
this._emit(MessageTypes.WHITEBOARD_ANNOTATION_UPDATE,updateObj);
}
///////白板数据的封包和解包/////////////////////////////////////////
packPdu(_param,_itemIdx){
/* required uint32 type= 1;//白板类型
required uint32 id= 2;//id 每一次绘制的唯一标识
required uint32 initiator=3; //绘制来自谁
optional string pointGroup=4; //坐标点集数组的JSON字符串
optional string color= 5 [default = "#000000"]; //颜色
optional uint32 thickness= 6 ;//线条粗细
optional uint32 radius= 7;//园的半径
optional uint32 fontSize= 8;//字体大小
optional uint32 fontName= 9;//字体名称
optional uint32 text= 10;//文本内容*/
//验证坐标点集合数组是否合法
if(_param.pointGroup==null||_param.pointGroup.length<1){
this._emit(MessageTypes.MCU_ERROR,MessageTypes.ERR_APE_INTERFACE_PARAM_WRONG);
return null;
}
//判断type类型,根据type设置不同的参数
let whiteBoardModelPdu =new pdu['RCWhiteBoardDataModelPdu'];
switch (_param.type){
case TYPE_BIGHT:
break;
case TYPE_CIRCLE:
whiteBoardModelPdu.radius=parseInt(_param.radius);
case TYPE_LINE:
break;
case TYPE_TEXT:
whiteBoardModelPdu.fontSize=parseInt(_param.fontSize);
whiteBoardModelPdu.fontName=_param.fontName||null;
whiteBoardModelPdu.text=_param.text||null;
case TYPE_RECT:
break;
default:
//其它类型不做处理
return null;
break;
}
//下面4个是必须的参数
whiteBoardModelPdu.type =_param.type;
whiteBoardModelPdu.itemIdx =_itemIdx;
whiteBoardModelPdu.initiator =GlobalConfig.nodeId;
/* whiteBoardModelPdu.parentId=_param.parentId||0;
whiteBoardModelPdu.curPage=_param.curPage||1;*/
whiteBoardModelPdu.parentId=GlobalConfig.activeDocId;//当前激活的文档id
whiteBoardModelPdu.curPageNo=GlobalConfig.activeDocCurPage;//当前激活的文档页码
whiteBoardModelPdu.pointGroup =EngineUtils.arrayToJsonString(_param.pointGroup);
whiteBoardModelPdu.color=_param.color||"#000000";
return whiteBoardModelPdu;
}
unPackPdu(owner, itemIdx,itemData){
try{
console.log("白板收到数据===unPackPdu ");
let whiteBoardModelPdu= pdu['RCWhiteBoardDataModelPdu'].decode(itemData);
//console.log(whiteBoardModelPdu);
//loger.log(whiteBoardModelPdu);
let _pointGroup= EngineUtils.arrayFromJsonString(whiteBoardModelPdu.pointGroup);
whiteBoardModelPdu.pointGroup=_pointGroup;
this.annoInfos[itemIdx] = whiteBoardModelPdu;
return whiteBoardModelPdu;
}catch (err){
console.log("unPackPdu Pdu解析错误,itemIdx="+itemIdx+" err:"+err.message);
}
return null;
}
/////收到消息处理/////////////////////////////////////////////////////////////////////////////////
/* whiteboardMsgComingHandler(_data) {
//flash RCConferenceSendDataRequestPdu
//loger.warn('whiteboardMsgComingHandler needs to be handled.');
//const recordInfo = pdu['RCWhiteboardDataRequestPdu'].decode(pdu);
//loger.log("whiteboardMsgComingHandler",recordInfo);
let receiveInfo = pdu['RCConferenceSendDataRequestPdu'].decode(_data);
loger.log("whiteboardMsgComingHandler",receiveInfo);
}*/
tableInsertHandler(owner, itemIdx,itemData) {
/* try{
console.log("白板收到数据===tableInsertHandler ");
let whiteBoardModelPdu= pdu['RCWhiteBoardDataModel'].decode(itemData);
this.annoInfos[itemIdx] = itemData;
console.log(whiteBoardModelPdu);
}catch (err){
console.log("tableInsertHandler Pdu解析错误,itemIdx="+itemIdx+" err:"+err.message);
}*/
let whiteBoardModel=this.unPackPdu(owner, itemIdx,itemData);
loger.log('tableInsertHandler',whiteBoardModel);
if(whiteBoardModel){
if(GlobalConfig.activeDocId==whiteBoardModel.parentId&&GlobalConfig.activeDocCurPage==whiteBoardModel.curPageNo){
loger.log('WHITEBOARD_ANNOTAION_INSERT 显示到界面上',whiteBoardModel);
this._emit(MessageTypes.WHITEBOARD_ANNOTAION_INSERT,whiteBoardModel);
}
}
}
tableUpdateHandler(owner, itemIdx, itemData) {
let whiteBoardModel=this.unPackPdu(owner, itemIdx,itemData);
loger.log('tableUpdateHandler',whiteBoardModel);
if(whiteBoardModel){
if(GlobalConfig.activeDocId==whiteBoardModel.parentId&&GlobalConfig.activeDocCurPage==whiteBoardModel.curPageNo){
loger.log('WHITEBOARD_ANNOTATION_UPDATE 显示到界面上',whiteBoardModel);
this._emit(MessageTypes.WHITEBOARD_ANNOTATION_UPDATE,whiteBoardModel);
}
}
/* try{
console.log("白板收到数据===tableUpdateHandler ");
let whiteBoardModelPdu= pdu['RCWhiteBoardDataModel'].decode(itemData);
this.annoInfos[itemIdx] = itemData;
console.log(whiteBoardModelPdu);
loger.log(whiteBoardModelPdu)
}catch (err){
console.log("tableUpdateHandler Pdu解析错误,itemIdx="+itemIdx+" err:"+err.message);
}*/
/*const recordInfo = pdu['RCWhiteboardDataRequestPdu'].decode(recordData);
console.log("recordInfo");
loger.log(recordInfo);
// 目前只处理 文档标注
if (recordInfo.type == ApeConsts.WBA_DOC_ANNOTATION) {
const uncompressedBytes = new Zlib.Inflate(recordInfo.action.compact().view).decompress();
const annoInfo = {
id: recordId,
svg: UTF8.getStringFromBytes(uncompressedBytes)
};
loger.log(annoInfo);
this.annoInfos[recordId] = annoInfo;
this._emit(MessageTypes.WHITEBOARD_ANNOTATION_UPDATE, annoInfo);
} else {
loger.log('白板动作忽略,类型:', ApeConsts(recordInfo.type));
}*/
}
tableDeleteHandler(object_id, tableDeleteData){
// console.log("白板收到数据,tableDeleteHandler object_id="+object_id);//((18<< 16) + 1)=1179649
loger.log('tableDeleteHandler',object_id,tableDeleteData);//["tableDeleteHandler",1179649,{"type":231,"itemIdx":[1486301768]}]
if(tableDeleteData&&tableDeleteData.itemIdx){
let len=tableDeleteData.itemIdx.length;
let itemIdxs=tableDeleteData.itemIdx;
for (let i=0;i<len;i++){
if(this.annoInfos[itemIdxs[i]]){
loger.log("删除白板数据:",itemIdxs[i],"当前剩余的白板数据");
console.log(this.annoInfos); this._emit(MessageTypes.WHITEBOARD_ANNOTAION_DELETE,{ "itemIdx":itemIdxs[i]});
this._emit(MessageTypes.WHITEBOARD_ANNOTAION_DELETE,{ "itemIdx":itemIdxs[i]});
delete this.annoInfos[itemIdxs[i]];
}
}
}
}
//文档更新,白板也要更新
docUpdateHandler(_data){
loger.log("白板收到文档更新的消息docUpdateHandler",_data);
for (let key in this.annoInfos){
let item=this.annoInfos[key];
if(item&&item.parentId==GlobalConfig.activeDocId&&item.curPageNo==GlobalConfig.activeDocCurPage){
loger.log("显示和文档对应的白板数据docUpdateHandler",item);
}else{
loger.log("不显示白板数据docUpdateHandler",item);
}
}
/* let docItem=_data;
for (let key in this.annoInfos){
let item=this.annoInfos[key];
if(item&&docItem.visible==true&&item.parentId==docItem.itemIdx&&item.curPageNo==docItem.curPageNo){
loger.log("显示和文档对应的白板数据docUpdateHandler",item);
}else{
loger.log("不显示白板数据docUpdateHandler",item);
}
}*/
}
//删除白板数据
docDeleteHandler(_parentId){
loger.log("白板收到文档删除的消息docDeleteHandler",_parentId);
for (let key in this.annoInfos){
let item=this.annoInfos[key];
if(item&&item.parentId==_parentId){
loger.log("文档删除,白板数据也删除,itemIdx:"+key,"_parentId:",_parentId);
this.sendDeleteAnnotaion({"itemIdx":key});
}
}
}
case TYPE_CIRCLE:
whiteBoardModelPdu.radius=parseInt(_param.radius);
break;
case TYPE_TEXT:
whiteBoardModelPdu.fontSize=parseInt(_param.fontSize);
whiteBoardModelPdu.fontName=_param.fontName||null;
whiteBoardModelPdu.text=_param.text||null;
break;
default:
//其它类型不做处理
return null;
break;
}
//下面4个是必须的参数
whiteBoardModelPdu.type =_param.type;
whiteBoardModelPdu.itemIdx =_itemIdx;
whiteBoardModelPdu.initiator =GlobalConfig.nodeId;
/* whiteBoardModelPdu.parentId=_param.parentId||0;
whiteBoardModelPdu.curPage=_param.curPage||1;*/
whiteBoardModelPdu.parentId=GlobalConfig.activeDocId;//当前激活的文档id
whiteBoardModelPdu.curPageNo=GlobalConfig.activeDocCurPage;//当前激活的文档页码
whiteBoardModelPdu.pointGroup =EngineUtils.arrayToJsonString(_param.pointGroup);
whiteBoardModelPdu.color=_param.color||"#000000";
return whiteBoardModelPdu;
}
unPackPdu(owner, itemIdx,itemData){
try{
console.log("白板收到数据===unPackPdu ");
let whiteBoardModelPdu= pdu['RCWhiteBoardDataModelPdu'].decode(itemData);
//console.log(whiteBoardModelPdu);
//loger.log(whiteBoardModelPdu);
let _pointGroup= EngineUtils.arrayFromJsonString(whiteBoardModelPdu.pointGroup);
whiteBoardModelPdu.pointGroup=_pointGroup;
this.annoInfos[itemIdx] = whiteBoardModelPdu;
return whiteBoardModelPdu;
}catch (err){
console.log("unPackPdu Pdu解析错误,itemIdx="+itemIdx+" err:"+err.message);
}
return null;
}
}
export default WhiteBoardApe;
... ...