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

JitsiConnection.js 2.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. var JitsiConference = require("./JitsiConference");
  2. var XMPP = require("./modules/xmpp/xmpp");
  3. /**
  4. * Creates new connection object for the Jitsi Meet server side video conferencing service. Provides access to the
  5. * JitsiConference interface.
  6. * @param appID identification for the provider of Jitsi Meet video conferencing services.
  7. * @param token the JWT token used to authenticate with the server(optional)
  8. * @param options Object with properties / settings related to connection with the server.
  9. * @constructor
  10. */
  11. function JitsiConnection(appID, token, options) {
  12. this.appID = appID;
  13. this.token = token;
  14. this.options = options;
  15. this.xmpp = new XMPP(options);
  16. this.conferences = {};
  17. }
  18. /**
  19. * Connect the client with the server.
  20. * @param options {object} connecting options (for example authentications parameters).
  21. */
  22. JitsiConnection.prototype.connect = function (options) {
  23. if(!options)
  24. options = {};
  25. this.xmpp.connect(options.id, options.password);
  26. }
  27. /**
  28. * Disconnect the client from the server.
  29. */
  30. JitsiConnection.prototype.disconnect = function () {
  31. this.xmpp.disconnect();
  32. }
  33. /**
  34. * This method allows renewal of the tokens if they are expiring.
  35. * @param token the new token.
  36. */
  37. JitsiConnection.prototype.setToken = function (token) {
  38. this.token = token;
  39. }
  40. /**
  41. * Creates and joins new conference.
  42. * @param name the name of the conference; if null - a generated name will be
  43. * provided from the api
  44. * @param options Object with properties / settings related to the conference
  45. * that will be created.
  46. * @returns {JitsiConference} returns the new conference object.
  47. */
  48. JitsiConnection.prototype.initJitsiConference = function (name, options) {
  49. this.conferences[name] = new JitsiConference({name: name, config: options,
  50. connection: this});
  51. return this.conferences[name];
  52. }
  53. /**
  54. * Subscribes the passed listener to the event.
  55. * @param event {JitsiConnectionEvents} the connection event.
  56. * @param listener {Function} the function that will receive the event
  57. */
  58. JitsiConnection.prototype.addEventListener = function (event, listener) {
  59. this.xmpp.addListener(event, listener);
  60. }
  61. /**
  62. * Unsubscribes the passed handler.
  63. * @param event {JitsiConnectionEvents} the connection event.
  64. * @param listener {Function} the function that will receive the event
  65. */
  66. JitsiConnection.prototype.removeEventListener = function (event, listener) {
  67. this.xmpp.removeListener(event, listener);
  68. }
  69. module.exports = JitsiConnection;