@bitrix24/b24jssdk
Version:
Bitrix24 REST API JavaScript SDK
79 lines (76 loc) • 2.02 kB
JavaScript
/**
* @package @bitrix24/b24jssdk
* @version 1.0.1
* @copyright (c) 2026 Bitrix24
* @license MIT
* @see https://github.com/bitrix24/b24jssdk
* @see https://bitrix24.github.io/b24jssdk/
*/
import { Type } from '../tools/type.mjs';
import { ConnectionType } from '../types/pull.mjs';
import { LoggerFactory } from '../logger/logger-factory.mjs';
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.createNullLogger();
this._parent = config.parent;
this._connectionType = ConnectionType.Undefined;
this._callbacks = {
onOpen: Type.isFunction(config.onOpen) ? config.onOpen : () => {
},
onDisconnect: Type.isFunction(config.onDisconnect) ? config.onDisconnect : () => {
},
onError: Type.isFunction(config.onError) ? config.onError : () => {
},
onMessage: 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);
}
}
export { AbstractConnector };
//# sourceMappingURL=abstract-connector.mjs.map