Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

ComponentsVersions.js 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. const logger = require('jitsi-meet-logger').getLogger(__filename);
  2. const Statistics = require('../statistics/statistics');
  3. /**
  4. * The constant for the name of the focus component.
  5. * @type {string}
  6. */
  7. ComponentsVersions.FOCUS_COMPONENT = 'focus';
  8. /**
  9. * The constant for the name of the videobridge component.
  10. * @type {string}
  11. */
  12. ComponentsVersions.VIDEOBRIDGE_COMPONENT = 'videobridge';
  13. /**
  14. * The constant for the name of the XMPP server component.
  15. * @type {string}
  16. */
  17. ComponentsVersions.XMPP_SERVER_COMPONENT = 'xmpp';
  18. /**
  19. * Creates new instance of <tt>ComponentsVersions</tt> which will be discovering
  20. * the versions of conferencing system components in given
  21. * <tt>JitsiConference</tt>.
  22. * @param conference <tt>JitsiConference</tt> instance which will be used to
  23. * listen for focus presence updates.
  24. * @constructor
  25. */
  26. function ComponentsVersions(conference) {
  27. this.versions = {};
  28. this.conference = conference;
  29. this.conference.addCommandListener(
  30. 'versions', this.processPresence.bind(this));
  31. }
  32. ComponentsVersions.prototype.processPresence
  33. = function(node, mucResource, mucJid) {
  34. if (node.attributes.xmlns !== 'http://jitsi.org/jitmeet') {
  35. logger.warn('Ignored presence versions node - invalid xmlns', node);
  36. return;
  37. }
  38. if (!this.conference._isFocus(mucJid)) {
  39. logger.warn(
  40. `Received versions not from the focus user: ${node}`,
  41. mucJid);
  42. return;
  43. }
  44. const log = [];
  45. node.children.forEach(item => {
  46. const componentName = item.attributes.name;
  47. if (componentName !== ComponentsVersions.FOCUS_COMPONENT
  48. && componentName !== ComponentsVersions.XMPP_SERVER_COMPONENT
  49. && componentName !== ComponentsVersions.VIDEOBRIDGE_COMPONENT) {
  50. logger.warn(
  51. `Received version for not supported component name: ${
  52. componentName}`);
  53. return;
  54. }
  55. const version = item.value;
  56. if (this.versions[componentName] !== version) {
  57. this.versions[componentName] = version;
  58. logger.info(`Got ${componentName} version: ${version}`);
  59. log.push({
  60. id: 'component_version',
  61. component: componentName,
  62. version
  63. });
  64. }
  65. });
  66. // logs versions to stats
  67. if (log.length > 0) {
  68. Statistics.sendLog(JSON.stringify(log));
  69. }
  70. };
  71. /**
  72. * Obtains the version of conferencing system component.
  73. * @param componentName the name of the component for which we want to obtain
  74. * the version.
  75. * @returns {String} which describes the version of the component identified by
  76. * given <tt>componentName</tt> or <tt>undefined</tt> if not found.
  77. */
  78. ComponentsVersions.prototype.getComponentVersion = function(componentName) {
  79. return this.versions[componentName];
  80. };
  81. module.exports = ComponentsVersions;