You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ComponentsVersions.js 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. const logger = require('@jitsi/logger').getLogger(__filename);
  2. /**
  3. * Creates new instance of <tt>ComponentsVersions</tt> which will be discovering
  4. * the versions of conferencing system components in given
  5. * <tt>JitsiConference</tt>.
  6. * @param conference <tt>JitsiConference</tt> instance which will be used to
  7. * listen for focus presence updates.
  8. * @constructor
  9. */
  10. export default function ComponentsVersions(conference) {
  11. this.versions = {};
  12. this.conference = conference;
  13. this.conference.addCommandListener(
  14. 'versions', this.processVersions.bind(this));
  15. }
  16. ComponentsVersions.prototype.processVersions
  17. = function(versions, mucResource, mucJid) {
  18. if (!this.conference.isFocus(mucJid)) {
  19. logger.warn(
  20. `Received versions not from the focus user: ${versions}`,
  21. mucJid);
  22. return;
  23. }
  24. versions.children.forEach(component => {
  25. const name = component.attributes.name;
  26. const version = component.value;
  27. if (this.versions[name] !== version) {
  28. this.versions[name] = version;
  29. logger.info(`Got ${name} version: ${version}`);
  30. }
  31. });
  32. };
  33. /**
  34. * Obtains the version of conferencing system component.
  35. * @param componentName the name of the component for which we want to obtain
  36. * the version.
  37. * @returns {String} which describes the version of the component identified by
  38. * given <tt>componentName</tt> or <tt>undefined</tt> if not found.
  39. */
  40. ComponentsVersions.prototype.getComponentVersion = function(componentName) {
  41. return this.versions[componentName];
  42. };