modified lib-jitsi-meet dev repo
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.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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 contant 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 <tt>ChatRoom</tt>.
  21. * @param chatRoom <tt>ChatRoom</tt> instance which will be used to listen for
  22. * focus presence updates.
  23. * @constructor
  24. */
  25. function ComponentsVersions(chatRoom) {
  26. this.versions = {};
  27. this.chatRoom = chatRoom;
  28. this.chatRoom.addPresenceListener(
  29. 'versions', this.processPresence.bind(this));
  30. }
  31. ComponentsVersions.prototype.processPresence =
  32. function(node, mucResource, mucJid) {
  33. if (node.attributes.xmlns !== 'http://jitsi.org/jitmeet') {
  34. logger.warn("Ignored presence versions node - invalid xmlns", node);
  35. return;
  36. }
  37. if (!this.chatRoom.isFocus(mucJid)) {
  38. logger.warn(
  39. "Received versions not from the focus user: " + node, mucJid);
  40. return;
  41. }
  42. var log = "";
  43. node.children.forEach(function(item){
  44. var componentName = item.attributes.name;
  45. if (componentName !== ComponentsVersions.FOCUS_COMPONENT &&
  46. componentName !== ComponentsVersions.XMPP_SERVER_COMPONENT &&
  47. componentName !== ComponentsVersions.VIDEOBRIDGE_COMPONENT) {
  48. logger.warn(
  49. "Received version for not supported component name: "
  50. + componentName);
  51. return;
  52. }
  53. var version = item.value;
  54. if (this.versions[componentName] !== version) {
  55. this.versions[componentName] = version;
  56. logger.info("Got " + componentName + " version: " + version);
  57. log += (log.length > 0? ", " : "")
  58. + componentName + ": " + version;
  59. }
  60. }.bind(this));
  61. // logs versions to stats
  62. if (log.length > 0)
  63. Statistics.sendLog(log);
  64. };
  65. /**
  66. * Obtains the version of conferencing system component.
  67. * @param componentName the name of the component for which we want to obtain
  68. * the version.
  69. * @returns {String} which describes the version of the component identified by
  70. * given <tt>componentName</tt> or <tt>undefined</tt> if not found.
  71. */
  72. ComponentsVersions.prototype.getComponentVersion = function(componentName) {
  73. return this.versions[componentName];
  74. };
  75. module.exports = ComponentsVersions;