DocApe.js
2.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// //////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2016-present All Rights Reserved.
// Licensed under the Apache License, Version 2.0 (the "License");
// http://www.apache.org/licenses/LICENSE-2.0
//
// Github Home: https://github.com/AlexWang1987
// Author: AlexWang
// Date: 2016-08-26 17:30:43
// QQ Email: 1669499355@qq.com
// Last Modified time: 2016-09-21 14:12:25
// Description: LiveClass-DocApe
//
// //////////////////////////////////////////////////////////////////////////////
import Ape from './Ape';
import ApeConsts from './ApeConsts';
import pdu from 'pdus';
import Loger from 'Loger';
import MessageTypes from 'MessageTypes';
let loger = Loger.getLoger('DocApe');
class DocApe extends Ape {
constructor() {
super(
ApeConsts.DOCSHARING_SESSION_ID,
ApeConsts.DOCSHARING_SESSION_NAME,
ApeConsts.DOCSHARING_SESSION_TAG
);
this.docList = {};
// Ape Models
this.registerKey(this._session_id, this._session_name, this._session_tag, new ArrayBuffer);
this.registerObj(pdu.RCPDU_REG_REGISTER_TABLE, ApeConsts.DOCSHARING_OBJ_TABLE_ID_H5, ApeConsts.DOCSHARING_OBJ_TABLE_NAME_H5, ApeConsts.DOCSHARING_OBJ_TABLE_TAG_H5, 0, new ArrayBuffer);
// 延迟
this._apeDelayed = true;
}
tableInsertHandler(owner, tableId, recordData) {
this.tableUpdateHandler(owner, tableId, recordData);
}
tableDeleteHandler(tableId, record){
const re={};
re.type=ApeConsts.DOCUMENT_DEL;
this._emit(MessageTypes.DOC_DEL, re);
}
tableUpdateHandler(owner, recordId, recordData) {
try {
const recordInfo = pdu['RCDocSendDataRequestPdu'].decode(recordData);
recordInfo.type = ApeConsts.DOCUMENT_LOAD;
recordInfo.ext = recordInfo.name.substr(recordInfo.name.indexOf('.') + 1);
recordInfo.wbid = (recordInfo.id << 10) + recordInfo.curPageNo;
recordInfo.isPicture = ~['bmp', 'png', 'gif', 'jpg', 'jpeg'].indexOf(recordInfo.ext);
if (recordInfo.isPicture) {
recordInfo.namePath = recordInfo.uri.substring(0, recordInfo.uri.lastIndexOf('.'));
recordInfo.loadURL = recordInfo.namePath + '.' + recordInfo.ext;
} else {
recordInfo.namePath = recordInfo.uri.substring(0, recordInfo.uri.lastIndexOf('/'));
recordInfo.loadURL = `${recordInfo.namePath}/${recordInfo.curPageNo}.jpg`;
}
this.docList[recordId] = recordInfo;
this._emit(MessageTypes.DOC_UPDATE, recordInfo);
loger.log('Doc update ->' + recordId);
} catch (e) {
loger.warn('Doc Table Update Decode包异常');
}
}
}
export default DocApe;