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

ComponentsVersions.js 2.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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});
  62. }
  63. }.bind(this));
  64. // logs versions to stats
  65. if (log.length > 0)
  66. Statistics.sendLog(JSON.stringify(log));
  67. };
  68. /**
  69. * Obtains the version of conferencing system component.
  70. * @param componentName the name of the component for which we want to obtain
  71. * the version.
  72. * @returns {String} which describes the version of the component identified by
  73. * given <tt>componentName</tt> or <tt>undefined</tt> if not found.
  74. */
  75. ComponentsVersions.prototype.getComponentVersion = function(componentName) {
  76. return this.versions[componentName];
  77. };
  78. module.exports = ComponentsVersions;