diff --git a/lib/ws_servers/api/algos/algo_worker.js b/lib/ws_servers/api/algos/algo_worker.js index 10b48a6e..7d78b366 100644 --- a/lib/ws_servers/api/algos/algo_worker.js +++ b/lib/ws_servers/api/algos/algo_worker.js @@ -62,7 +62,7 @@ class AlgoWorker { apiKey, apiSecret, authToken, - dms: dms ? DMS_ENABLED : 0, + dms: 0, // always set dms 0 for AOHost. dms order cancelation will be handled by dms_remote_control withHeartbeat: true, affiliateCode, wsURL, @@ -80,6 +80,7 @@ class AlgoWorker { this.host = host this.registerEvents() + this.updateDms(dms) const { caps } = await host.connect() if (!hasRequiredPermissions(caps)) { @@ -212,6 +213,15 @@ class AlgoWorker { adapter.updateAuthArgs(args) } + /** + * @public + * @param {number?} dms + */ + updateDms (dms) { + // if dms is disabled, skip meta:reload on disconnection + if (this.host) this.host.shouldSkipMetaReload = !dms + } + /** * @public * @param {number?} dms diff --git a/lib/ws_servers/api/dms_remote_control.js b/lib/ws_servers/api/dms_remote_control.js index 9cc0d066..89498e50 100644 --- a/lib/ws_servers/api/dms_remote_control.js +++ b/lib/ws_servers/api/dms_remote_control.js @@ -21,6 +21,7 @@ class DmsRemoteControl { this.restURL = restURL this.ws = null this.isOpen = false + this.lastAlive = 0 } async open ({ apiKey, apiSecret, dmsScope }) { @@ -118,6 +119,9 @@ class DmsRemoteControl { this._schedulePing() onSuccess() } + + // track last connection time + this.lastAlive = Date.now() } _onClose () { diff --git a/lib/ws_servers/api/factories/create_algo_worker.js b/lib/ws_servers/api/factories/create_algo_worker.js index 2b523742..d396dcfb 100644 --- a/lib/ws_servers/api/factories/create_algo_worker.js +++ b/lib/ws_servers/api/factories/create_algo_worker.js @@ -24,7 +24,7 @@ module.exports = (server, session, ws, settings) => { return new AlgoWorker( { - dms: false, + dms: settings.dms || 0, affiliateCode, wsURL, restURL, diff --git a/lib/ws_servers/api/start_connections.js b/lib/ws_servers/api/start_connections.js index 511d982e..f305b4e0 100644 --- a/lib/ws_servers/api/start_connections.js +++ b/lib/ws_servers/api/start_connections.js @@ -93,6 +93,9 @@ class ConnectionManager { * @returns {Promise<*>} */ async updateDms (server, session, dms, dmsScope) { + // update dms setting for algo worker + session.getAlgoWorker()?.updateDms(dms) + if (!dmsScope) { return { dmsControl: false } }