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

ComponentsVersions.js 2.5KB

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