Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

JitsiConference.js 5.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. /**
  2. * Creates a JitsiConference object with the given name and properties.
  3. * Note: this constructor is not a part of the public API (objects should be
  4. * created using JitsiConnection.createConference).
  5. * @param options.config properties / settings related to the conference that will be created.
  6. * @param options.name the name of the conference
  7. * @param options.connection the JitsiConnection object for this JitsiConference.
  8. * @constructor
  9. */
  10. function JitsiConference(options) {
  11. this.options = options;
  12. this.connection = this.options.connection;
  13. this.xmpp = this.connection.xmpp;
  14. this.room = this.xmpp.createRoom(this.options.name, null, null);
  15. }
  16. /**
  17. * Joins the conference.
  18. * @param password {string} the password
  19. */
  20. JitsiConference.prototype.join = function (password) {
  21. this.room.joinRoom(password);
  22. }
  23. /**
  24. * Leaves the conference.
  25. */
  26. JitsiConference.prototype.leave = function () {
  27. this.xmpp.leaveRoom(room.roomjid);
  28. this.room = null;
  29. }
  30. /**
  31. * Creates the media tracks and returns them via the callback.
  32. * @param options Object with properties / settings specifying the tracks which should be created.
  33. * should be created or some additional configurations about resolution for example.
  34. * @returns {Promise.<{Array.<JitsiTrack>}, JitsiConferenceError>} A promise that returns an array of created JitsiTracks if resolved,
  35. * or a JitsiConferenceError if rejected.
  36. */
  37. JitsiConference.prototype.createLocalTracks = function (options) {
  38. }
  39. /**
  40. * Returns the local tracks.
  41. */
  42. JitsiConference.prototype.getLocalTracks = function () {
  43. };
  44. /**
  45. * Attaches a handler for events(For example - "participant joined".) in the conference. All possible event are defined
  46. * in JitsiConferenceEvents.
  47. * @param eventId the event ID.
  48. * @param handler handler for the event.
  49. *
  50. * Note: consider adding eventing functionality by extending an EventEmitter impl, instead of rolling ourselves
  51. */
  52. JitsiConference.prototype.on = function (eventId, handler) {
  53. this.add.addListener(eventId, handler);
  54. }
  55. /**
  56. * Removes event listener
  57. * @param eventId the event ID.
  58. * @param [handler] optional, the specific handler to unbind
  59. *
  60. * Note: consider adding eventing functionality by extending an EventEmitter impl, instead of rolling ourselves
  61. */
  62. JitsiConference.prototype.off = function (eventId, handler) {
  63. this.room.removeListener(eventId, listener);
  64. }
  65. // Common aliases for event emitter
  66. JitsiConference.prototype.addEventListener = JitsiConference.prototype.on
  67. JitsiConference.prototype.removeEventListener = JitsiConference.prototype.off
  68. /**
  69. * Receives notifications from another participants for commands / custom events(send by sendPresenceCommand method).
  70. * @param command {String} the name of the command
  71. * @param handler {Function} handler for the command
  72. */
  73. JitsiConference.prototype.addCommandListener = function (command, handler) {
  74. this.room.addPresenceListener(command, handler);
  75. }
  76. /**
  77. * Removes command listener
  78. * @param command {String} the name of the command
  79. */
  80. JitsiConference.prototype.removeCommandListener = function (command) {
  81. this.room.removePresenceListener(command);
  82. }
  83. /**
  84. * Sends text message to the other participants in the conference
  85. * @param message the text message.
  86. */
  87. JitsiConference.prototype.sendTextMessage = function (message) {
  88. this.room.sendMessage(message);
  89. }
  90. /**
  91. * Send presence command.
  92. * @param name the name of the command.
  93. * @param values Object with keys and values that will be send.
  94. **/
  95. JitsiConference.prototype.sendCommand = function (name, values) {
  96. this.room.addToPresence(name, values);
  97. this.room.sendPresence();
  98. }
  99. /**
  100. * Send presence command one time.
  101. * @param name the name of the command.
  102. * @param values Object with keys and values that will be send.
  103. **/
  104. JitsiConference.prototype.sendCommandOnce = function (name, values) {
  105. this.sendCommand(name, values);
  106. this.removeCommand(name);
  107. }
  108. /**
  109. * Send presence command.
  110. * @param name the name of the command.
  111. * @param values Object with keys and values that will be send.
  112. * @param persistent if false the command will be sent only one time
  113. **/
  114. JitsiConference.prototype.removeCommand = function (name) {
  115. this.room.removeFromPresence(name);
  116. }
  117. /**
  118. * Sets the display name for this conference.
  119. * @param name the display name to set
  120. */
  121. JitsiConference.prototype.setDisplayName = function(name) {
  122. this.room.addToPresence("nick", {attributes: {xmlns: 'http://jabber.org/protocol/nick'}, value: name});
  123. }
  124. /**
  125. * Elects the participant with the given id to be the selected participant or the speaker.
  126. * @param id the identifier of the participant
  127. */
  128. JitsiConference.prototype.selectParticipant = function(participantId) {
  129. }
  130. /**
  131. * Returns the list of participants for this conference.
  132. * @return Object a list of participant identifiers containing all conference participants.
  133. */
  134. JitsiConference.prototype.getParticipants = function() {
  135. }
  136. /**
  137. * @returns {JitsiParticipant} the participant in this conference with the specified id (or
  138. * null if there isn't one).
  139. * @param id the id of the participant.
  140. */
  141. JitsiConference.prototype.getParticipantById = function(id) {
  142. }
  143. module.exports = JitsiConference;