src/meetings/Meeting.js
import {EventEmitter} from '../eventemitter';
/**
* Represents a meeting. This class must not be directly instantiated. Instead,
* instances of this class are obtained by calling the {@link MeetingManager#createMeeting}
* or {@link MeetingManager#getMeetings} methods of {MeetingManager}
*
* ## Events
*
* - **`delete`** is emitted when the meeting is deleted.
*/
export default class Meeting extends EventEmitter {
/**
* Constructs a new meeting
* @protected
* @param {WacStack} stack
* @param {Meeting} meeting
* @property {String} meeting.id The ID of the meeting
* @property {String} meeting.name The name for the meeting
* @property {Array} meeting.participants The people participating of the meeting
* @property {String} meeting.language The language for the meeting
* @property {Integer} meeting.validSince The starting time for the meeting
* @property {Integer} meeting.validUntil The ending time for the meeting
* @property {String} meeting.url The link to access to the meeting
* @property {String} meeting.phone Who will be called to access to the meeting
*/
constructor(stack, meeting) {
super();
/**
* @private
* @type {WacStack}
*/
this._stack = stack;
/**
* @private
* @type {string}
*/
this._id = meeting.id;
/**
* @private
* @type {String}
*/
this._name = meeting.name;
/**
* @private
* @type {Array}
*/
this._participants = meeting.participants;
/**
* @private
* @type {String}
*/
this._language = meeting.language;
/**
* @private
* @type {Integer}
*/
this._validSince = meeting.validSince;
/**
* @private
* @type {Integer}
*/
this._validUntil = meeting.validUntil;
/**
* @private
* @type {String}
*/
this._url = meeting.url;
/**
* @private
* @type {String}
*/
this._phone = meeting.phone;
}
/**
* The ID of the meeting
* @type {string}
*/
get id() {
return this._id;
}
/**
* The name for the meeting
* @type {string}
*/
get name() {
return this._name;
}
/**
* The people participating of the meeting
* @type {string}
*/
get participants() {
return this._participants;
}
/**
* The language for the meeting
* @type {string}
*/
get language() {
return this._language;
}
/**
* The starting time for the meeting
* @type {string}
*/
get validSince() {
return this._validSince;
}
/**
* The ending time for the meeting
* @type {string}
*/
get validUntil() {
return this._validUntil;
}
/**
* The link to access to the meeting
* @type {string}
*/
get url() {
return this._url;
}
/**
* Who will be called to access to the meeting
* @type {string}
*/
get phone() {
return this._phone;
}
/**
* Update the ID of a meeting
* @type {string}
*/
set id(value) {
this._id = value;
}
/**
* Update the phone of a meeting
* @type {string}
*/
set phone(value) {
this._phone = value;
}
/**
* Resend the invitation to all participants
* @return {Promise<Meeting>}
*/
reinvite() {
return this._stack.sendMeetingInvites(this._id).then(() => this);
}
/**
* Removes the meeting
* @return {Promise<undefined,Error>}
*/
destroy() {
return this._stack.delete(this._id).then(() => this._remove());
}
/**
* Check if the participant in a meeting is online
* @return {Boolean}
*/
isOnline() {
return this.phone !== '';
}
/**
* Removes (locally) the meeting
* @protected
*/
_remove() {
this._stack = null;
this.emit('delete');
}
/**
* Returns a JS object with the JSON serialization representation of this object
* @return {Object}
* @property {String} id
* @property {String} name
* @property {Array} participants
* @property {String} language
* @property {Integer} validSince
* @property {Integer} validUntil
* @property {String} url
* @property {String} phone
*/
toJSON() {
return {
id: this._id,
name: this._name,
participants: this._participants,
language: this._language,
validSince: this._source,
validUntil: this._presence,
url: this._url,
phone: this._phone,
};
}
}