UNPKG

@bitrix24/b24jssdk

Version:

Bitrix24 REST API JavaScript SDK

81 lines (77 loc) 2.08 kB
/** * @package @bitrix24/b24jssdk * @version 2.0.0 * @copyright (c) 2026 Bitrix24 * @license MIT * @see https://github.com/bitrix24/b24jssdk * @see https://bitrix24.github.io/b24jssdk/ */ 'use strict'; const type = require('../tools/type.cjs'); const pull = require('../types/pull.cjs'); const loggerFactory = require('../logger/logger-factory.cjs'); var __defProp = Object.defineProperty; var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); class AbstractConnector { static { __name(this, "AbstractConnector"); } _logger; _connected = false; _connectionType; _disconnectCode = 0; _disconnectReason = ""; _parent; _callbacks; constructor(config) { this._logger = loggerFactory.LoggerFactory.createNullLogger(); this._parent = config.parent; this._connectionType = pull.ConnectionType.Undefined; this._callbacks = { onOpen: type.Type.isFunction(config.onOpen) ? config.onOpen : () => { }, onDisconnect: type.Type.isFunction(config.onDisconnect) ? config.onDisconnect : () => { }, onError: type.Type.isFunction(config.onError) ? config.onError : () => { }, onMessage: type.Type.isFunction(config.onMessage) ? config.onMessage : () => { } }; } setLogger(logger) { this._logger = logger; } getLogger() { return this._logger; } destroy() { } get connected() { return this._connected; } set connected(value) { if (value == this._connected) { return; } this._connected = value; if (this._connected) { this._callbacks.onOpen(); } else { this._callbacks.onDisconnect({ code: this.disconnectCode, reason: this.disconnectReason }); } } get disconnectCode() { return this._disconnectCode; } get disconnectReason() { return this._disconnectReason; } get connectionPath() { return this._parent.getConnectionPath(this._connectionType); } } exports.AbstractConnector = AbstractConnector; //# sourceMappingURL=abstract-connector.cjs.map