open-collaboration-server
Version:
Open Collaboration Server implementation, part of the Open Collaboration Tools project
31 lines • 1.03 kB
JavaScript
// ******************************************************************************
// Copyright 2024 TypeFox GmbH
// This program and the accompanying materials are made available under the
// terms of the MIT License, which is available in the project root.
// ******************************************************************************
import * as protocol from 'open-collaboration-protocol';
export class Room {
id;
host;
guests;
clock = 0;
constructor(id, host, guests) {
this.id = id;
this.host = host;
this.guests = guests;
}
get peers() {
return [this.host, ...this.guests];
}
getPeer(id) {
return this.peers.find(peer => peer.id === id);
}
removeGuest(id) {
this.guests = this.guests.filter(peer => peer.id !== id);
}
}
export function isUser(obj) {
return protocol.isObject(obj) && typeof obj.id === 'string' && typeof obj.name === 'string';
}
export const PeerInfo = Symbol('PeerInfo');
//# sourceMappingURL=types.js.map