src/conferences/Invitation.js
/**
* This class allows access to the details of each outgoing invitation in a Conference
* @link {Conference#getOutgoingInvitations()} method should be used to obtain the list
* of instances of this class.
* This is an immutable object, the private setters return a new object instance.
*/
export class Invitation {
/** @private */
constructor(toUser, to, mediaTypes, autoAccepted, responseCode, hasStreams, canceled) {
this._toUser = toUser;
this._to = to;
this._mediaTypes = mediaTypes;
this._autoAccepted = autoAccepted;
this._responseCode = responseCode;
this._hasStreams = hasStreams;
this._canceled = canceled;
this._timestamp = Date.now();
Object.freeze(this);
}
/**
* Obtains the User object representing the WAC user of the invited user
* If we are not inviting a wac user, this will be empty.
* @returns {Object}
*/
getToUser() {
return this._toUser;
}
/**
* Obtains the "gateway username" of the invited user.
* @returns {string}
*/
getTo() {
return this._to;
}
/**
* Obtains the mediaTypes for this invitation.
* This allow us to guess if we are inviting the user with audio & video, or only with audio and video
* @returns {MediaTypes}
*/
getMediaTypes() {
return this._mediaTypes;
}
/**
* Returns true when the invitation is marked as "auto accepted".
* The "auto accepted" invitations are sent after accepting an invitation request and they are going to be accepted
* automatically by the invited user.
* @returns {boolean}
*/
isAutoAccepted() {
return this._autoAccepted;
}
/**
* Returns The response code of the invitation.
* This will be a 200 (OK) when the invited user accepts the invitation.
* @returns {number}
*/
getResponseCode() {
return this._responseCode;
}
/**
* Returns true when the conference room has a stream associated to the invited user.
* @returns {boolean}
*/
hasStreams() {
return this._hasStreams;
}
/**
* Returns true when the user has cancelled this invitation.
* @returns {boolean}
*/
isCanceled() {
return this._canceled;
}
/**
* Utility method that returns true when the invitation does not has a response code and it it not cancelled.
* @returns {boolean}
*/
isActive() {
return !this._responseCode && !this._canceled;
}
/**
* Returns the timestamp when this invitation object was created.
* This is useful to keep the client showing the invitations with errors for a period of time.
* @returns {number}
*/
getTimestamp() {
return this._timestamp;
}
/** @private */
setTo(to) {
return new Invitation(this._toUser, to, this._mediaTypes, this._autoAccepted, this._responseCode, this._hasStreams, this._canceled);
}
/** @private */
setResponseCode(responseCode) {
return new Invitation(this._toUser, this._to, this._mediaTypes, this._autoAccepted, responseCode, this._hasStreams, this._canceled);
}
/** @private */
setCanceled(canceled) {
return new Invitation(this._toUser, this._to, this._mediaTypes, this._autoAccepted, this._responseCode, this._hasStreams, canceled);
}
/** @private */
setStreams(hasStreams) {
return new Invitation(this._toUser, this._to, this._mediaTypes, this._autoAccepted, this._responseCode, hasStreams, this._canceled);
}
}