Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

JitsiConnection.js 2.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. }
  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. return new JitsiConference({name: name, config: options, connection: this});
  48. }
  49. /**
  50. * Subscribes the passed listener to the event.
  51. * @param event {JitsiConnectionEvents} the connection event.
  52. * @param listener {Function} the function that will receive the event
  53. */
  54. JitsiConnection.prototype.addListener = function (event, listener) {
  55. this.xmpp.addListener(event, listener);
  56. }
  57. /**
  58. * Unsubscribes the passed handler.
  59. * @param event {JitsiConnectionEvents} the connection event.
  60. * @param listener {Function} the function that will receive the event
  61. */
  62. JitsiConnection.prototype.removeListener = function (event, listener) {
  63. this.xmpp.removeListener(event, listener);
  64. }
  65. module.exports = JitsiConnection;