UNPKG

diffusion

Version:

Diffusion JavaScript client

53 lines (52 loc) 1.95 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Core = void 0; var Services = require("./../services/session-services"); var logger = require("./../util/logger"); var response_success_1 = require("./../util/response-success"); var log = logger.create('Internal Session'); /** * Core feature implements methods defined on the {@link Session} interface */ var Core = /** @class */ (function () { /** * Create a new PingImpl instance * * @param internal the internal session * @param currentTime a function returning the current time in milliseconds. * Only used for testing */ function Core(internal, currentTime) { if (currentTime === void 0) { currentTime = Date.now; } /** * A function returning the current time in milliseconds * * Only used for testing. Otherwise always `Date.now` */ this.currentTime = Date.now; this.internal = internal; this.currentTime = currentTime; this.GET_OWN_SESSION_PROPERTIES = internal.getServiceLocator().obtain(Services.GET_OWN_SESSION_PROPERTIES); } /** * Get the session properties for the current session */ Core.prototype.getSessionProperties = function () { var _this = this; return new Promise(function (resolve, reject) { if (_this.internal.checkConnected(reject)) { _this.GET_OWN_SESSION_PROPERTIES.send(null, function (err, response) { if (!response_success_1.responseSuccess(err, response)) { log.error('Error getting session properties:', err); reject(err); } else { resolve(response.properties); } }); } }); }; return Core; }()); exports.Core = Core;