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 = '';
    }
    async answerSession(fromSockId, ans) {
        this.fromSockId = fromSockId;
        return this.answer(ans);
    }
    async screenshot() {
        return this.cli.ackRequest(`screenshot`, {
            to_user_id: this.toUserId,
        }, ackRequestTimeout);
    }
    async startRecord() {
        if (this.recordings) {
            throw new Error('recordings already exists');
        }
        const res = await this.cli.ackRequest(`start_record_screen`, {
            root_id: this.id,
            to_user_id: this.toUserId,
        }, ackRequestTimeout);
        this.recordings = true;
        return res;
    }
    async stopRecord() {
        if (!this.recordings) {
            throw new Error('recordings not exists');
        }
        const res = await 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