Commit 4a88d82e authored by Alexander.Trofimov's avatar Alexander.Trofimov Committed by Alexander.Trofimov

delete trackFile.js

delete trackingInfo from getsettings command
add ping with tracking (param ua - 'user_active')
add cleanupIfQuotaExceed (in user count - remove all after day; in active connection - remove unactive after 2*tracking_interval)

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@64690 954022d7-b5bf-4e40-9824-e11837661b57
parent 675769c7
......@@ -30,7 +30,6 @@
"../../Common/SerializeChart.js",
"../../Common/Drawings/Format/Constants.js",
"../../Common/Drawings/Format/Format.js",
"../../Common/trackFile.js",
"../../Common/FontsFreeType/font_map.js",
"../../Word/Drawing/Externals.js",
......
......@@ -32,7 +32,6 @@
"../../Word/Drawing/Externals.js",
"../../Word/Drawing/Metafile.js",
"../../Excel/model/DrawingObjects/GlobalLoaders.js",
"../../Common/trackFile.js",
"../../Excel/apiDefines.js",
"../../Excel/document/empty-workbook.js",
"../../Excel/utils/utils.js",
......
......@@ -34,7 +34,6 @@
"../../Common/Charts/DrawingArea.js",
"../../Common/NumFormat.js",
"../../Word/Editor/Serialize2.js",
"../../Common/trackFile.js",
"../../Word/Editor/Styles.js",
"../../Word/Editor/Numbering.js",
"../../Word/Drawing/Metafile.js",
......
......@@ -28,7 +28,6 @@
"../../Common/SerializeChart.js",
"../../Common/Drawings/Format/Constants.js",
"../../Common/Drawings/Format/Format.js",
"../../Common/trackFile.js",
"../../Common/FontsFreeType/font_engine.js",
"../../Common/FontsFreeType/FontFile.js",
"../../Common/FontsFreeType/FontManager.js",
......
......@@ -27,8 +27,7 @@
"../../Word/Drawing/WorkEvents.js",
"../../Word/Drawing/Externals.js",
"../../Word/Drawing/Metafile.js",
"../../Excel/model/DrawingObjects/GlobalLoaders.js",
"../../Common/trackFile.js",
"../../Excel/model/DrawingObjects/GlobalLoaders.js",
"../../Excel/apiDefines.js",
"../../Excel/document/empty-workbook.js",
"../../Excel/utils/utils.js",
......
......@@ -30,7 +30,6 @@
"../../Common/Charts/DrawingArea.js",
"../../Common/NumFormat.js",
"../../Word/Editor/Serialize2.js",
"../../Common/trackFile.js",
"../../Word/Editor/Styles.js",
"../../Word/Editor/Numbering.js",
......
......@@ -24,7 +24,6 @@
"../../Common/SerializeChart.js",
"../../Common/Drawings/Format/Constants.js",
"../../Common/Drawings/Format/Format.js",
"../../Common/trackFile.js",
"../../Common/FontsFreeType/font_engine.js",
"../../Common/FontsFreeType/FontFile.js",
"../../Common/FontsFreeType/FontManager.js",
......
......@@ -142,6 +142,12 @@
}
};
CDocsCoApi.prototype.setPingSettings = function(inverval, bSendUserAlive) {
if (this._CoAuthoringApi && this._onlineWork) {
this._CoAuthoringApi.setPingSettings(inverval, bSendUserAlive);
}
};
CDocsCoApi.prototype.askLock = function(arrayBlockId, callback) {
if (this._CoAuthoringApi && this._onlineWork) {
this._CoAuthoringApi.askLock(arrayBlockId, callback);
......@@ -648,13 +654,27 @@
};
DocsCoApi.prototype.ping = function() {
this._send({"type": "ping"});
// ua - активность пользователя. 0 - неактивный, 1 - активный, -1 - не обновлять
this._send({'type': 'ping', 'ua': this.bSendUserAlive ? (this.bUserAlive >> 0) : -1});
// После отправки сбрасываем активность
this.bUserAlive = false;
};
DocsCoApi.prototype.setUserAlive = function() {
this.bUserAlive = true;
};
DocsCoApi.prototype.setPingSettings = function(inverval, bSendUserAlive) {
if (null !== this.pingIntervalID)
return;
this.bSendUserAlive = bSendUserAlive;
this.pingInterval = inverval * 1000;
var t = this;
this.ping();
this.pingIntervalID = setInterval(function() {t.ping();}, this.pingInterval);
};
DocsCoApi.prototype._sendPrebuffered = function() {
for (var i = 0; i < this._msgBuffer.length; i++) {
this._sendRaw(this._msgBuffer[i]);
......@@ -1033,14 +1053,6 @@
if (this._initCallback) {
this._initCallback({result: data["result"]});
}
//ping
var fPing = function() {
setTimeout(function() {
t.ping();
fPing();
}, 60000);
};
fPing();
};
DocsCoApi.prototype.init = function(user, docid, documentCallbackUrl, token, callback, editorType, documentFormatSave, isViewer) {
......@@ -1058,7 +1070,10 @@
this._documentFormatSave = documentFormatSave;
this._isViewer = isViewer;
this.bUserAlive = false; // Активность пользователя
this.bUserAlive = false; // Активность пользователя
this.bSendUserAlive = false; // Отправлять ли активность пользователя
this.pingInterval = 300 * 1000;
this.pingIntervalID = null;
this._initSocksJs();
};
......
"use strict";
(
/**
* @param {window} window
* @param {undefined} undefined
*/
function(window, undefined) {
var asc = window["Asc"] ? window["Asc"] : (window["Asc"] = {});
// tracking type by license type
var c_TrackingType = {
TT_USER_COUNT: 0, // by user count
TT_ACTIVE_CONNECTION: 1, // by active connections
TT_TIME_USAGE: 2, // by time of editing
TT_DOCUMENT_SESSION: 3, // by document editing session count
TT_NONE: 4, // no tracking
TT_USER_COUNT_2: 5, // by user count, without active/inactive detection
TT_ACTIVE_CONNECTION_AWS: 6 // by active connections (only on aws instance)
};
function CTrackFile(obj) {
this.trackingType = c_TrackingType.TT_USER_COUNT;
this.licenseId = null;
this.trackingUrl = g_sTrackingServiceLocalUrl;
this.isPeriodicalyTracking = false;
this.isAliveTrackingOnly = false;
this.isTrackDone = false;
this.bAliveUser2 = false;
if (undefined != obj && null != obj) {
if (undefined != obj["licenseId"] && null != obj["licenseId"])
this.licenseId = obj["licenseId"];
if (undefined != obj["trackingType"] && null != obj["trackingType"])
this.trackingType = obj["trackingType"];
if (undefined != obj["trackingUrl"] && null != obj["trackingUrl"])
this.trackingUrl = obj["trackingUrl"];
}
switch (this.trackingType) {
case c_TrackingType.TT_ACTIVE_CONNECTION:
case c_TrackingType.TT_ACTIVE_CONNECTION_AWS:
this.isPeriodicalyTracking = true;
this.isAliveTrackingOnly = false;
break;
case c_TrackingType.TT_DOCUMENT_SESSION:
this.isPeriodicalyTracking = false;
this.isAliveTrackingOnly = true;
break;
case c_TrackingType.TT_USER_COUNT_2:
this.bAliveUser2 = true; // Сразу выставляем, что пользователь активный
this.isPeriodicalyTracking = false;
this.isAliveTrackingOnly = true;
break;
case c_TrackingType.TT_NONE:
this.isTrackDone = true;
this.isPeriodicalyTracking = false;
break;
default:
break;
}
this.sendTrackFunc = null;
this.trackingInterval = 300 * 1000;
this.docId = null;
this.userId = null;
this.bAliveUser = false;
}
CTrackFile.prototype.Start = function () {
var oThis = this;
if (this.isPeriodicalyTracking || !this.isTrackDone) {
var _OnTrackingTimer = function () {
oThis.Start();
};
var _OnSendTrack = function () {
setTimeout(_OnTrackingTimer, oThis.trackingInterval);
};
if (this.isAliveTrackingOnly && !this.bAliveUser && !this.bAliveUser2) {
_OnSendTrack();
} else {
this.isTrackDone = true;
this._sendTrack(_OnSendTrack);
}
}
};
CTrackFile.prototype.Stop = function () {
};
CTrackFile.prototype.setInterval = function (inverval) {
this.trackingInterval = inverval * 1000;
};
CTrackFile.prototype.setDocId = function (docId) {
this.docId = docId;
};
CTrackFile.prototype.setUserId = function (userId) {
this.userId = userId;
};
CTrackFile.prototype.setTrackFunc = function (func) {
if (undefined != func)
this.sendTrackFunc = func;
};
CTrackFile.prototype.setUserAlive = function () {
this.bAliveUser = true;
};
CTrackFile.prototype._sendTrack = function (callback) {
var rData = {
"docId": this.docId,
"clientId": this.userId,
"isAlive": this.bAliveUser ? 1 : 0
};
// Сбрасываем активность пользователя после отправки, т.к. она пойдет заново
this.bAliveUser = false;
if (this.sendTrackFunc != null)
this.sendTrackFunc(callback, this.trackingUrl, JSON.stringify(rData));
};
asc.CTrackFile = CTrackFile;
}
)(window, undefined);
\ No newline at end of file
......@@ -44,8 +44,6 @@
<script type="text/javascript" src="../../Word/Drawing/Externals.js"></script>
<script type="text/javascript" src="../../Word/Drawing/Metafile.js"></script>
<script type="text/javascript" src="../../Common/trackFile.js"></script>
<script type="text/javascript" src="../apiDefines.js"></script>
<script type="text/javascript" src="../utils/utils.js"></script>
......
......@@ -62,8 +62,6 @@
<script type="text/javascript" src="../Word/Drawing/Externals.js"></script>
<script type="text/javascript" src="../Word/Drawing/Metafile.js"></script>
<script type="text/javascript" src="../Common/trackFile.js"></script>
<script type="text/javascript" src="apiDefines.js"></script>
<script type="text/javascript" src="utils/utils.js"></script>
......
......@@ -49,8 +49,6 @@
<script type="text/javascript" src="../Word/Drawing/Externals.js"></script>
<script type="text/javascript" src="../Word/Drawing/Metafile.js"></script>
<script type="text/javascript" src="../Common/trackFile.js"></script>
<script type="text/javascript" src="apiDefines.js"></script>
<script type="text/javascript" src="utils/utils.js"></script>
......
......@@ -17,7 +17,6 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
var asc_CAdjustPrint = asc.asc_CAdjustPrint;
var asc_CAscEditorPermissions = asc.asc_CAscEditorPermissions;
var asc_CAscLicense = asc.asc_CAscLicense;
var asc_CTrackFile = asc.CTrackFile;
var prot;
var CDocsCoApi = window["CDocsCoApi"];
......@@ -593,6 +592,7 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
t.advancedOptionsAction = c_oAscAdvancedOptionsAction.Perm;
sendCommand2(t, null, rdata);
} else {
// Фиктивный режим, фактически без документа
t.handlers.trigger("asc_onGetEditorPermissions", new asc_CAscEditorPermissions());
// Фиктивно инициализируем
t.SpellCheckUrl = window['g_cAscSpellCheckUrl'] ? window['g_cAscSpellCheckUrl'] : '';
......@@ -1385,22 +1385,9 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
this.SpellCheckUrl = oSettings['g_cAscSpellCheckUrl'];
var oEditorPermissions = new asc_CAscEditorPermissions(oSettings);
this.handlers.trigger("asc_onGetEditorPermissions", oEditorPermissions);
if (null != oSettings['trackingInfo'] && oEditorPermissions.asc_getCanEdit()) {
this.TrackFile = new asc_CTrackFile(oSettings['trackingInfo']);
this.TrackFile.setDocId(this.DocInfo["Id"]);
this.TrackFile.setUserId(this.DocInfo["UserId"]);
this.TrackFile.setTrackFunc(sendTrack);
if (null != oSettings['TrackingInterval']) {
this.TrackFile.setInterval(oSettings['TrackingInterval']);
}
this.TrackFile.Start();
}
this.CoAuthoringApi.setPingSettings(oSettings['TrackingInterval'], oEditorPermissions.asc_getCanLicense());
}
};
......
......@@ -252,7 +252,6 @@
<script type="text/javascript" src="../../../../OfficeWeb/Common/Charts/ChartsDrawer.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/Common/commonDefines.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/Common/apiCommon.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/Common/trackFile.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/Common/NumFormat.js"></script>
......
......@@ -220,7 +220,6 @@
<script type="text/javascript" src="../../../../OfficeWeb/Common/Charts/ChartsDrawer.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/Common/commonDefines.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/Common/apiCommon.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/Common/trackFile.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/Common/NumFormat.js"></script>
......
......@@ -66,8 +66,6 @@
<script type="text/javascript" src="../Common/Charts/charts.js"></script>
<script type="text/javascript" src="../Word/Editor/Serialize2.js"></script>
<script type="text/javascript" src="../Common/trackFile.js"></script>
<script src="../Common/commonDefines.js"></script>
......
......@@ -729,6 +729,7 @@ asc_docs_api.prototype.asc_getEditorPermissions = function() {
t.advancedOptionsAction = c_oAscAdvancedOptionsAction.Perm;
sendCommand2(t, null, rData);
} else {
// Фиктивный режим, фактически без документа
var asc_CAscEditorPermissions = window["Asc"].asc_CAscEditorPermissions;
t.asc_fireCallback("asc_onGetEditorPermissions", new asc_CAscEditorPermissions());
// Фиктивно инициализируем
......@@ -757,19 +758,7 @@ asc_docs_api.prototype.asc_getEditorPermissionsCallback = function(response) {
var oEditorPermissions = new asc_CAscEditorPermissions(oSettings);
this.asc_fireCallback("asc_onGetEditorPermissions", oEditorPermissions);
if (null != oSettings['trackingInfo'] && oEditorPermissions.asc_getCanEdit()) {
var asc_CTrackFile = window["Asc"].CTrackFile;
this.TrackFile = new asc_CTrackFile(oSettings['trackingInfo']);
this.TrackFile.setDocId(this.DocInfo.get_Id());
this.TrackFile.setUserId(this.DocInfo.get_UserId());
this.TrackFile.setTrackFunc(sendTrack);
if (null != oSettings['TrackingInterval'])
this.TrackFile.setInterval(oSettings['TrackingInterval']);
this.TrackFile.Start();
}
this.CoAuthoringApi.setPingSettings(oSettings['TrackingInterval'], oEditorPermissions.asc_getCanLicense());
}
};
......
......@@ -272,8 +272,6 @@
<script type="text/javascript" src="../../../../OfficeWeb/Common/NumFormat.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/Word/Editor/Serialize2.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/Common/trackFile.js"></script>
<script src="../../../../OfficeWeb/Common/commonDefines.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/Word/Editor/Styles.js"></script>
......
......@@ -25,8 +25,6 @@
<script type="text/javascript" src="../Common/3rdparty/Sockjs/sockjs-0.3.min.js"></script>
<script type="text/javascript" src="../Common/3rdparty/XRegExp/xregexp-all.js"></script>
<script type="text/javascript" src="../Common/trackFile.js"></script>
<!-- application -->
<script type="text/javascript" src="../Common/browser.js"></script>
<script type="text/javascript" src="../Common/editorscommon.js"></script>
......
......@@ -739,6 +739,7 @@ asc_docs_api.prototype.asc_getEditorPermissions = function() {
t.advancedOptionsAction = c_oAscAdvancedOptionsAction.Perm;
sendCommand2(t, null, rData);
} else {
// Фиктивный режим, фактически без документа
var asc_CAscEditorPermissions = window["Asc"].asc_CAscEditorPermissions;
t.asc_fireCallback("asc_onGetEditorPermissions", new asc_CAscEditorPermissions());
// Фиктивно инициализируем
......@@ -777,19 +778,7 @@ asc_docs_api.prototype.asc_getEditorPermissionsCallback = function(response) {
var oEditorPermissions = new asc_CAscEditorPermissions(oSettings);
this.asc_fireCallback("asc_onGetEditorPermissions", oEditorPermissions);
if (null != oSettings['trackingInfo'] && oEditorPermissions.asc_getCanEdit()) {
var asc_CTrackFile = window["Asc"].CTrackFile;
this.TrackFile = new asc_CTrackFile(oSettings['trackingInfo']);
this.TrackFile.setDocId(this.DocInfo.get_Id());
this.TrackFile.setUserId(this.DocInfo.get_UserId());
this.TrackFile.setTrackFunc(sendTrack);
if (null != oSettings['TrackingInterval'])
this.TrackFile.setInterval(oSettings['TrackingInterval']);
this.TrackFile.Start();
}
this.CoAuthoringApi.setPingSettings(oSettings['TrackingInterval'], oEditorPermissions.asc_getCanLicense());
}
};
......
......@@ -255,7 +255,6 @@
<script type="text/javascript" src="../../../../OfficeWeb/Common/spellCheckLanguagesAll.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/Common/apiCommon.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/Common/trackFile.js"></script>
<!-- For chart editor -->
<!--<script type="text/javascript" src="../../../../OfficeWeb/Excel/apiDefines.js"></script>-->
......
......@@ -85,7 +85,6 @@
<script type="text/javascript" src="../../../../OfficeWeb/Common/spellCheckLanguagesAll.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/Common/apiCommon.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/Common/trackFile.js"></script>
<!-- For chart editor -->
<script type="text/javascript" src="../../../../OfficeWeb/Excel/apiDefines.js"></script>
......
......@@ -36,8 +36,6 @@
<script type="text/javascript" src="../Common/CommonDefines.js"></script>
<script type="text/javascript" src="../Common/NumFormat.js"></script>
<script type="text/javascript" src="../Common/editorscommon.js"></script>
<script type="text/javascript" src="../Common/trackFile.js"></script>
<!-- For chart editor -->
<script type="text/javascript" src="../Excel/apiDefines.js"></script>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment