modified lib-jitsi-meet dev repo
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

JitsiConference.js 43KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341
  1. /* global Strophe, $, Promise */
  2. /* jshint -W101 */
  3. var logger = require("jitsi-meet-logger").getLogger(__filename);
  4. var RTC = require("./modules/RTC/RTC");
  5. var XMPPEvents = require("./service/xmpp/XMPPEvents");
  6. var EventEmitter = require("events");
  7. import * as JitsiConferenceErrors from "./JitsiConferenceErrors";
  8. import * as JitsiConferenceEvents from "./JitsiConferenceEvents";
  9. import JitsiParticipant from "./JitsiParticipant";
  10. var Statistics = require("./modules/statistics/statistics");
  11. var JitsiDTMFManager = require('./modules/DTMF/JitsiDTMFManager');
  12. import JitsiTrackError from "./JitsiTrackError";
  13. import * as JitsiTrackErrors from "./JitsiTrackErrors";
  14. import * as JitsiTrackEvents from "./JitsiTrackEvents";
  15. var Settings = require("./modules/settings/Settings");
  16. var ComponentsVersions = require("./modules/version/ComponentsVersions");
  17. var GlobalOnErrorHandler = require("./modules/util/GlobalOnErrorHandler");
  18. var JitsiConferenceEventManager = require("./JitsiConferenceEventManager");
  19. var VideoType = require('./service/RTC/VideoType');
  20. var Transcriber = require("./modules/transcription/transcriber");
  21. var ParticipantConnectionStatus
  22. = require("./modules/connectivity/ParticipantConnectionStatus");
  23. /**
  24. * Creates a JitsiConference object with the given name and properties.
  25. * Note: this constructor is not a part of the public API (objects should be
  26. * created using JitsiConnection.createConference).
  27. * @param options.config properties / settings related to the conference that will be created.
  28. * @param options.name the name of the conference
  29. * @param options.connection the JitsiConnection object for this JitsiConference.
  30. * @constructor
  31. */
  32. function JitsiConference(options) {
  33. if(!options.name || options.name.toLowerCase() !== options.name) {
  34. var errmsg
  35. = "Invalid conference name (no conference name passed or it "
  36. + "contains invalid characters like capital letters)!";
  37. logger.error(errmsg);
  38. throw new Error(errmsg);
  39. }
  40. this.eventEmitter = new EventEmitter();
  41. this.settings = new Settings();
  42. this.options = options;
  43. this.eventManager = new JitsiConferenceEventManager(this);
  44. this._init(options);
  45. this.componentsVersions = new ComponentsVersions(this);
  46. this.participants = {};
  47. this.lastDominantSpeaker = null;
  48. this.dtmfManager = null;
  49. this.somebodySupportsDTMF = false;
  50. this.authEnabled = false;
  51. this.authIdentity;
  52. this.startAudioMuted = false;
  53. this.startVideoMuted = false;
  54. this.startMutedPolicy = {audio: false, video: false};
  55. this.availableDevices = {
  56. audio: undefined,
  57. video: undefined
  58. };
  59. this.isMutedByFocus = false;
  60. this.reportedAudioSSRCs = {};
  61. // Flag indicates if the 'onCallEnded' method was ever called on this
  62. // instance. Used to log extra analytics event for debugging purpose.
  63. // We need to know if the potential issue happened before or after
  64. // the restart.
  65. this.wasStopped = false;
  66. }
  67. /**
  68. * Initializes the conference object properties
  69. * @param options {object}
  70. * @param connection {JitsiConnection} overrides this.connection
  71. */
  72. JitsiConference.prototype._init = function (options) {
  73. if(!options)
  74. options = {};
  75. // Override connection and xmpp properties (Usefull if the connection
  76. // reloaded)
  77. if(options.connection) {
  78. this.connection = options.connection;
  79. this.xmpp = this.connection.xmpp;
  80. // Setup XMPP events only if we have new connection object.
  81. this.eventManager.setupXMPPListeners();
  82. }
  83. this.room = this.xmpp.createRoom(this.options.name, this.options.config,
  84. this.settings);
  85. this.room.updateDeviceAvailability(RTC.getDeviceAvailability());
  86. if(!this.rtc) {
  87. this.rtc = new RTC(this, options);
  88. this.eventManager.setupRTCListeners();
  89. }
  90. this.participantConnectionStatus
  91. = new ParticipantConnectionStatus(
  92. this.rtc, this,
  93. options.config.peerDisconnectedThroughRtcTimeout);
  94. this.participantConnectionStatus.init();
  95. if(!this.statistics) {
  96. this.statistics = new Statistics(this.xmpp, {
  97. callStatsID: this.options.config.callStatsID,
  98. callStatsSecret: this.options.config.callStatsSecret,
  99. callStatsSecret: this.options.config.callStatsSecret,
  100. callStatsCustomScriptUrl:
  101. this.options.config.callStatsCustomScriptUrl,
  102. roomName: this.options.name
  103. });
  104. }
  105. this.eventManager.setupChatRoomListeners();
  106. // Always add listeners because on reload we are executing leave and the
  107. // listeners are removed from statistics module.
  108. this.eventManager.setupStatisticsListeners();
  109. }
  110. /**
  111. * Joins the conference.
  112. * @param password {string} the password
  113. */
  114. JitsiConference.prototype.join = function (password) {
  115. if(this.room)
  116. this.room.join(password);
  117. };
  118. /**
  119. * Check if joined to the conference.
  120. */
  121. JitsiConference.prototype.isJoined = function () {
  122. return this.room && this.room.joined;
  123. };
  124. /**
  125. * Leaves the conference and calls onMemberLeft for every participant.
  126. */
  127. JitsiConference.prototype._leaveRoomAndRemoveParticipants = function () {
  128. // remove all participants
  129. this.getParticipants().forEach(function (participant) {
  130. this.onMemberLeft(participant.getJid());
  131. }.bind(this));
  132. // leave the conference
  133. if (this.room) {
  134. this.room.leave();
  135. }
  136. this.room = null;
  137. }
  138. /**
  139. * Leaves the conference.
  140. * @returns {Promise}
  141. */
  142. JitsiConference.prototype.leave = function () {
  143. var conference = this;
  144. if (this.participantConnectionStatus) {
  145. this.participantConnectionStatus.dispose();
  146. this.participantConnectionStatus = null;
  147. }
  148. this.statistics.stopCallStats();
  149. this.rtc.closeAllDataChannels();
  150. return Promise.all(
  151. conference.getLocalTracks().map(function (track) {
  152. return conference.removeTrack(track);
  153. })
  154. ).then(this._leaveRoomAndRemoveParticipants.bind(this))
  155. .catch(function (error) {
  156. logger.error(error);
  157. GlobalOnErrorHandler.callUnhandledRejectionHandler(
  158. {promise: this, reason: error});
  159. // We are proceeding with leaving the conference because room.leave may
  160. // succeed.
  161. this._leaveRoomAndRemoveParticipants();
  162. return Promise.resolve();
  163. }.bind(this));
  164. };
  165. /**
  166. * Returns name of this conference.
  167. */
  168. JitsiConference.prototype.getName = function () {
  169. return this.options.name;
  170. };
  171. /**
  172. * Check if authentication is enabled for this conference.
  173. */
  174. JitsiConference.prototype.isAuthEnabled = function () {
  175. return this.authEnabled;
  176. };
  177. /**
  178. * Check if user is logged in.
  179. */
  180. JitsiConference.prototype.isLoggedIn = function () {
  181. return !!this.authIdentity;
  182. };
  183. /**
  184. * Get authorized login.
  185. */
  186. JitsiConference.prototype.getAuthLogin = function () {
  187. return this.authIdentity;
  188. };
  189. /**
  190. * Check if external authentication is enabled for this conference.
  191. */
  192. JitsiConference.prototype.isExternalAuthEnabled = function () {
  193. return this.room && this.room.moderator.isExternalAuthEnabled();
  194. };
  195. /**
  196. * Get url for external authentication.
  197. * @param {boolean} [urlForPopup] if true then return url for login popup,
  198. * else url of login page.
  199. * @returns {Promise}
  200. */
  201. JitsiConference.prototype.getExternalAuthUrl = function (urlForPopup) {
  202. return new Promise(function (resolve, reject) {
  203. if (!this.isExternalAuthEnabled()) {
  204. reject();
  205. return;
  206. }
  207. if (urlForPopup) {
  208. this.room.moderator.getPopupLoginUrl(resolve, reject);
  209. } else {
  210. this.room.moderator.getLoginUrl(resolve, reject);
  211. }
  212. }.bind(this));
  213. };
  214. /**
  215. * Returns the local tracks.
  216. */
  217. JitsiConference.prototype.getLocalTracks = function () {
  218. if (this.rtc) {
  219. return this.rtc.localTracks.slice();
  220. } else {
  221. return [];
  222. }
  223. };
  224. /**
  225. * Attaches a handler for events(For example - "participant joined".) in the conference. All possible event are defined
  226. * in JitsiConferenceEvents.
  227. * @param eventId the event ID.
  228. * @param handler handler for the event.
  229. *
  230. * Note: consider adding eventing functionality by extending an EventEmitter impl, instead of rolling ourselves
  231. */
  232. JitsiConference.prototype.on = function (eventId, handler) {
  233. if(this.eventEmitter)
  234. this.eventEmitter.on(eventId, handler);
  235. };
  236. /**
  237. * Removes event listener
  238. * @param eventId the event ID.
  239. * @param [handler] optional, the specific handler to unbind
  240. *
  241. * Note: consider adding eventing functionality by extending an EventEmitter impl, instead of rolling ourselves
  242. */
  243. JitsiConference.prototype.off = function (eventId, handler) {
  244. if(this.eventEmitter)
  245. this.eventEmitter.removeListener(eventId, handler);
  246. };
  247. // Common aliases for event emitter
  248. JitsiConference.prototype.addEventListener = JitsiConference.prototype.on;
  249. JitsiConference.prototype.removeEventListener = JitsiConference.prototype.off;
  250. /**
  251. * Receives notifications from other participants about commands / custom events
  252. * (sent by sendCommand or sendCommandOnce methods).
  253. * @param command {String} the name of the command
  254. * @param handler {Function} handler for the command
  255. */
  256. JitsiConference.prototype.addCommandListener = function (command, handler) {
  257. if(this.room)
  258. this.room.addPresenceListener(command, handler);
  259. };
  260. /**
  261. * Removes command listener
  262. * @param command {String} the name of the command
  263. */
  264. JitsiConference.prototype.removeCommandListener = function (command) {
  265. if(this.room)
  266. this.room.removePresenceListener(command);
  267. };
  268. /**
  269. * Sends text message to the other participants in the conference
  270. * @param message the text message.
  271. */
  272. JitsiConference.prototype.sendTextMessage = function (message) {
  273. if(this.room)
  274. this.room.sendMessage(message);
  275. };
  276. /**
  277. * Send presence command.
  278. * @param name {String} the name of the command.
  279. * @param values {Object} with keys and values that will be sent.
  280. **/
  281. JitsiConference.prototype.sendCommand = function (name, values) {
  282. if(this.room) {
  283. this.room.addToPresence(name, values);
  284. this.room.sendPresence();
  285. }
  286. };
  287. /**
  288. * Send presence command one time.
  289. * @param name {String} the name of the command.
  290. * @param values {Object} with keys and values that will be sent.
  291. **/
  292. JitsiConference.prototype.sendCommandOnce = function (name, values) {
  293. this.sendCommand(name, values);
  294. this.removeCommand(name);
  295. };
  296. /**
  297. * Removes presence command.
  298. * @param name {String} the name of the command.
  299. **/
  300. JitsiConference.prototype.removeCommand = function (name) {
  301. if(this.room)
  302. this.room.removeFromPresence(name);
  303. };
  304. /**
  305. * Sets the display name for this conference.
  306. * @param name the display name to set
  307. */
  308. JitsiConference.prototype.setDisplayName = function(name) {
  309. if(this.room){
  310. // remove previously set nickname
  311. this.room.removeFromPresence("nick");
  312. this.room.addToPresence("nick", {attributes: {xmlns: 'http://jabber.org/protocol/nick'}, value: name});
  313. this.room.sendPresence();
  314. }
  315. };
  316. /**
  317. * Set new subject for this conference. (available only for moderator)
  318. * @param {string} subject new subject
  319. */
  320. JitsiConference.prototype.setSubject = function (subject) {
  321. if (this.room && this.isModerator()) {
  322. this.room.setSubject(subject);
  323. }
  324. };
  325. /**
  326. * Get a transcriber object for all current participants in this conference
  327. * @return {Transcriber} the transcriber object
  328. */
  329. JitsiConference.prototype.getTranscriber = function(){
  330. if(this.transcriber === undefined){
  331. this.transcriber = new Transcriber();
  332. //add all existing local audio tracks to the transcriber
  333. this.rtc.localTracks.forEach(function (localTrack) {
  334. if(localTrack.isAudioTrack()){
  335. this.transcriber.addTrack(localTrack);
  336. }
  337. }.bind(this));
  338. //and all remote audio tracks
  339. this.rtc.remoteTracks.forEach(function (remoteTrack){
  340. if(remoteTrack.isAudioTrack()){
  341. this.transcriber.addTrack(remoteTrack);
  342. }
  343. }.bind(this));
  344. }
  345. return this.transcriber;
  346. };
  347. /**
  348. * Adds JitsiLocalTrack object to the conference.
  349. * @param track the JitsiLocalTrack object.
  350. * @returns {Promise<JitsiLocalTrack>}
  351. * @throws {Error} if the specified track is a video track and there is already
  352. * another video track in the conference.
  353. */
  354. JitsiConference.prototype.addTrack = function (track) {
  355. if (track.disposed) {
  356. return Promise.reject(
  357. new JitsiTrackError(JitsiTrackErrors.TRACK_IS_DISPOSED));
  358. }
  359. if (track.isVideoTrack()) {
  360. // Ensure there's exactly 1 local video track in the conference.
  361. var localVideoTrack = this.rtc.getLocalVideoTrack();
  362. if (localVideoTrack) {
  363. // Don't be excessively harsh and severe if the API client happens
  364. // to attempt to add the same local video track twice.
  365. if (track === localVideoTrack) {
  366. return Promise.resolve(track);
  367. } else {
  368. return Promise.reject(new Error(
  369. "cannot add second video track to the conference"));
  370. }
  371. }
  372. }
  373. track.ssrcHandler = function (conference, ssrcMap) {
  374. if(ssrcMap[this.getMSID()]){
  375. this._setSSRC(ssrcMap[this.getMSID()]);
  376. conference.room.removeListener(XMPPEvents.SENDRECV_STREAMS_CHANGED,
  377. this.ssrcHandler);
  378. }
  379. }.bind(track, this);
  380. this.room.addListener(XMPPEvents.SENDRECV_STREAMS_CHANGED,
  381. track.ssrcHandler);
  382. if(track.isAudioTrack() || (track.isVideoTrack() &&
  383. track.videoType !== VideoType.DESKTOP)) {
  384. // Report active device to statistics
  385. var devices = RTC.getCurrentlyAvailableMediaDevices();
  386. var device = devices.find(function (d) {
  387. return d.kind === track.getTrack().kind + 'input'
  388. && d.label === track.getTrack().label;
  389. });
  390. if(device)
  391. Statistics.sendActiveDeviceListEvent(
  392. RTC.getEventDataForActiveDevice(device));
  393. }
  394. return new Promise(function (resolve, reject) {
  395. this.room.addStream(track.getOriginalStream(), function () {
  396. if (track.isVideoTrack()) {
  397. this.removeCommand("videoType");
  398. this.sendCommand("videoType", {
  399. value: track.videoType,
  400. attributes: {
  401. xmlns: 'http://jitsi.org/jitmeet/video'
  402. }
  403. });
  404. }
  405. this.rtc.addLocalTrack(track);
  406. if (track.startMuted) {
  407. track.mute();
  408. }
  409. // ensure that we're sharing proper "is muted" state
  410. if (track.isAudioTrack()) {
  411. this.room.setAudioMute(track.isMuted());
  412. } else {
  413. this.room.setVideoMute(track.isMuted());
  414. }
  415. track.muteHandler = this._fireMuteChangeEvent.bind(this, track);
  416. track.audioLevelHandler = this._fireAudioLevelChangeEvent.bind(this);
  417. track.addEventListener(JitsiTrackEvents.TRACK_MUTE_CHANGED,
  418. track.muteHandler);
  419. track.addEventListener(JitsiTrackEvents.TRACK_AUDIO_LEVEL_CHANGED,
  420. track.audioLevelHandler);
  421. track._setConference(this);
  422. // send event for starting screen sharing
  423. // FIXME: we assume we have only one screen sharing track
  424. // if we change this we need to fix this check
  425. if (track.isVideoTrack() && track.videoType === VideoType.DESKTOP)
  426. this.statistics.sendScreenSharingEvent(true);
  427. this.eventEmitter.emit(JitsiConferenceEvents.TRACK_ADDED, track);
  428. resolve(track);
  429. }.bind(this), function (error) {
  430. reject(error);
  431. });
  432. }.bind(this));
  433. };
  434. /**
  435. * Fires TRACK_AUDIO_LEVEL_CHANGED change conference event.
  436. * @param audioLevel the audio level
  437. */
  438. JitsiConference.prototype._fireAudioLevelChangeEvent = function (audioLevel) {
  439. this.eventEmitter.emit(
  440. JitsiConferenceEvents.TRACK_AUDIO_LEVEL_CHANGED,
  441. this.myUserId(), audioLevel);
  442. };
  443. /**
  444. * Fires TRACK_MUTE_CHANGED change conference event.
  445. * @param track the JitsiTrack object related to the event.
  446. */
  447. JitsiConference.prototype._fireMuteChangeEvent = function (track) {
  448. // check if track was muted by focus and now is unmuted by user
  449. if (this.isMutedByFocus && track.isAudioTrack() && !track.isMuted()) {
  450. this.isMutedByFocus = false;
  451. // unmute local user on server
  452. this.room.muteParticipant(this.room.myroomjid, false);
  453. }
  454. this.eventEmitter.emit(JitsiConferenceEvents.TRACK_MUTE_CHANGED, track);
  455. };
  456. /**
  457. * Clear JitsiLocalTrack properties and listeners.
  458. * @param track the JitsiLocalTrack object.
  459. */
  460. JitsiConference.prototype.onTrackRemoved = function (track) {
  461. track._setSSRC(null);
  462. track._setConference(null);
  463. this.rtc.removeLocalTrack(track);
  464. track.removeEventListener(JitsiTrackEvents.TRACK_MUTE_CHANGED,
  465. track.muteHandler);
  466. track.removeEventListener(JitsiTrackEvents.TRACK_AUDIO_LEVEL_CHANGED,
  467. track.audioLevelHandler);
  468. this.room.removeListener(XMPPEvents.SENDRECV_STREAMS_CHANGED,
  469. track.ssrcHandler);
  470. // send event for stopping screen sharing
  471. // FIXME: we assume we have only one screen sharing track
  472. // if we change this we need to fix this check
  473. if (track.isVideoTrack() && track.videoType === VideoType.DESKTOP)
  474. this.statistics.sendScreenSharingEvent(false);
  475. this.eventEmitter.emit(JitsiConferenceEvents.TRACK_REMOVED, track);
  476. }
  477. /**
  478. * Removes JitsiLocalTrack object to the conference.
  479. * @param track the JitsiLocalTrack object.
  480. * @returns {Promise}
  481. */
  482. JitsiConference.prototype.removeTrack = function (track) {
  483. if (track.disposed) {
  484. return Promise.reject(
  485. new JitsiTrackError(JitsiTrackErrors.TRACK_IS_DISPOSED));
  486. }
  487. if(!this.room){
  488. if(this.rtc) {
  489. this.onTrackRemoved(track);
  490. }
  491. return Promise.resolve();
  492. }
  493. return new Promise(function (resolve, reject) {
  494. this.room.removeStream(track.getOriginalStream(), function(){
  495. this.onTrackRemoved(track);
  496. resolve();
  497. }.bind(this), function (error) {
  498. reject(error);
  499. }, {
  500. mtype: track.getType(),
  501. type: "remove",
  502. ssrc: track.ssrc});
  503. }.bind(this));
  504. };
  505. /**
  506. * Get role of the local user.
  507. * @returns {string} user role: 'moderator' or 'none'
  508. */
  509. JitsiConference.prototype.getRole = function () {
  510. return this.room.role;
  511. };
  512. /**
  513. * Check if local user is moderator.
  514. * @returns {boolean} true if local user is moderator, false otherwise.
  515. */
  516. JitsiConference.prototype.isModerator = function () {
  517. return this.room.isModerator();
  518. };
  519. /**
  520. * Set password for the room.
  521. * @param {string} password new password for the room.
  522. * @returns {Promise}
  523. */
  524. JitsiConference.prototype.lock = function (password) {
  525. if (!this.isModerator()) {
  526. return Promise.reject();
  527. }
  528. var conference = this;
  529. return new Promise(function (resolve, reject) {
  530. conference.room.lockRoom(password || "", function () {
  531. resolve();
  532. }, function (err) {
  533. reject(err);
  534. }, function () {
  535. reject(JitsiConferenceErrors.PASSWORD_NOT_SUPPORTED);
  536. });
  537. });
  538. };
  539. /**
  540. * Remove password from the room.
  541. * @returns {Promise}
  542. */
  543. JitsiConference.prototype.unlock = function () {
  544. return this.lock();
  545. };
  546. /**
  547. * Elects the participant with the given id to be the selected participant in
  548. * order to receive higher video quality (if simulcast is enabled).
  549. * Or cache it if channel is not created and send it once channel is available.
  550. * @param participantId the identifier of the participant
  551. * @throws NetworkError or InvalidStateError or Error if the operation fails.
  552. */
  553. JitsiConference.prototype.selectParticipant = function(participantId) {
  554. this.rtc.selectEndpoint(participantId);
  555. };
  556. /**
  557. * Elects the participant with the given id to be the pinned participant in
  558. * order to always receive video for this participant (even when last n is
  559. * enabled).
  560. * @param participantId the identifier of the participant
  561. * @throws NetworkError or InvalidStateError or Error if the operation fails.
  562. */
  563. JitsiConference.prototype.pinParticipant = function(participantId) {
  564. this.rtc.pinEndpoint(participantId);
  565. };
  566. /**
  567. * Returns the list of participants for this conference.
  568. * @return Array<JitsiParticipant> a list of participant identifiers containing all conference participants.
  569. */
  570. JitsiConference.prototype.getParticipants = function() {
  571. return Object.keys(this.participants).map(function (key) {
  572. return this.participants[key];
  573. }, this);
  574. };
  575. /**
  576. * @returns {JitsiParticipant} the participant in this conference with the specified id (or
  577. * undefined if there isn't one).
  578. * @param id the id of the participant.
  579. */
  580. JitsiConference.prototype.getParticipantById = function(id) {
  581. return this.participants[id];
  582. };
  583. /**
  584. * Kick participant from this conference.
  585. * @param {string} id id of the participant to kick
  586. */
  587. JitsiConference.prototype.kickParticipant = function (id) {
  588. var participant = this.getParticipantById(id);
  589. if (!participant) {
  590. return;
  591. }
  592. this.room.kick(participant.getJid());
  593. };
  594. /**
  595. * Kick participant from this conference.
  596. * @param {string} id id of the participant to kick
  597. */
  598. JitsiConference.prototype.muteParticipant = function (id) {
  599. var participant = this.getParticipantById(id);
  600. if (!participant) {
  601. return;
  602. }
  603. this.room.muteParticipant(participant.getJid(), true);
  604. };
  605. /**
  606. * Indicates that a participant has joined the conference.
  607. *
  608. * @param jid the jid of the participant in the MUC
  609. * @param nick the display name of the participant
  610. * @param role the role of the participant in the MUC
  611. * @param isHidden indicates if this is a hidden participant (sysem participant,
  612. * for example a recorder).
  613. */
  614. JitsiConference.prototype.onMemberJoined
  615. = function (jid, nick, role, isHidden) {
  616. var id = Strophe.getResourceFromJid(jid);
  617. if (id === 'focus' || this.myUserId() === id) {
  618. return;
  619. }
  620. var participant = new JitsiParticipant(jid, this, nick, isHidden);
  621. participant._role = role;
  622. this.participants[id] = participant;
  623. this.eventEmitter.emit(JitsiConferenceEvents.USER_JOINED, id, participant);
  624. // XXX Since disco is checked in multiple places (e.g.
  625. // modules/xmpp/strophe.jingle.js, modules/xmpp/strophe.rayo.js), check it
  626. // here as well.
  627. var disco = this.xmpp.connection.disco;
  628. if (disco) {
  629. disco.info(
  630. jid, "node", function(iq) {
  631. participant._supportsDTMF = $(iq).find(
  632. '>query>feature[var="urn:xmpp:jingle:dtmf:0"]').length > 0;
  633. this.updateDTMFSupport();
  634. }.bind(this)
  635. );
  636. } else {
  637. // FIXME Should participant._supportsDTMF be assigned false here (and
  638. // this.updateDTMFSupport invoked)?
  639. }
  640. };
  641. JitsiConference.prototype.onMemberLeft = function (jid) {
  642. var id = Strophe.getResourceFromJid(jid);
  643. if (id === 'focus' || this.myUserId() === id) {
  644. return;
  645. }
  646. var participant = this.participants[id];
  647. delete this.participants[id];
  648. var removedTracks = this.rtc.removeRemoteTracks(id);
  649. removedTracks.forEach(function (track) {
  650. this.eventEmitter.emit(JitsiConferenceEvents.TRACK_REMOVED, track);
  651. }.bind(this));
  652. // there can be no participant in case the member that left is focus
  653. if (participant)
  654. this.eventEmitter.emit(
  655. JitsiConferenceEvents.USER_LEFT, id, participant);
  656. };
  657. JitsiConference.prototype.onUserRoleChanged = function (jid, role) {
  658. var id = Strophe.getResourceFromJid(jid);
  659. var participant = this.getParticipantById(id);
  660. if (!participant) {
  661. return;
  662. }
  663. participant._role = role;
  664. this.eventEmitter.emit(JitsiConferenceEvents.USER_ROLE_CHANGED, id, role);
  665. };
  666. JitsiConference.prototype.onDisplayNameChanged = function (jid, displayName) {
  667. var id = Strophe.getResourceFromJid(jid);
  668. var participant = this.getParticipantById(id);
  669. if (!participant) {
  670. return;
  671. }
  672. if (participant._displayName === displayName)
  673. return;
  674. participant._displayName = displayName;
  675. this.eventEmitter.emit(JitsiConferenceEvents.DISPLAY_NAME_CHANGED, id, displayName);
  676. };
  677. /**
  678. * Notifies this JitsiConference that a JitsiRemoteTrack was added (into the
  679. * ChatRoom of this JitsiConference).
  680. *
  681. * @param {JitsiRemoteTrack} track the JitsiRemoteTrack which was added to this
  682. * JitsiConference
  683. */
  684. JitsiConference.prototype.onTrackAdded = function (track) {
  685. var id = track.getParticipantId();
  686. var participant = this.getParticipantById(id);
  687. if (!participant) {
  688. return;
  689. }
  690. // Add track to JitsiParticipant.
  691. participant._tracks.push(track);
  692. if(this.transcriber){
  693. this.transcriber.addTrack(track);
  694. }
  695. var emitter = this.eventEmitter;
  696. track.addEventListener(
  697. JitsiTrackEvents.TRACK_MUTE_CHANGED,
  698. function () {
  699. emitter.emit(JitsiConferenceEvents.TRACK_MUTE_CHANGED, track);
  700. }
  701. );
  702. track.addEventListener(
  703. JitsiTrackEvents.TRACK_AUDIO_LEVEL_CHANGED,
  704. function (audioLevel) {
  705. emitter.emit(
  706. JitsiConferenceEvents.TRACK_AUDIO_LEVEL_CHANGED,
  707. id,
  708. audioLevel);
  709. }
  710. );
  711. emitter.emit(JitsiConferenceEvents.TRACK_ADDED, track);
  712. };
  713. /**
  714. * Handles incoming call event.
  715. */
  716. JitsiConference.prototype.onIncomingCall =
  717. function (jingleSession, jingleOffer, now) {
  718. if (!this.room.isFocus(jingleSession.peerjid)) {
  719. // Error cause this should never happen unless something is wrong!
  720. var errmsg = "Rejecting session-initiate from non-focus user: "
  721. + jingleSession.peerjid;
  722. GlobalOnErrorHandler.callErrorHandler(new Error(errmsg));
  723. logger.error(errmsg);
  724. return;
  725. }
  726. // Accept incoming call
  727. this.room.setJingleSession(jingleSession);
  728. this.room.connectionTimes["session.initiate"] = now;
  729. // Log "session.restart"
  730. if (this.wasStopped) {
  731. Statistics.sendEventToAll("session.restart");
  732. }
  733. // add info whether call is cross-region
  734. var crossRegion = null;
  735. if (window.jitsiRegionInfo)
  736. crossRegion = window.jitsiRegionInfo["CrossRegion"];
  737. Statistics.analytics.sendEvent("session.initiate",
  738. (now - this.room.connectionTimes["muc.joined"]),
  739. crossRegion);
  740. try{
  741. jingleSession.initialize(false /* initiator */,this.room);
  742. } catch (error) {
  743. GlobalOnErrorHandler.callErrorHandler(error);
  744. };
  745. this.rtc.onIncommingCall(jingleSession);
  746. // Add local Tracks to the ChatRoom
  747. this.rtc.localTracks.forEach(function(localTrack) {
  748. var ssrcInfo = null;
  749. if(localTrack.isVideoTrack() && localTrack.isMuted()) {
  750. /**
  751. * Handles issues when the stream is added before the peerconnection
  752. * is created. The peerconnection is created when second participant
  753. * enters the call. In that use case the track doesn't have
  754. * information about it's ssrcs and no jingle packets are sent. That
  755. * can cause inconsistent behavior later.
  756. *
  757. * For example:
  758. * If we mute the stream and than second participant enter it's
  759. * remote SDP won't include that track. On unmute we are not sending
  760. * any jingle packets which will brake the unmute.
  761. *
  762. * In order to solve issues like the above one here we have to
  763. * generate the ssrc information for the track .
  764. */
  765. localTrack._setSSRC(
  766. this.room.generateNewStreamSSRCInfo());
  767. ssrcInfo = {
  768. mtype: localTrack.getType(),
  769. type: "addMuted",
  770. ssrc: localTrack.ssrc,
  771. msid: localTrack.initialMSID
  772. };
  773. }
  774. try {
  775. this.room.addStream(
  776. localTrack.getOriginalStream(), function () {}, function () {},
  777. ssrcInfo, true);
  778. } catch(e) {
  779. GlobalOnErrorHandler.callErrorHandler(e);
  780. logger.error(e);
  781. }
  782. }.bind(this));
  783. jingleSession.acceptOffer(jingleOffer, null,
  784. function (error) {
  785. GlobalOnErrorHandler.callErrorHandler(error);
  786. logger.error(
  787. "Failed to accept incoming Jingle session", error);
  788. }
  789. );
  790. // Start callstats as soon as peerconnection is initialized,
  791. // do not wait for XMPPEvents.PEERCONNECTION_READY, as it may never
  792. // happen in case if user doesn't have or denied permission to
  793. // both camera and microphone.
  794. this.statistics.startCallStats(jingleSession, this.settings);
  795. this.statistics.startRemoteStats(jingleSession.peerconnection);
  796. };
  797. /**
  798. * Handles the call ended event.
  799. * @param {JingleSessionPC} JingleSession the jingle session which has been
  800. * terminated.
  801. * @param {String} reasonCondition the Jingle reason condition.
  802. * @param {String|null} reasonText human readable reason text which may provide
  803. * more details about why the call has been terminated.
  804. */
  805. JitsiConference.prototype.onCallEnded
  806. = function (JingleSession, reasonCondition, reasonText) {
  807. logger.info("Call ended: " + reasonCondition + " - " + reasonText);
  808. this.wasStopped = true;
  809. // Send session.terminate event
  810. Statistics.sendEventToAll("session.terminate");
  811. // Stop the stats
  812. if (this.statistics) {
  813. this.statistics.stopRemoteStats();
  814. this.statistics.stopCallStats();
  815. }
  816. // Current JingleSession is invalid so set it to null on the room
  817. this.room.setJingleSession(null);
  818. // Let the RTC service do any cleanups
  819. this.rtc.onCallEnded();
  820. // PeerConnection has been closed which means that SSRCs stored in
  821. // JitsiLocalTrack will not match those assigned by the old PeerConnection
  822. // and SSRC replacement logic will not work as expected.
  823. // We want to re-register 'ssrcHandler' of our local tracks, so that they
  824. // will learn what their SSRC from the new PeerConnection which will be
  825. // created on incoming call event.
  826. var self = this;
  827. this.rtc.localTracks.forEach(function(localTrack) {
  828. // Reset SSRC as it will no longer be valid
  829. localTrack._setSSRC(null);
  830. // Bind the handler to fetch new SSRC, it will un register itself once
  831. // it reads the values
  832. self.room.addListener(
  833. XMPPEvents.SENDRECV_STREAMS_CHANGED, localTrack.ssrcHandler);
  834. });
  835. };
  836. JitsiConference.prototype.updateDTMFSupport = function () {
  837. var somebodySupportsDTMF = false;
  838. var participants = this.getParticipants();
  839. // check if at least 1 participant supports DTMF
  840. for (var i = 0; i < participants.length; i += 1) {
  841. if (participants[i].supportsDTMF()) {
  842. somebodySupportsDTMF = true;
  843. break;
  844. }
  845. }
  846. if (somebodySupportsDTMF !== this.somebodySupportsDTMF) {
  847. this.somebodySupportsDTMF = somebodySupportsDTMF;
  848. this.eventEmitter.emit(JitsiConferenceEvents.DTMF_SUPPORT_CHANGED, somebodySupportsDTMF);
  849. }
  850. };
  851. /**
  852. * Allows to check if there is at least one user in the conference
  853. * that supports DTMF.
  854. * @returns {boolean} true if somebody supports DTMF, false otherwise
  855. */
  856. JitsiConference.prototype.isDTMFSupported = function () {
  857. return this.somebodySupportsDTMF;
  858. };
  859. /**
  860. * Returns the local user's ID
  861. * @return {string} local user's ID
  862. */
  863. JitsiConference.prototype.myUserId = function () {
  864. return (this.room && this.room.myroomjid)? Strophe.getResourceFromJid(this.room.myroomjid) : null;
  865. };
  866. JitsiConference.prototype.sendTones = function (tones, duration, pause) {
  867. if (!this.dtmfManager) {
  868. var connection = this.xmpp.connection.jingle.activecall.peerconnection;
  869. if (!connection) {
  870. logger.warn("cannot sendTones: no conneciton");
  871. return;
  872. }
  873. var tracks = this.getLocalTracks().filter(function (track) {
  874. return track.isAudioTrack();
  875. });
  876. if (!tracks.length) {
  877. logger.warn("cannot sendTones: no local audio stream");
  878. return;
  879. }
  880. this.dtmfManager = new JitsiDTMFManager(tracks[0], connection);
  881. }
  882. this.dtmfManager.sendTones(tones, duration, pause);
  883. };
  884. /**
  885. * Returns true if the recording is supproted and false if not.
  886. */
  887. JitsiConference.prototype.isRecordingSupported = function () {
  888. if(this.room)
  889. return this.room.isRecordingSupported();
  890. return false;
  891. };
  892. /**
  893. * Returns null if the recording is not supported, "on" if the recording started
  894. * and "off" if the recording is not started.
  895. */
  896. JitsiConference.prototype.getRecordingState = function () {
  897. return (this.room) ? this.room.getRecordingState() : undefined;
  898. }
  899. /**
  900. * Returns the url of the recorded video.
  901. */
  902. JitsiConference.prototype.getRecordingURL = function () {
  903. return (this.room) ? this.room.getRecordingURL() : null;
  904. }
  905. /**
  906. * Starts/stops the recording
  907. */
  908. JitsiConference.prototype.toggleRecording = function (options) {
  909. if(this.room)
  910. return this.room.toggleRecording(options, function (status, error) {
  911. this.eventEmitter.emit(
  912. JitsiConferenceEvents.RECORDER_STATE_CHANGED, status, error);
  913. }.bind(this));
  914. this.eventEmitter.emit(
  915. JitsiConferenceEvents.RECORDER_STATE_CHANGED, "error",
  916. new Error("The conference is not created yet!"));
  917. }
  918. /**
  919. * Returns true if the SIP calls are supported and false otherwise
  920. */
  921. JitsiConference.prototype.isSIPCallingSupported = function () {
  922. if(this.room)
  923. return this.room.isSIPCallingSupported();
  924. return false;
  925. }
  926. /**
  927. * Dials a number.
  928. * @param number the number
  929. */
  930. JitsiConference.prototype.dial = function (number) {
  931. if(this.room)
  932. return this.room.dial(number);
  933. return new Promise(function(resolve, reject){
  934. reject(new Error("The conference is not created yet!"))});
  935. }
  936. /**
  937. * Hangup an existing call
  938. */
  939. JitsiConference.prototype.hangup = function () {
  940. if(this.room)
  941. return this.room.hangup();
  942. return new Promise(function(resolve, reject){
  943. reject(new Error("The conference is not created yet!"))});
  944. }
  945. /**
  946. * Returns the phone number for joining the conference.
  947. */
  948. JitsiConference.prototype.getPhoneNumber = function () {
  949. if(this.room)
  950. return this.room.getPhoneNumber();
  951. return null;
  952. }
  953. /**
  954. * Returns the pin for joining the conference with phone.
  955. */
  956. JitsiConference.prototype.getPhonePin = function () {
  957. if(this.room)
  958. return this.room.getPhonePin();
  959. return null;
  960. }
  961. /**
  962. * Returns the connection state for the current room. Its ice connection state
  963. * for its session.
  964. */
  965. JitsiConference.prototype.getConnectionState = function () {
  966. if(this.room)
  967. return this.room.getConnectionState();
  968. return null;
  969. }
  970. /**
  971. * Make all new participants mute their audio/video on join.
  972. * @param policy {Object} object with 2 boolean properties for video and audio:
  973. * @param {boolean} audio if audio should be muted.
  974. * @param {boolean} video if video should be muted.
  975. */
  976. JitsiConference.prototype.setStartMutedPolicy = function (policy) {
  977. if (!this.isModerator()) {
  978. return;
  979. }
  980. this.startMutedPolicy = policy;
  981. this.room.removeFromPresence("startmuted");
  982. this.room.addToPresence("startmuted", {
  983. attributes: {
  984. audio: policy.audio,
  985. video: policy.video,
  986. xmlns: 'http://jitsi.org/jitmeet/start-muted'
  987. }
  988. });
  989. this.room.sendPresence();
  990. };
  991. /**
  992. * Returns current start muted policy
  993. * @returns {Object} with 2 proprties - audio and video.
  994. */
  995. JitsiConference.prototype.getStartMutedPolicy = function () {
  996. return this.startMutedPolicy;
  997. };
  998. /**
  999. * Check if audio is muted on join.
  1000. */
  1001. JitsiConference.prototype.isStartAudioMuted = function () {
  1002. return this.startAudioMuted;
  1003. };
  1004. /**
  1005. * Check if video is muted on join.
  1006. */
  1007. JitsiConference.prototype.isStartVideoMuted = function () {
  1008. return this.startVideoMuted;
  1009. };
  1010. /**
  1011. * Get object with internal logs.
  1012. */
  1013. JitsiConference.prototype.getLogs = function () {
  1014. var data = this.xmpp.getJingleLog();
  1015. var metadata = {};
  1016. metadata.time = new Date();
  1017. metadata.url = window.location.href;
  1018. metadata.ua = navigator.userAgent;
  1019. var log = this.xmpp.getXmppLog();
  1020. if (log) {
  1021. metadata.xmpp = log;
  1022. }
  1023. data.metadata = metadata;
  1024. return data;
  1025. };
  1026. /**
  1027. * Returns measured connectionTimes.
  1028. */
  1029. JitsiConference.prototype.getConnectionTimes = function () {
  1030. return this.room.connectionTimes;
  1031. };
  1032. /**
  1033. * Sets a property for the local participant.
  1034. */
  1035. JitsiConference.prototype.setLocalParticipantProperty = function(name, value) {
  1036. this.sendCommand("jitsi_participant_" + name, {value: value});
  1037. };
  1038. /**
  1039. * Sends the given feedback through CallStats if enabled.
  1040. *
  1041. * @param overallFeedback an integer between 1 and 5 indicating the
  1042. * user feedback
  1043. * @param detailedFeedback detailed feedback from the user. Not yet used
  1044. */
  1045. JitsiConference.prototype.sendFeedback =
  1046. function(overallFeedback, detailedFeedback){
  1047. this.statistics.sendFeedback(overallFeedback, detailedFeedback);
  1048. }
  1049. /**
  1050. * Returns true if the callstats integration is enabled, otherwise returns
  1051. * false.
  1052. *
  1053. * @returns true if the callstats integration is enabled, otherwise returns
  1054. * false.
  1055. */
  1056. JitsiConference.prototype.isCallstatsEnabled = function () {
  1057. return this.statistics.isCallstatsEnabled();
  1058. }
  1059. /**
  1060. * Handles track attached to container (Calls associateStreamWithVideoTag method
  1061. * from statistics module)
  1062. * @param track the track
  1063. * @param container the container
  1064. */
  1065. JitsiConference.prototype._onTrackAttach = function(track, container) {
  1066. var ssrc = track.getSSRC();
  1067. if (!container.id || !ssrc) {
  1068. return;
  1069. }
  1070. this.statistics.associateStreamWithVideoTag(
  1071. ssrc, track.isLocal(), track.getUsageLabel(), container.id);
  1072. }
  1073. /**
  1074. * Reports detected audio problem with the media stream related to the passed
  1075. * ssrc.
  1076. * @param ssrc {string} the ssrc
  1077. * NOTE: all logger.log calls are there only to be able to see the info in
  1078. * torture
  1079. */
  1080. JitsiConference.prototype._reportAudioProblem = function (ssrc) {
  1081. if(this.reportedAudioSSRCs[ssrc])
  1082. return;
  1083. var track = this.rtc.getRemoteTrackBySSRC(ssrc);
  1084. if(!track || !track.isAudioTrack())
  1085. return;
  1086. var id = track.getParticipantId();
  1087. var displayName = null;
  1088. if(id) {
  1089. var participant = this.getParticipantById(id);
  1090. if(participant) {
  1091. displayName = participant.getDisplayName();
  1092. }
  1093. }
  1094. this.reportedAudioSSRCs[ssrc] = true;
  1095. var errorContent = {
  1096. errMsg: "The audio is received but not played",
  1097. ssrc: ssrc,
  1098. jid: id,
  1099. displayName: displayName
  1100. };
  1101. logger.log("=================The audio is received but not played" +
  1102. "======================");
  1103. logger.log("ssrc: ", ssrc);
  1104. logger.log("jid: ", id);
  1105. logger.log("displayName: ", displayName);
  1106. var mstream = track.stream, mtrack = track.track;
  1107. if(mstream) {
  1108. logger.log("MediaStream:");
  1109. errorContent.MediaStream = {
  1110. active: mstream.active,
  1111. id: mstream.id
  1112. };
  1113. logger.log("active: ", mstream.active);
  1114. logger.log("id: ", mstream.id);
  1115. }
  1116. if(mtrack) {
  1117. logger.log("MediaStreamTrack:");
  1118. errorContent.MediaStreamTrack = {
  1119. enabled: mtrack.enabled,
  1120. id: mtrack.id,
  1121. label: mtrack.label,
  1122. muted: mtrack.muted
  1123. }
  1124. logger.log("enabled: ", mtrack.enabled);
  1125. logger.log("id: ", mtrack.id);
  1126. logger.log("label: ", mtrack.label);
  1127. logger.log("muted: ", mtrack.muted);
  1128. }
  1129. if(track.containers) {
  1130. errorContent.containers = [];
  1131. logger.log("Containers:");
  1132. track.containers.forEach(function (container) {
  1133. logger.log("Container:");
  1134. errorContent.containers.push({
  1135. autoplay: container.autoplay,
  1136. muted: container.muted,
  1137. src: container.src,
  1138. volume: container.volume,
  1139. id: container.id,
  1140. ended: container.ended,
  1141. paused: container.paused,
  1142. readyState: container.readyState
  1143. });
  1144. logger.log("autoplay: ", container.autoplay);
  1145. logger.log("muted: ", container.muted);
  1146. logger.log("src: ", container.src);
  1147. logger.log("volume: ", container.volume);
  1148. logger.log("id: ", container.id);
  1149. logger.log("ended: ", container.ended);
  1150. logger.log("paused: ", container.paused);
  1151. logger.log("readyState: ", container.readyState);
  1152. });
  1153. }
  1154. // Prints JSON.stringify(errorContent) to be able to see all properties of
  1155. // errorContent from torture
  1156. logger.error("Audio problem detected. The audio is received but not played",
  1157. errorContent);
  1158. delete errorContent.displayName;
  1159. this.statistics.sendDetectedAudioProblem(
  1160. new Error(JSON.stringify(errorContent)));
  1161. };
  1162. /**
  1163. * Logs an "application log" message.
  1164. * @param message {string} The message to log. Note that while this can be a
  1165. * generic string, the convention used by lib-jitsi-meet and jitsi-meet is to
  1166. * log valid JSON strings, with an "id" field used for distinguishing between
  1167. * message types. E.g.: {id: "recorder_status", status: "off"}
  1168. */
  1169. JitsiConference.prototype.sendApplicationLog = function(message) {
  1170. Statistics.sendLog(message);
  1171. };
  1172. /**
  1173. * Checks if the user identified by given <tt>mucJid</tt> is the conference
  1174. * focus.
  1175. * @param mucJid the full MUC address of the user to be checked.
  1176. * @returns {boolean} <tt>true</tt> if MUC user is the conference focus.
  1177. */
  1178. JitsiConference.prototype._isFocus = function (mucJid) {
  1179. return this.room.isFocus(mucJid);
  1180. };
  1181. /**
  1182. * Fires CONFERENCE_FAILED event with INCOMPATIBLE_SERVER_VERSIONS parameter
  1183. */
  1184. JitsiConference.prototype._fireIncompatibleVersionsEvent = function () {
  1185. this.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_FAILED,
  1186. JitsiConferenceErrors.INCOMPATIBLE_SERVER_VERSIONS);
  1187. };
  1188. /**
  1189. * Sends message via the datachannels.
  1190. * @param to {string} the id of the endpoint that should receive the message.
  1191. * If "" the message will be sent to all participants.
  1192. * @param payload {object} the payload of the message.
  1193. * @throws NetworkError or InvalidStateError or Error if the operation fails.
  1194. */
  1195. JitsiConference.prototype.sendEndpointMessage = function (to, payload) {
  1196. this.rtc.sendDataChannelMessage(to, payload);
  1197. }
  1198. /**
  1199. * Sends broadcast message via the datachannels.
  1200. * @param payload {object} the payload of the message.
  1201. * @throws NetworkError or InvalidStateError or Error if the operation fails.
  1202. */
  1203. JitsiConference.prototype.broadcastEndpointMessage = function (payload) {
  1204. this.sendEndpointMessage("", payload);
  1205. }
  1206. module.exports = JitsiConference;