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.

JitsiConnection.js 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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 provided from the api
  43. * @param options Object with properties / settings related to the conference that will be created.
  44. * @returns {JitsiConference} returns the new conference object.
  45. */
  46. JitsiConnection.prototype.initJitsiConference = function (name, options) {
  47. this.conferences[name] = new JitsiConference({name: name, config: options, connection: this});
  48. return this.conferences[name];
  49. }
  50. /**
  51. * Subscribes the passed listener to the event.
  52. * @param event {JitsiConnectionEvents} the connection event.
  53. * @param listener {Function} the function that will receive the event
  54. */
  55. JitsiConnection.prototype.addEventListener = function (event, listener) {
  56. this.xmpp.addListener(event, listener);
  57. }
  58. /**
  59. * Unsubscribes the passed handler.
  60. * @param event {JitsiConnectionEvents} the connection event.
  61. * @param listener {Function} the function that will receive the event
  62. */
  63. JitsiConnection.prototype.removeEventListener = function (event, listener) {
  64. this.xmpp.removeListener(event, listener);
  65. }
  66. module.exports = JitsiConnection;