您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

ComponentsVersions.js 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. var logger = require("jitsi-meet-logger").getLogger(__filename);
  2. var 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, mucJid);
  41. return;
  42. }
  43. var log = [];
  44. node.children.forEach(function(item){
  45. var componentName = item.attributes.name;
  46. if (componentName !== ComponentsVersions.FOCUS_COMPONENT &&
  47. componentName !== ComponentsVersions.XMPP_SERVER_COMPONENT &&
  48. componentName !== ComponentsVersions.VIDEOBRIDGE_COMPONENT) {
  49. logger.warn(
  50. "Received version for not supported component name: "
  51. + componentName);
  52. return;
  53. }
  54. var version = item.value;
  55. if (this.versions[componentName] !== version) {
  56. this.versions[componentName] = version;
  57. logger.info("Got " + componentName + " version: " + version);
  58. log.push({
  59. id: "component_version",
  60. component: componentName,
  61. version: version});
  62. }
  63. }.bind(this));
  64. // logs versions to stats
  65. if (log.length > 0) {
  66. Statistics.sendLog(JSON.stringify(log));
  67. }
  68. };
  69. /**
  70. * Obtains the version of conferencing system component.
  71. * @param componentName the name of the component for which we want to obtain
  72. * the version.
  73. * @returns {String} which describes the version of the component identified by
  74. * given <tt>componentName</tt> or <tt>undefined</tt> if not found.
  75. */
  76. ComponentsVersions.prototype.getComponentVersion = function(componentName) {
  77. return this.versions[componentName];
  78. };
  79. module.exports = ComponentsVersions;