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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644
  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 = null;
  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,
  224. member, this.isModerator());
  225. }
  226. if (!this.joined) {
  227. this.joined = true;
  228. console.log("(TIME) MUC joined:\t", window.performance.now());
  229. this.eventEmitter.emit(XMPPEvents.MUC_JOINED, from, member);
  230. }
  231. } else if (this.members[from] === undefined) {
  232. // new participant
  233. this.members[from] = member;
  234. logger.log('entered', from, member);
  235. if (member.isFocus) {
  236. this.focusMucJid = from;
  237. logger.info("Ignore focus: " + from + ", real JID: " + member.jid);
  238. }
  239. else {
  240. this.eventEmitter.emit(XMPPEvents.MUC_MEMBER_JOINED, from, member.id || member.email, member.nick);
  241. }
  242. } else {
  243. // Presence update for existing participant
  244. // Watch role change:
  245. if (this.members[from].role != member.role) {
  246. this.members[from].role = member.role;
  247. this.eventEmitter.emit(XMPPEvents.MUC_ROLE_CHANGED,
  248. member.role, member.nick);
  249. }
  250. // store the new display name
  251. if(member.displayName)
  252. this.members[from].displayName = member.displayName;
  253. }
  254. if(!member.isFocus)
  255. this.eventEmitter.emit(XMPPEvents.USER_ID_CHANGED, from, member.id || member.email);
  256. // Trigger status message update
  257. if (member.status) {
  258. this.eventEmitter.emit(XMPPEvents.PRESENCE_STATUS, from, member);
  259. }
  260. };
  261. ChatRoom.prototype.processNode = function (node, from) {
  262. if(this.presHandlers[node.tagName])
  263. this.presHandlers[node.tagName](node, from);
  264. };
  265. ChatRoom.prototype.sendMessage = function (body, nickname) {
  266. var msg = $msg({to: this.roomjid, type: 'groupchat'});
  267. msg.c('body', body).up();
  268. if (nickname) {
  269. msg.c('nick', {xmlns: 'http://jabber.org/protocol/nick'}).t(nickname).up().up();
  270. }
  271. this.connection.send(msg);
  272. this.eventEmitter.emit(XMPPEvents.SENDING_CHAT_MESSAGE, body);
  273. };
  274. ChatRoom.prototype.setSubject = function (subject) {
  275. var msg = $msg({to: this.roomjid, type: 'groupchat'});
  276. msg.c('subject', subject);
  277. this.connection.send(msg);
  278. logger.log("topic changed to " + subject);
  279. };
  280. ChatRoom.prototype.onParticipantLeft = function (jid) {
  281. delete this.lastPresences[jid];
  282. this.eventEmitter.emit(XMPPEvents.MUC_MEMBER_LEFT, jid);
  283. this.moderator.onMucMemberLeft(jid);
  284. };
  285. ChatRoom.prototype.onPresenceUnavailable = function (pres, from) {
  286. // room destroyed ?
  287. if ($(pres).find('>x[xmlns="http://jabber.org/protocol/muc#user"]' +
  288. '>destroy').length) {
  289. var reason;
  290. var reasonSelect = $(pres).find(
  291. '>x[xmlns="http://jabber.org/protocol/muc#user"]' +
  292. '>destroy>reason');
  293. if (reasonSelect.length) {
  294. reason = reasonSelect.text();
  295. }
  296. this.xmpp.disposeConference(false);
  297. this.eventEmitter.emit(XMPPEvents.MUC_DESTROYED, reason);
  298. delete this.connection.emuc.rooms[Strophe.getBareJidFromJid(from)];
  299. return true;
  300. }
  301. // Status code 110 indicates that this notification is "self-presence".
  302. if (!$(pres).find('>x[xmlns="http://jabber.org/protocol/muc#user"]>status[code="110"]').length) {
  303. delete this.members[from];
  304. this.onParticipantLeft(from);
  305. }
  306. // If the status code is 110 this means we're leaving and we would like
  307. // to remove everyone else from our view, so we trigger the event.
  308. else if (Object.keys(this.members).length > 1) {
  309. for (var i in this.members) {
  310. var member = this.members[i];
  311. delete this.members[i];
  312. this.onParticipantLeft(member);
  313. }
  314. }
  315. if ($(pres).find('>x[xmlns="http://jabber.org/protocol/muc#user"]>status[code="307"]').length) {
  316. if (this.myroomjid === from) {
  317. this.xmpp.disposeConference(false);
  318. this.eventEmitter.emit(XMPPEvents.KICKED);
  319. }
  320. }
  321. };
  322. ChatRoom.prototype.onMessage = function (msg, from) {
  323. var nick =
  324. $(msg).find('>nick[xmlns="http://jabber.org/protocol/nick"]')
  325. .text() ||
  326. Strophe.getResourceFromJid(from);
  327. var txt = $(msg).find('>body').text();
  328. var type = msg.getAttribute("type");
  329. if (type == "error") {
  330. this.eventEmitter.emit(XMPPEvents.CHAT_ERROR_RECEIVED,
  331. $(msg).find('>text').text(), txt);
  332. return true;
  333. }
  334. var subject = $(msg).find('>subject');
  335. if (subject.length) {
  336. var subjectText = subject.text();
  337. if (subjectText || subjectText === "") {
  338. this.eventEmitter.emit(XMPPEvents.SUBJECT_CHANGED, subjectText);
  339. logger.log("Subject is changed to " + subjectText);
  340. }
  341. }
  342. // xep-0203 delay
  343. var stamp = $(msg).find('>delay').attr('stamp');
  344. if (!stamp) {
  345. // or xep-0091 delay, UTC timestamp
  346. stamp = $(msg).find('>[xmlns="jabber:x:delay"]').attr('stamp');
  347. if (stamp) {
  348. // the format is CCYYMMDDThh:mm:ss
  349. var dateParts = stamp.match(/(\d{4})(\d{2})(\d{2}T\d{2}:\d{2}:\d{2})/);
  350. stamp = dateParts[1] + "-" + dateParts[2] + "-" + dateParts[3] + "Z";
  351. }
  352. }
  353. if (txt) {
  354. logger.log('chat', nick, txt);
  355. this.eventEmitter.emit(XMPPEvents.MESSAGE_RECEIVED,
  356. from, nick, txt, this.myroomjid, stamp);
  357. }
  358. };
  359. ChatRoom.prototype.onPresenceError = function (pres, from) {
  360. if ($(pres).find('>error[type="auth"]>not-authorized[xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"]').length) {
  361. logger.log('on password required', from);
  362. this.eventEmitter.emit(XMPPEvents.PASSWORD_REQUIRED);
  363. } else if ($(pres).find(
  364. '>error[type="cancel"]>not-allowed[xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"]').length) {
  365. var toDomain = Strophe.getDomainFromJid(pres.getAttribute('to'));
  366. if (toDomain === this.xmpp.options.hosts.anonymousdomain) {
  367. // enter the room by replying with 'not-authorized'. This would
  368. // result in reconnection from authorized domain.
  369. // We're either missing Jicofo/Prosody config for anonymous
  370. // domains or something is wrong.
  371. this.eventEmitter.emit(XMPPEvents.ROOM_JOIN_ERROR, pres);
  372. } else {
  373. logger.warn('onPresError ', pres);
  374. this.eventEmitter.emit(XMPPEvents.ROOM_CONNECT_ERROR, pres);
  375. }
  376. } else {
  377. logger.warn('onPresError ', pres);
  378. this.eventEmitter.emit(XMPPEvents.ROOM_CONNECT_ERROR, pres);
  379. }
  380. };
  381. ChatRoom.prototype.kick = function (jid) {
  382. var kickIQ = $iq({to: this.roomjid, type: 'set'})
  383. .c('query', {xmlns: 'http://jabber.org/protocol/muc#admin'})
  384. .c('item', {nick: Strophe.getResourceFromJid(jid), role: 'none'})
  385. .c('reason').t('You have been kicked.').up().up().up();
  386. this.connection.sendIQ(
  387. kickIQ,
  388. function (result) {
  389. logger.log('Kick participant with jid: ', jid, result);
  390. },
  391. function (error) {
  392. logger.log('Kick participant error: ', error);
  393. });
  394. };
  395. ChatRoom.prototype.lockRoom = function (key, onSuccess, onError, onNotSupported) {
  396. //http://xmpp.org/extensions/xep-0045.html#roomconfig
  397. var ob = this;
  398. this.connection.sendIQ($iq({to: this.roomjid, type: 'get'}).c('query', {xmlns: 'http://jabber.org/protocol/muc#owner'}),
  399. function (res) {
  400. if ($(res).find('>query>x[xmlns="jabber:x:data"]>field[var="muc#roomconfig_roomsecret"]').length) {
  401. var formsubmit = $iq({to: ob.roomjid, type: 'set'}).c('query', {xmlns: 'http://jabber.org/protocol/muc#owner'});
  402. formsubmit.c('x', {xmlns: 'jabber:x:data', type: 'submit'});
  403. formsubmit.c('field', {'var': 'FORM_TYPE'}).c('value').t('http://jabber.org/protocol/muc#roomconfig').up().up();
  404. formsubmit.c('field', {'var': 'muc#roomconfig_roomsecret'}).c('value').t(key).up().up();
  405. // Fixes a bug in prosody 0.9.+ https://code.google.com/p/lxmppd/issues/detail?id=373
  406. formsubmit.c('field', {'var': 'muc#roomconfig_whois'}).c('value').t('anyone').up().up();
  407. // FIXME: is muc#roomconfig_passwordprotectedroom required?
  408. ob.connection.sendIQ(formsubmit,
  409. onSuccess,
  410. onError);
  411. } else {
  412. onNotSupported();
  413. }
  414. }, onError);
  415. };
  416. ChatRoom.prototype.addToPresence = function (key, values) {
  417. values.tagName = key;
  418. this.presMap["nodes"].push(values);
  419. };
  420. ChatRoom.prototype.removeFromPresence = function (key) {
  421. for(var i = 0; i < this.presMap.nodes.length; i++)
  422. {
  423. if(key === this.presMap.nodes[i].tagName)
  424. this.presMap.nodes.splice(i, 1);
  425. }
  426. };
  427. ChatRoom.prototype.addPresenceListener = function (name, handler) {
  428. this.presHandlers[name] = handler;
  429. };
  430. ChatRoom.prototype.removePresenceListener = function (name) {
  431. delete this.presHandlers[name];
  432. };
  433. ChatRoom.prototype.isModerator = function (jid) {
  434. return this.role === 'moderator';
  435. };
  436. ChatRoom.prototype.getMemberRole = function (peerJid) {
  437. if (this.members[peerJid]) {
  438. return this.members[peerJid].role;
  439. }
  440. return null;
  441. };
  442. ChatRoom.prototype.setJingleSession = function(session){
  443. this.session = session;
  444. this.session.room = this;
  445. };
  446. ChatRoom.prototype.removeStream = function (stream) {
  447. if(!this.session)
  448. return;
  449. this.session.peerconnection.removeStream(stream);
  450. };
  451. ChatRoom.prototype.switchStreams = function (stream, oldStream, callback, isAudio) {
  452. if(this.session) {
  453. // FIXME: will block switchInProgress on true value in case of exception
  454. this.session.switchStreams(stream, oldStream, callback, isAudio);
  455. } else {
  456. // We are done immediately
  457. logger.warn("No conference handler or conference not started yet");
  458. callback();
  459. }
  460. };
  461. ChatRoom.prototype.addStream = function (stream, callback) {
  462. if(this.session) {
  463. // FIXME: will block switchInProgress on true value in case of exception
  464. this.session.addStream(stream, callback);
  465. } else {
  466. // We are done immediately
  467. logger.warn("No conference handler or conference not started yet");
  468. callback();
  469. }
  470. };
  471. ChatRoom.prototype.setVideoMute = function (mute, callback, options) {
  472. var self = this;
  473. var localCallback = function (mute) {
  474. self.sendVideoInfoPresence(mute);
  475. if(callback)
  476. callback(mute);
  477. };
  478. if(this.session)
  479. {
  480. this.session.setVideoMute(
  481. mute, localCallback, options);
  482. }
  483. else {
  484. localCallback(mute);
  485. }
  486. };
  487. ChatRoom.prototype.setAudioMute = function (mute, callback) {
  488. //This will be for remote streams only
  489. // if (this.forceMuted && !mute) {
  490. // logger.info("Asking focus for unmute");
  491. // this.connection.moderate.setMute(this.connection.emuc.myroomjid, mute);
  492. // // FIXME: wait for result before resetting muted status
  493. // this.forceMuted = false;
  494. // }
  495. return this.sendAudioInfoPresence(mute, callback);
  496. };
  497. ChatRoom.prototype.addAudioInfoToPresence = function (mute) {
  498. this.removeFromPresence("audiomuted");
  499. this.addToPresence("audiomuted",
  500. {attributes:
  501. {"audions": "http://jitsi.org/jitmeet/audio"},
  502. value: mute.toString()});
  503. };
  504. ChatRoom.prototype.sendAudioInfoPresence = function(mute, callback) {
  505. this.addAudioInfoToPresence(mute);
  506. if(this.connection) {
  507. this.sendPresence();
  508. }
  509. if(callback)
  510. callback();
  511. };
  512. ChatRoom.prototype.addVideoInfoToPresence = function (mute) {
  513. this.removeFromPresence("videomuted");
  514. this.addToPresence("videomuted",
  515. {attributes:
  516. {"videons": "http://jitsi.org/jitmeet/video"},
  517. value: mute.toString()});
  518. };
  519. ChatRoom.prototype.sendVideoInfoPresence = function (mute) {
  520. this.addVideoInfoToPresence(mute);
  521. if(!this.connection)
  522. return;
  523. this.sendPresence();
  524. };
  525. ChatRoom.prototype.addListener = function(type, listener) {
  526. this.eventEmitter.on(type, listener);
  527. };
  528. ChatRoom.prototype.removeListener = function (type, listener) {
  529. this.eventEmitter.removeListener(type, listener);
  530. };
  531. ChatRoom.prototype.remoteStreamAdded = function(data, sid, thessrc) {
  532. if(this.lastPresences[data.peerjid])
  533. {
  534. var pres = this.lastPresences[data.peerjid];
  535. var audiomuted = filterNodeFromPresenceJSON(pres, "audiomuted");
  536. var videomuted = filterNodeFromPresenceJSON(pres, "videomuted");
  537. data.videomuted = ((videomuted.length > 0
  538. && videomuted[0]
  539. && videomuted[0]["value"] === "true")? true : false);
  540. data.audiomuted = ((audiomuted.length > 0
  541. && audiomuted[0]
  542. && audiomuted[0]["value"] === "true")? true : false);
  543. }
  544. this.eventEmitter.emit(XMPPEvents.REMOTE_STREAM_RECEIVED, data, sid, thessrc);
  545. };
  546. ChatRoom.prototype.getJidBySSRC = function (ssrc) {
  547. if (!this.session)
  548. return null;
  549. return this.session.getSsrcOwner(ssrc);
  550. };
  551. module.exports = ChatRoom;