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.

ChatRoom.js 21KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642
  1. /* global Strophe, $, $pres, $iq, $msg */
  2. /* jshint -W101,-W069 */
  3. var logger = require("jitsi-meet-logger").getLogger(__filename);
  4. var XMPPEvents = require("../../service/xmpp/XMPPEvents");
  5. var Moderator = require("./moderator");
  6. var EventEmitter = require("events");
  7. var parser = {
  8. packet2JSON: function (packet, nodes) {
  9. var self = this;
  10. $(packet).children().each(function (index) {
  11. var tagName = $(this).prop("tagName");
  12. var node = {
  13. tagName: tagName
  14. };
  15. node.attributes = {};
  16. $($(this)[0].attributes).each(function( index, attr ) {
  17. node.attributes[ attr.name ] = attr.value;
  18. });
  19. var text = Strophe.getText($(this)[0]);
  20. if (text) {
  21. node.value = text;
  22. }
  23. node.children = [];
  24. nodes.push(node);
  25. self.packet2JSON($(this), node.children);
  26. });
  27. },
  28. JSON2packet: function (nodes, packet) {
  29. for(var i = 0; i < nodes.length; i++) {
  30. var node = nodes[i];
  31. if(!node || node === null){
  32. continue;
  33. }
  34. packet.c(node.tagName, node.attributes);
  35. if(node.value)
  36. packet.t(node.value);
  37. if(node.children)
  38. this.JSON2packet(node.children, packet);
  39. packet.up();
  40. }
  41. // packet.up();
  42. }
  43. };
  44. /**
  45. * Returns array of JS objects from the presence JSON associated with the passed nodeName
  46. * @param pres the presence JSON
  47. * @param nodeName the name of the node (videomuted, audiomuted, etc)
  48. */
  49. function filterNodeFromPresenceJSON(pres, nodeName){
  50. var res = [];
  51. for(var i = 0; i < pres.length; i++)
  52. if(pres[i].tagName === nodeName)
  53. res.push(pres[i]);
  54. return res;
  55. }
  56. function ChatRoom(connection, jid, password, XMPP, options) {
  57. this.eventEmitter = new EventEmitter();
  58. this.xmpp = XMPP;
  59. this.connection = connection;
  60. this.roomjid = Strophe.getBareJidFromJid(jid);
  61. this.myroomjid = jid;
  62. this.password = password;
  63. logger.info("Joined MUC as " + this.myroomjid);
  64. this.members = {};
  65. this.presMap = {};
  66. this.presHandlers = {};
  67. this.joined = false;
  68. this.role = 'none';
  69. this.focusMucJid = null;
  70. this.bridgeIsDown = false;
  71. this.options = options || {};
  72. this.moderator = new Moderator(this.roomjid, this.xmpp, this.eventEmitter);
  73. this.initPresenceMap();
  74. this.session = null;
  75. var self = this;
  76. this.lastPresences = {};
  77. }
  78. ChatRoom.prototype.initPresenceMap = function () {
  79. this.presMap['to'] = this.myroomjid;
  80. this.presMap['xns'] = 'http://jabber.org/protocol/muc';
  81. this.presMap["nodes"] = [];
  82. this.presMap["nodes"].push( {
  83. "tagName": "user-agent",
  84. "value": navigator.userAgent,
  85. "attributes": {xmlns: 'http://jitsi.org/jitmeet/user-agent'}
  86. });
  87. };
  88. ChatRoom.prototype.updateDeviceAvailability = function (devices) {
  89. this.presMap["nodes"].push( {
  90. "tagName": "devices",
  91. "children": [
  92. {
  93. "tagName": "audio",
  94. "value": devices.audio,
  95. },
  96. {
  97. "tagName": "video",
  98. "value": devices.video,
  99. }
  100. ]
  101. });
  102. };
  103. ChatRoom.prototype.join = function (password, tokenPassword) {
  104. if(password)
  105. this.password = password;
  106. var self = this;
  107. this.moderator.allocateConferenceFocus(function()
  108. {
  109. self.sendPresence(tokenPassword);
  110. }.bind(this));
  111. };
  112. ChatRoom.prototype.sendPresence = function (tokenPassword) {
  113. if (!this.presMap['to']) {
  114. // Too early to send presence - not initialized
  115. return;
  116. }
  117. var pres = $pres({to: this.presMap['to'] });
  118. pres.c('x', {xmlns: this.presMap['xns']});
  119. if (this.password) {
  120. pres.c('password').t(this.password).up();
  121. }
  122. pres.up();
  123. // Send XEP-0115 'c' stanza that contains our capabilities info
  124. if (this.connection.caps) {
  125. this.connection.caps.node = this.xmpp.options.clientNode;
  126. pres.c('c', this.connection.caps.generateCapsAttrs()).up();
  127. }
  128. if (tokenPassword) {
  129. pres.c('token', { xmlns: 'http://jitsi.org/jitmeet/auth-token'})
  130. .t(tokenPassword).up();
  131. }
  132. parser.JSON2packet(this.presMap.nodes, pres);
  133. this.connection.send(pres);
  134. };
  135. ChatRoom.prototype.doLeave = function () {
  136. logger.log("do leave", this.myroomjid);
  137. var pres = $pres({to: this.myroomjid, type: 'unavailable' });
  138. this.presMap.length = 0;
  139. this.connection.send(pres);
  140. };
  141. ChatRoom.prototype.createNonAnonymousRoom = function () {
  142. // http://xmpp.org/extensions/xep-0045.html#createroom-reserved
  143. var getForm = $iq({type: 'get', to: this.roomjid})
  144. .c('query', {xmlns: 'http://jabber.org/protocol/muc#owner'})
  145. .c('x', {xmlns: 'jabber:x:data', type: 'submit'});
  146. var self = this;
  147. this.connection.sendIQ(getForm, function (form) {
  148. if (!$(form).find(
  149. '>query>x[xmlns="jabber:x:data"]' +
  150. '>field[var="muc#roomconfig_whois"]').length) {
  151. logger.error('non-anonymous rooms not supported');
  152. return;
  153. }
  154. var formSubmit = $iq({to: this.roomjid, type: 'set'})
  155. .c('query', {xmlns: 'http://jabber.org/protocol/muc#owner'});
  156. formSubmit.c('x', {xmlns: 'jabber:x:data', type: 'submit'});
  157. formSubmit.c('field', {'var': 'FORM_TYPE'})
  158. .c('value')
  159. .t('http://jabber.org/protocol/muc#roomconfig').up().up();
  160. formSubmit.c('field', {'var': 'muc#roomconfig_whois'})
  161. .c('value').t('anyone').up().up();
  162. self.connection.sendIQ(formSubmit);
  163. }, function (error) {
  164. logger.error("Error getting room configuration form");
  165. });
  166. };
  167. ChatRoom.prototype.onPresence = function (pres) {
  168. var from = pres.getAttribute('from');
  169. // Parse roles.
  170. var member = {};
  171. member.show = $(pres).find('>show').text();
  172. member.status = $(pres).find('>status').text();
  173. var tmp = $(pres).find('>x[xmlns="http://jabber.org/protocol/muc#user"]>item');
  174. member.affiliation = tmp.attr('affiliation');
  175. member.role = tmp.attr('role');
  176. // Focus recognition
  177. member.jid = tmp.attr('jid');
  178. member.isFocus = false;
  179. if (member.jid
  180. && member.jid.indexOf(this.moderator.getFocusUserJid() + "/") === 0) {
  181. member.isFocus = true;
  182. }
  183. $(pres).find(">x").remove();
  184. var nodes = [];
  185. parser.packet2JSON(pres, nodes);
  186. this.lastPresences[from] = nodes;
  187. for(var i = 0; i < nodes.length; i++)
  188. {
  189. var node = nodes[i];
  190. switch(node.tagName)
  191. {
  192. case "nick":
  193. member.nick = node.value;
  194. if(!member.isFocus) {
  195. var displayName = !this.xmpp.options.displayJids
  196. ? member.nick : Strophe.getResourceFromJid(from);
  197. if (displayName && displayName.length > 0) {
  198. this.eventEmitter.emit(XMPPEvents.DISPLAY_NAME_CHANGED, from, displayName);
  199. }
  200. logger.info("Display name: " + displayName, pres);
  201. }
  202. break;
  203. case "userId":
  204. member.id = node.value;
  205. break;
  206. case "email":
  207. member.email = node.value;
  208. break;
  209. case "bridgeIsDown":
  210. if(!this.bridgeIsDown) {
  211. this.bridgeIsDown = true;
  212. this.eventEmitter.emit(XMPPEvents.BRIDGE_DOWN);
  213. }
  214. break;
  215. default :
  216. this.processNode(node, from);
  217. }
  218. }
  219. if (from == this.myroomjid) {
  220. if (member.affiliation == 'owner')
  221. if (this.role !== member.role) {
  222. this.role = member.role;
  223. this.eventEmitter.emit(XMPPEvents.LOCAL_ROLE_CHANGED, this.role);
  224. }
  225. if (!this.joined) {
  226. this.joined = true;
  227. console.log("(TIME) MUC joined:\t", window.performance.now());
  228. this.eventEmitter.emit(XMPPEvents.MUC_JOINED, from, member);
  229. }
  230. } else if (this.members[from] === undefined) {
  231. // new participant
  232. this.members[from] = member;
  233. logger.log('entered', from, member);
  234. if (member.isFocus) {
  235. this.focusMucJid = from;
  236. logger.info("Ignore focus: " + from + ", real JID: " + member.jid);
  237. }
  238. else {
  239. this.eventEmitter.emit(XMPPEvents.MUC_MEMBER_JOINED, from, member.id || member.email, member.nick);
  240. }
  241. } else {
  242. // Presence update for existing participant
  243. // Watch role change:
  244. if (this.members[from].role != member.role) {
  245. this.members[from].role = member.role;
  246. this.eventEmitter.emit(XMPPEvents.MUC_ROLE_CHANGED, from, member.role);
  247. }
  248. // store the new display name
  249. if(member.displayName)
  250. this.members[from].displayName = member.displayName;
  251. }
  252. if(!member.isFocus)
  253. this.eventEmitter.emit(XMPPEvents.USER_ID_CHANGED, from, member.id || member.email);
  254. // Trigger status message update
  255. if (member.status) {
  256. this.eventEmitter.emit(XMPPEvents.PRESENCE_STATUS, from, member);
  257. }
  258. };
  259. ChatRoom.prototype.processNode = function (node, from) {
  260. if(this.presHandlers[node.tagName])
  261. this.presHandlers[node.tagName](node, from);
  262. };
  263. ChatRoom.prototype.sendMessage = function (body, nickname) {
  264. var msg = $msg({to: this.roomjid, type: 'groupchat'});
  265. msg.c('body', body).up();
  266. if (nickname) {
  267. msg.c('nick', {xmlns: 'http://jabber.org/protocol/nick'}).t(nickname).up().up();
  268. }
  269. this.connection.send(msg);
  270. this.eventEmitter.emit(XMPPEvents.SENDING_CHAT_MESSAGE, body);
  271. };
  272. ChatRoom.prototype.setSubject = function (subject) {
  273. var msg = $msg({to: this.roomjid, type: 'groupchat'});
  274. msg.c('subject', subject);
  275. this.connection.send(msg);
  276. logger.log("topic changed to " + subject);
  277. };
  278. ChatRoom.prototype.onParticipantLeft = function (jid) {
  279. delete this.lastPresences[jid];
  280. this.eventEmitter.emit(XMPPEvents.MUC_MEMBER_LEFT, jid);
  281. this.moderator.onMucMemberLeft(jid);
  282. };
  283. ChatRoom.prototype.onPresenceUnavailable = function (pres, from) {
  284. // room destroyed ?
  285. if ($(pres).find('>x[xmlns="http://jabber.org/protocol/muc#user"]' +
  286. '>destroy').length) {
  287. var reason;
  288. var reasonSelect = $(pres).find(
  289. '>x[xmlns="http://jabber.org/protocol/muc#user"]' +
  290. '>destroy>reason');
  291. if (reasonSelect.length) {
  292. reason = reasonSelect.text();
  293. }
  294. this.xmpp.disposeConference(false);
  295. this.eventEmitter.emit(XMPPEvents.MUC_DESTROYED, reason);
  296. delete this.connection.emuc.rooms[Strophe.getBareJidFromJid(from)];
  297. return true;
  298. }
  299. // Status code 110 indicates that this notification is "self-presence".
  300. if (!$(pres).find('>x[xmlns="http://jabber.org/protocol/muc#user"]>status[code="110"]').length) {
  301. delete this.members[from];
  302. this.onParticipantLeft(from);
  303. }
  304. // If the status code is 110 this means we're leaving and we would like
  305. // to remove everyone else from our view, so we trigger the event.
  306. else if (Object.keys(this.members).length > 1) {
  307. for (var i in this.members) {
  308. var member = this.members[i];
  309. delete this.members[i];
  310. this.onParticipantLeft(member);
  311. }
  312. }
  313. if ($(pres).find('>x[xmlns="http://jabber.org/protocol/muc#user"]>status[code="307"]').length) {
  314. if (this.myroomjid === from) {
  315. this.xmpp.disposeConference(false);
  316. this.eventEmitter.emit(XMPPEvents.KICKED);
  317. }
  318. }
  319. };
  320. ChatRoom.prototype.onMessage = function (msg, from) {
  321. var nick =
  322. $(msg).find('>nick[xmlns="http://jabber.org/protocol/nick"]')
  323. .text() ||
  324. Strophe.getResourceFromJid(from);
  325. var txt = $(msg).find('>body').text();
  326. var type = msg.getAttribute("type");
  327. if (type == "error") {
  328. this.eventEmitter.emit(XMPPEvents.CHAT_ERROR_RECEIVED,
  329. $(msg).find('>text').text(), txt);
  330. return true;
  331. }
  332. var subject = $(msg).find('>subject');
  333. if (subject.length) {
  334. var subjectText = subject.text();
  335. if (subjectText || subjectText === "") {
  336. this.eventEmitter.emit(XMPPEvents.SUBJECT_CHANGED, subjectText);
  337. logger.log("Subject is changed to " + subjectText);
  338. }
  339. }
  340. // xep-0203 delay
  341. var stamp = $(msg).find('>delay').attr('stamp');
  342. if (!stamp) {
  343. // or xep-0091 delay, UTC timestamp
  344. stamp = $(msg).find('>[xmlns="jabber:x:delay"]').attr('stamp');
  345. if (stamp) {
  346. // the format is CCYYMMDDThh:mm:ss
  347. var dateParts = stamp.match(/(\d{4})(\d{2})(\d{2}T\d{2}:\d{2}:\d{2})/);
  348. stamp = dateParts[1] + "-" + dateParts[2] + "-" + dateParts[3] + "Z";
  349. }
  350. }
  351. if (txt) {
  352. logger.log('chat', nick, txt);
  353. this.eventEmitter.emit(XMPPEvents.MESSAGE_RECEIVED,
  354. from, nick, txt, this.myroomjid, stamp);
  355. }
  356. };
  357. ChatRoom.prototype.onPresenceError = function (pres, from) {
  358. if ($(pres).find('>error[type="auth"]>not-authorized[xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"]').length) {
  359. logger.log('on password required', from);
  360. this.eventEmitter.emit(XMPPEvents.PASSWORD_REQUIRED);
  361. } else if ($(pres).find(
  362. '>error[type="cancel"]>not-allowed[xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"]').length) {
  363. var toDomain = Strophe.getDomainFromJid(pres.getAttribute('to'));
  364. if (toDomain === this.xmpp.options.hosts.anonymousdomain) {
  365. // enter the room by replying with 'not-authorized'. This would
  366. // result in reconnection from authorized domain.
  367. // We're either missing Jicofo/Prosody config for anonymous
  368. // domains or something is wrong.
  369. this.eventEmitter.emit(XMPPEvents.ROOM_JOIN_ERROR, pres);
  370. } else {
  371. logger.warn('onPresError ', pres);
  372. this.eventEmitter.emit(XMPPEvents.ROOM_CONNECT_ERROR, pres);
  373. }
  374. } else {
  375. logger.warn('onPresError ', pres);
  376. this.eventEmitter.emit(XMPPEvents.ROOM_CONNECT_ERROR, pres);
  377. }
  378. };
  379. ChatRoom.prototype.kick = function (jid) {
  380. var kickIQ = $iq({to: this.roomjid, type: 'set'})
  381. .c('query', {xmlns: 'http://jabber.org/protocol/muc#admin'})
  382. .c('item', {nick: Strophe.getResourceFromJid(jid), role: 'none'})
  383. .c('reason').t('You have been kicked.').up().up().up();
  384. this.connection.sendIQ(
  385. kickIQ,
  386. function (result) {
  387. logger.log('Kick participant with jid: ', jid, result);
  388. },
  389. function (error) {
  390. logger.log('Kick participant error: ', error);
  391. });
  392. };
  393. ChatRoom.prototype.lockRoom = function (key, onSuccess, onError, onNotSupported) {
  394. //http://xmpp.org/extensions/xep-0045.html#roomconfig
  395. var ob = this;
  396. this.connection.sendIQ($iq({to: this.roomjid, type: 'get'}).c('query', {xmlns: 'http://jabber.org/protocol/muc#owner'}),
  397. function (res) {
  398. if ($(res).find('>query>x[xmlns="jabber:x:data"]>field[var="muc#roomconfig_roomsecret"]').length) {
  399. var formsubmit = $iq({to: ob.roomjid, type: 'set'}).c('query', {xmlns: 'http://jabber.org/protocol/muc#owner'});
  400. formsubmit.c('x', {xmlns: 'jabber:x:data', type: 'submit'});
  401. formsubmit.c('field', {'var': 'FORM_TYPE'}).c('value').t('http://jabber.org/protocol/muc#roomconfig').up().up();
  402. formsubmit.c('field', {'var': 'muc#roomconfig_roomsecret'}).c('value').t(key).up().up();
  403. // Fixes a bug in prosody 0.9.+ https://code.google.com/p/lxmppd/issues/detail?id=373
  404. formsubmit.c('field', {'var': 'muc#roomconfig_whois'}).c('value').t('anyone').up().up();
  405. // FIXME: is muc#roomconfig_passwordprotectedroom required?
  406. ob.connection.sendIQ(formsubmit,
  407. onSuccess,
  408. onError);
  409. } else {
  410. onNotSupported();
  411. }
  412. }, onError);
  413. };
  414. ChatRoom.prototype.addToPresence = function (key, values) {
  415. values.tagName = key;
  416. this.presMap["nodes"].push(values);
  417. };
  418. ChatRoom.prototype.removeFromPresence = function (key) {
  419. for(var i = 0; i < this.presMap.nodes.length; i++)
  420. {
  421. if(key === this.presMap.nodes[i].tagName)
  422. this.presMap.nodes.splice(i, 1);
  423. }
  424. };
  425. ChatRoom.prototype.addPresenceListener = function (name, handler) {
  426. this.presHandlers[name] = handler;
  427. };
  428. ChatRoom.prototype.removePresenceListener = function (name) {
  429. delete this.presHandlers[name];
  430. };
  431. ChatRoom.prototype.isModerator = function () {
  432. return this.role === 'moderator';
  433. };
  434. ChatRoom.prototype.getMemberRole = function (peerJid) {
  435. if (this.members[peerJid]) {
  436. return this.members[peerJid].role;
  437. }
  438. return null;
  439. };
  440. ChatRoom.prototype.setJingleSession = function(session){
  441. this.session = session;
  442. this.session.room = this;
  443. };
  444. ChatRoom.prototype.removeStream = function (stream) {
  445. if(!this.session)
  446. return;
  447. this.session.peerconnection.removeStream(stream);
  448. };
  449. ChatRoom.prototype.switchStreams = function (stream, oldStream, callback, isAudio) {
  450. if(this.session) {
  451. // FIXME: will block switchInProgress on true value in case of exception
  452. this.session.switchStreams(stream, oldStream, callback, isAudio);
  453. } else {
  454. // We are done immediately
  455. logger.warn("No conference handler or conference not started yet");
  456. callback();
  457. }
  458. };
  459. ChatRoom.prototype.addStream = function (stream, callback) {
  460. if(this.session) {
  461. // FIXME: will block switchInProgress on true value in case of exception
  462. this.session.addStream(stream, callback);
  463. } else {
  464. // We are done immediately
  465. logger.warn("No conference handler or conference not started yet");
  466. callback();
  467. }
  468. };
  469. ChatRoom.prototype.setVideoMute = function (mute, callback, options) {
  470. var self = this;
  471. var localCallback = function (mute) {
  472. self.sendVideoInfoPresence(mute);
  473. if(callback)
  474. callback(mute);
  475. };
  476. if(this.session)
  477. {
  478. this.session.setVideoMute(
  479. mute, localCallback, options);
  480. }
  481. else {
  482. localCallback(mute);
  483. }
  484. };
  485. ChatRoom.prototype.setAudioMute = function (mute, callback) {
  486. //This will be for remote streams only
  487. // if (this.forceMuted && !mute) {
  488. // logger.info("Asking focus for unmute");
  489. // this.connection.moderate.setMute(this.connection.emuc.myroomjid, mute);
  490. // // FIXME: wait for result before resetting muted status
  491. // this.forceMuted = false;
  492. // }
  493. return this.sendAudioInfoPresence(mute, callback);
  494. };
  495. ChatRoom.prototype.addAudioInfoToPresence = function (mute) {
  496. this.removeFromPresence("audiomuted");
  497. this.addToPresence("audiomuted",
  498. {attributes:
  499. {"audions": "http://jitsi.org/jitmeet/audio"},
  500. value: mute.toString()});
  501. };
  502. ChatRoom.prototype.sendAudioInfoPresence = function(mute, callback) {
  503. this.addAudioInfoToPresence(mute);
  504. if(this.connection) {
  505. this.sendPresence();
  506. }
  507. if(callback)
  508. callback();
  509. };
  510. ChatRoom.prototype.addVideoInfoToPresence = function (mute) {
  511. this.removeFromPresence("videomuted");
  512. this.addToPresence("videomuted",
  513. {attributes:
  514. {"videons": "http://jitsi.org/jitmeet/video"},
  515. value: mute.toString()});
  516. };
  517. ChatRoom.prototype.sendVideoInfoPresence = function (mute) {
  518. this.addVideoInfoToPresence(mute);
  519. if(!this.connection)
  520. return;
  521. this.sendPresence();
  522. };
  523. ChatRoom.prototype.addListener = function(type, listener) {
  524. this.eventEmitter.on(type, listener);
  525. };
  526. ChatRoom.prototype.removeListener = function (type, listener) {
  527. this.eventEmitter.removeListener(type, listener);
  528. };
  529. ChatRoom.prototype.remoteStreamAdded = function(data, sid, thessrc) {
  530. if(this.lastPresences[data.peerjid])
  531. {
  532. var pres = this.lastPresences[data.peerjid];
  533. var audiomuted = filterNodeFromPresenceJSON(pres, "audiomuted");
  534. var videomuted = filterNodeFromPresenceJSON(pres, "videomuted");
  535. data.videomuted = ((videomuted.length > 0
  536. && videomuted[0]
  537. && videomuted[0]["value"] === "true")? true : false);
  538. data.audiomuted = ((audiomuted.length > 0
  539. && audiomuted[0]
  540. && audiomuted[0]["value"] === "true")? true : false);
  541. }
  542. this.eventEmitter.emit(XMPPEvents.REMOTE_STREAM_RECEIVED, data, sid, thessrc);
  543. };
  544. ChatRoom.prototype.getJidBySSRC = function (ssrc) {
  545. if (!this.session)
  546. return null;
  547. return this.session.getSsrcOwner(ssrc);
  548. };
  549. module.exports = ChatRoom;