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 2.0KB

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