import { __awaiter } from "tslib";
import { ReceiverSession } from '../screen';
const ackRequestTimeout = 10000;
export class SpyScreen extends ReceiverSession {
    constructor(cli, userId, conf, log) {
        super(conf, log);
        this.cli = cli;
        this.recordings = false;
        this.toUserId = userId;
        this.fromSockId = '';
    }
    answerSession(fromSockId, ans) {
        return __awaiter(this, void 0, void 0, function* () {
            this.fromSockId = fromSockId;
            return this.answer(ans);
        });
    }
    screenshot() {
        return __awaiter(this, void 0, void 0, function* () {
            return this.cli.ackRequest(`screenshot`, {
                to_user_id: this.toUserId,
            }, ackRequestTimeout);
        });
    }
    startRecord() {
        return __awaiter(this, void 0, void 0, function* () {
            if (this.recordings) {
                throw new Error('recordings already exists');
            }
            const res = yield this.cli.ackRequest(`start_record_screen`, {
                root_id: this.id,
                to_user_id: this.toUserId,
            }, ackRequestTimeout);
            this.recordings = true;
            return res;
        });
    }
    stopRecord() {
        return __awaiter(this, void 0, void 0, function* () {
            if (!this.recordings) {
                throw new Error('recordings not exists');
            }
            const res = yield this.cli.ackRequest(`stop_record_screen`, {
                root_id: this.id,
                to_user_id: this.toUserId,
            }, ackRequestTimeout);
            this.recordings = false;
            return res;
        });
    }
}
//# sourceMappingURL=screen.js.map