Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

ComponentsVersions.js 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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
  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. if(this.versions[componentName] &&
  57. componentName !== ComponentsVersions.FOCUS_COMPONENT &&
  58. componentName !== ComponentsVersions.VIDEOBRIDGE_COMPONENT) {
  59. //version is changed during the call
  60. this.conference._fireIncompatibleVersionsEvent();
  61. }
  62. this.versions[componentName] = version;
  63. logger.info("Got " + componentName + " version: " + version);
  64. log += (log.length > 0? ", " : "")
  65. + componentName + ": " + version;
  66. }
  67. }.bind(this));
  68. // logs versions to stats
  69. if (log.length > 0)
  70. Statistics.sendLog(log);
  71. };
  72. /**
  73. * Obtains the version of conferencing system component.
  74. * @param componentName the name of the component for which we want to obtain
  75. * the version.
  76. * @returns {String} which describes the version of the component identified by
  77. * given <tt>componentName</tt> or <tt>undefined</tt> if not found.
  78. */
  79. ComponentsVersions.prototype.getComponentVersion = function(componentName) {
  80. return this.versions[componentName];
  81. };
  82. module.exports = ComponentsVersions;