export class Room {
    constructor(roomName, options, peerFactory) {
        this.roomName = roomName;
        this.options = options;
        this.peerFactory = peerFactory;
        this.users = new Map();
        this.connections = new Set();
        this.adapters = new Set();
    }
    getRegistrationInfo() {
        return {
            room: this.roomName,
            token: this.options.token
        };
    }
    async addUsers(users) {
        for (let user of users) {
            this.users.set(user.user, user);
            if (user.user > this.options.user)
                this.setConnection(user);
        }
    }
    async setConnection(user) {
        const connection = await this.peerFactory.getConnection(user, this.roomName, this.options.user);
        this.connections.add(connection);
        for (let adapter of this.adapters) {
            adapter.connect(connection);
        }
        return connection;
    }
    addConnection(connection) {
        this.connections.add(connection);
        for (let adapter of this.adapters) {
            adapter.connect(connection);
        }
        return connection;
    }
    addAdapter(docAdapter) {
        for (let connection of this.connections) {
            docAdapter.connect(connection);
        }
        this.adapters.add(docAdapter);
    }
    disconnect() {
    }
}
//# sourceMappingURL=room.js.map