"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ConnectionImpl = void 0;
class ConnectionImpl {
    constructor(rs) {
        this.wsw = rs;
        this.connectionStatus = 'NOT_CONNECTED';
    }
    close() {
        this.wsw.close();
    }
    onConnected(callback) {
        var _a;
        (_a = this.wsw) === null || _a === void 0 ? void 0 : _a.addStatusCallback('CONNECTED', (ws) => {
            this.connectionStatus = 'CONNECTED';
            callback();
        });
        return this;
    }
    onClosed(callback) {
        var _a;
        (_a = this.wsw) === null || _a === void 0 ? void 0 : _a.addStatusCallback('CLOSED', (ws) => {
            this.connectionStatus = 'CLOSED';
            callback();
        });
        return this;
    }
    onError(callback) {
        var _a;
        (_a = this.wsw) === null || _a === void 0 ? void 0 : _a.addStatusCallback('ERROR', (ws, e) => {
            this.connectionStatus = 'ERROR';
            callback(e);
        });
        return this;
    }
}
exports.ConnectionImpl = ConnectionImpl;
//# sourceMappingURL=Connection.js.map