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.6KB

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