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.

strophe.emuc.js 25KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615
  1. /* jshint -W117 */
  2. /* a simple MUC connection plugin
  3. * can only handle a single MUC room
  4. */
  5. var XMPPEvents = require("../../service/xmpp/XMPPEvents");
  6. var Moderator = require("./moderator");
  7. var JingleSession = require("./JingleSession");
  8. var bridgeIsDown = false;
  9. module.exports = function(XMPP, eventEmitter) {
  10. Strophe.addConnectionPlugin('emuc', {
  11. connection: null,
  12. roomjid: null,
  13. myroomjid: null,
  14. members: {},
  15. list_members: [], // so we can elect a new focus
  16. presMap: {},
  17. preziMap: {},
  18. joined: false,
  19. isOwner: false,
  20. role: null,
  21. focusMucJid: null,
  22. ssrc2jid: {},
  23. init: function (conn) {
  24. this.connection = conn;
  25. },
  26. initPresenceMap: function (myroomjid) {
  27. this.presMap['to'] = myroomjid;
  28. this.presMap['xns'] = 'http://jabber.org/protocol/muc';
  29. },
  30. doJoin: function (jid, password) {
  31. this.myroomjid = jid;
  32. console.info("Joined MUC as " + this.myroomjid);
  33. this.initPresenceMap(this.myroomjid);
  34. if (!this.roomjid) {
  35. this.roomjid = Strophe.getBareJidFromJid(jid);
  36. // add handlers (just once)
  37. this.connection.addHandler(this.onPresence.bind(this), null, 'presence', null, null, this.roomjid, {matchBare: true});
  38. this.connection.addHandler(this.onPresenceUnavailable.bind(this), null, 'presence', 'unavailable', null, this.roomjid, {matchBare: true});
  39. this.connection.addHandler(this.onPresenceError.bind(this), null, 'presence', 'error', null, this.roomjid, {matchBare: true});
  40. this.connection.addHandler(this.onMessage.bind(this), null, 'message', null, null, this.roomjid, {matchBare: true});
  41. }
  42. if (password !== undefined) {
  43. this.presMap['password'] = password;
  44. }
  45. this.sendPresence();
  46. },
  47. doLeave: function () {
  48. console.log("do leave", this.myroomjid);
  49. var pres = $pres({to: this.myroomjid, type: 'unavailable' });
  50. this.presMap.length = 0;
  51. this.connection.send(pres);
  52. },
  53. createNonAnonymousRoom: function () {
  54. // http://xmpp.org/extensions/xep-0045.html#createroom-reserved
  55. var getForm = $iq({type: 'get', to: this.roomjid})
  56. .c('query', {xmlns: 'http://jabber.org/protocol/muc#owner'})
  57. .c('x', {xmlns: 'jabber:x:data', type: 'submit'});
  58. var self = this;
  59. this.connection.sendIQ(getForm, function (form) {
  60. if (!$(form).find(
  61. '>query>x[xmlns="jabber:x:data"]' +
  62. '>field[var="muc#roomconfig_whois"]').length) {
  63. console.error('non-anonymous rooms not supported');
  64. return;
  65. }
  66. var formSubmit = $iq({to: this.roomjid, type: 'set'})
  67. .c('query', {xmlns: 'http://jabber.org/protocol/muc#owner'});
  68. formSubmit.c('x', {xmlns: 'jabber:x:data', type: 'submit'});
  69. formSubmit.c('field', {'var': 'FORM_TYPE'})
  70. .c('value')
  71. .t('http://jabber.org/protocol/muc#roomconfig').up().up();
  72. formSubmit.c('field', {'var': 'muc#roomconfig_whois'})
  73. .c('value').t('anyone').up().up();
  74. self.connection.sendIQ(formSubmit);
  75. }, function (error) {
  76. console.error("Error getting room configuration form");
  77. });
  78. },
  79. onPresence: function (pres) {
  80. var from = pres.getAttribute('from');
  81. // What is this for? A workaround for something?
  82. if (pres.getAttribute('type')) {
  83. return true;
  84. }
  85. // Parse etherpad tag.
  86. var etherpad = $(pres).find('>etherpad');
  87. if (etherpad.length) {
  88. if (config.etherpad_base && !Moderator.isModerator()) {
  89. eventEmitter.emit(XMPPEvents.ETHERPAD, etherpad.text());
  90. }
  91. }
  92. // Parse prezi tag.
  93. var presentation = $(pres).find('>prezi');
  94. if (presentation.length) {
  95. var url = presentation.attr('url');
  96. var current = presentation.find('>current').text();
  97. console.log('presentation info received from', from, url);
  98. if (this.preziMap[from] == null) {
  99. this.preziMap[from] = url;
  100. $(document).trigger('presentationadded.muc', [from, url, current]);
  101. }
  102. else {
  103. $(document).trigger('gotoslide.muc', [from, url, current]);
  104. }
  105. }
  106. else if (this.preziMap[from] != null) {
  107. var url = this.preziMap[from];
  108. delete this.preziMap[from];
  109. $(document).trigger('presentationremoved.muc', [from, url]);
  110. }
  111. // Parse audio info tag.
  112. var audioMuted = $(pres).find('>audiomuted');
  113. if (audioMuted.length) {
  114. $(document).trigger('audiomuted.muc', [from, audioMuted.text()]);
  115. }
  116. // Parse video info tag.
  117. var videoMuted = $(pres).find('>videomuted');
  118. if (videoMuted.length) {
  119. $(document).trigger('videomuted.muc', [from, videoMuted.text()]);
  120. }
  121. var stats = $(pres).find('>stats');
  122. if (stats.length) {
  123. var statsObj = {};
  124. Strophe.forEachChild(stats[0], "stat", function (el) {
  125. statsObj[el.getAttribute("name")] = el.getAttribute("value");
  126. });
  127. eventEmitter.emit(XMPPEvents.REMOTE_STATS, from, statsObj);
  128. }
  129. // Parse status.
  130. if ($(pres).find('>x[xmlns="http://jabber.org/protocol/muc#user"]>status[code="201"]').length) {
  131. this.isOwner = true;
  132. this.createNonAnonymousRoom();
  133. }
  134. // Parse roles.
  135. var member = {};
  136. member.show = $(pres).find('>show').text();
  137. member.status = $(pres).find('>status').text();
  138. var tmp = $(pres).find('>x[xmlns="http://jabber.org/protocol/muc#user"]>item');
  139. member.affiliation = tmp.attr('affiliation');
  140. member.role = tmp.attr('role');
  141. // Focus recognition
  142. member.jid = tmp.attr('jid');
  143. member.isFocus = false;
  144. if (member.jid
  145. && member.jid.indexOf(Moderator.getFocusUserJid() + "/") == 0) {
  146. member.isFocus = true;
  147. }
  148. var nicktag = $(pres).find('>nick[xmlns="http://jabber.org/protocol/nick"]');
  149. member.displayName = (nicktag.length > 0 ? nicktag.html() : null);
  150. if (from == this.myroomjid) {
  151. if (member.affiliation == 'owner') this.isOwner = true;
  152. if (this.role !== member.role) {
  153. this.role = member.role;
  154. eventEmitter.emit(XMPPEvents.LOCALROLE_CHANGED,
  155. from, member, pres, Moderator.isModerator(),
  156. Moderator.isExternalAuthEnabled());
  157. }
  158. if (!this.joined) {
  159. this.joined = true;
  160. eventEmitter.emit(XMPPEvents.MUC_JOINED, from, member);
  161. this.list_members.push(from);
  162. }
  163. } else if (this.members[from] === undefined) {
  164. // new participant
  165. this.members[from] = member;
  166. this.list_members.push(from);
  167. console.log('entered', from, member);
  168. if (member.isFocus) {
  169. this.focusMucJid = from;
  170. console.info("Ignore focus: " + from + ", real JID: " + member.jid);
  171. }
  172. else {
  173. var id = $(pres).find('>userID').text();
  174. var email = $(pres).find('>email');
  175. if (email.length > 0) {
  176. id = email.text();
  177. }
  178. eventEmitter.emit(XMPPEvents.MUC_ENTER, from, id, member.displayName);
  179. }
  180. } else {
  181. // Presence update for existing participant
  182. // Watch role change:
  183. if (this.members[from].role != member.role) {
  184. this.members[from].role = member.role;
  185. eventEmitter.emit(XMPPEvents.MUC_ROLE_CHANGED,
  186. member.role, member.displayName);
  187. }
  188. }
  189. // Always trigger presence to update bindings
  190. this.parsePresence(from, member, pres);
  191. // Trigger status message update
  192. if (member.status) {
  193. eventEmitter.emit(XMPPEvents.PRESENCE_STATUS, from, member);
  194. }
  195. return true;
  196. },
  197. onPresenceUnavailable: function (pres) {
  198. var from = pres.getAttribute('from');
  199. // Status code 110 indicates that this notification is "self-presence".
  200. if (!$(pres).find('>x[xmlns="http://jabber.org/protocol/muc#user"]>status[code="110"]').length) {
  201. delete this.members[from];
  202. this.list_members.splice(this.list_members.indexOf(from), 1);
  203. this.onParticipantLeft(from);
  204. }
  205. // If the status code is 110 this means we're leaving and we would like
  206. // to remove everyone else from our view, so we trigger the event.
  207. else if (this.list_members.length > 1) {
  208. for (var i = 0; i < this.list_members.length; i++) {
  209. var member = this.list_members[i];
  210. delete this.members[i];
  211. this.list_members.splice(i, 1);
  212. this.onParticipantLeft(member);
  213. }
  214. }
  215. if ($(pres).find('>x[xmlns="http://jabber.org/protocol/muc#user"]>status[code="307"]').length) {
  216. $(document).trigger('kicked.muc', [from]);
  217. if (this.myroomjid === from) {
  218. XMPP.disposeConference(false);
  219. eventEmitter.emit(XMPPEvents.KICKED);
  220. }
  221. }
  222. return true;
  223. },
  224. onPresenceError: function (pres) {
  225. var from = pres.getAttribute('from');
  226. if ($(pres).find('>error[type="auth"]>not-authorized[xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"]').length) {
  227. console.log('on password required', from);
  228. var self = this;
  229. eventEmitter.emit(XMPPEvents.PASSWORD_REQUIRED, function (value) {
  230. self.doJoin(from, value);
  231. });
  232. } else if ($(pres).find(
  233. '>error[type="cancel"]>not-allowed[xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"]').length) {
  234. var toDomain = Strophe.getDomainFromJid(pres.getAttribute('to'));
  235. if (toDomain === config.hosts.anonymousdomain) {
  236. // enter the room by replying with 'not-authorized'. This would
  237. // result in reconnection from authorized domain.
  238. // We're either missing Jicofo/Prosody config for anonymous
  239. // domains or something is wrong.
  240. // XMPP.promptLogin();
  241. APP.UI.messageHandler.openReportDialog(null,
  242. 'Oops ! We couldn`t join the conference.' +
  243. ' There might be some problem with security' +
  244. ' configuration. Please contact service' +
  245. ' administrator.', pres);
  246. } else {
  247. console.warn('onPresError ', pres);
  248. APP.UI.messageHandler.openReportDialog(null,
  249. 'Oops! Something went wrong and we couldn`t connect to the conference.',
  250. pres);
  251. }
  252. } else {
  253. console.warn('onPresError ', pres);
  254. APP.UI.messageHandler.openReportDialog(null,
  255. 'Oops! Something went wrong and we couldn`t connect to the conference.',
  256. pres);
  257. }
  258. return true;
  259. },
  260. sendMessage: function (body, nickname) {
  261. var msg = $msg({to: this.roomjid, type: 'groupchat'});
  262. msg.c('body', body).up();
  263. if (nickname) {
  264. msg.c('nick', {xmlns: 'http://jabber.org/protocol/nick'}).t(nickname).up().up();
  265. }
  266. this.connection.send(msg);
  267. eventEmitter.emit(XMPPEvents.SENDING_CHAT_MESSAGE, body);
  268. },
  269. setSubject: function (subject) {
  270. var msg = $msg({to: this.roomjid, type: 'groupchat'});
  271. msg.c('subject', subject);
  272. this.connection.send(msg);
  273. console.log("topic changed to " + subject);
  274. },
  275. onMessage: function (msg) {
  276. // FIXME: this is a hack. but jingle on muc makes nickchanges hard
  277. var from = msg.getAttribute('from');
  278. var nick =
  279. $(msg).find('>nick[xmlns="http://jabber.org/protocol/nick"]')
  280. .text() ||
  281. Strophe.getResourceFromJid(from);
  282. var txt = $(msg).find('>body').text();
  283. var type = msg.getAttribute("type");
  284. if (type == "error") {
  285. eventEmitter.emit(XMPPEvents.CHAT_ERROR_RECEIVED,
  286. $(msg).find('>text').text(), txt);
  287. return true;
  288. }
  289. var subject = $(msg).find('>subject');
  290. if (subject.length) {
  291. var subjectText = subject.text();
  292. if (subjectText || subjectText == "") {
  293. eventEmitter.emit(XMPPEvents.SUBJECT_CHANGED, subjectText);
  294. console.log("Subject is changed to " + subjectText);
  295. }
  296. }
  297. if (txt) {
  298. console.log('chat', nick, txt);
  299. eventEmitter.emit(XMPPEvents.MESSAGE_RECEIVED,
  300. from, nick, txt, this.myroomjid);
  301. }
  302. return true;
  303. },
  304. lockRoom: function (key, onSuccess, onError, onNotSupported) {
  305. //http://xmpp.org/extensions/xep-0045.html#roomconfig
  306. var ob = this;
  307. this.connection.sendIQ($iq({to: this.roomjid, type: 'get'}).c('query', {xmlns: 'http://jabber.org/protocol/muc#owner'}),
  308. function (res) {
  309. if ($(res).find('>query>x[xmlns="jabber:x:data"]>field[var="muc#roomconfig_roomsecret"]').length) {
  310. var formsubmit = $iq({to: ob.roomjid, type: 'set'}).c('query', {xmlns: 'http://jabber.org/protocol/muc#owner'});
  311. formsubmit.c('x', {xmlns: 'jabber:x:data', type: 'submit'});
  312. formsubmit.c('field', {'var': 'FORM_TYPE'}).c('value').t('http://jabber.org/protocol/muc#roomconfig').up().up();
  313. formsubmit.c('field', {'var': 'muc#roomconfig_roomsecret'}).c('value').t(key).up().up();
  314. // Fixes a bug in prosody 0.9.+ https://code.google.com/p/lxmppd/issues/detail?id=373
  315. formsubmit.c('field', {'var': 'muc#roomconfig_whois'}).c('value').t('anyone').up().up();
  316. // FIXME: is muc#roomconfig_passwordprotectedroom required?
  317. ob.connection.sendIQ(formsubmit,
  318. onSuccess,
  319. onError);
  320. } else {
  321. onNotSupported();
  322. }
  323. }, onError);
  324. },
  325. kick: function (jid) {
  326. var kickIQ = $iq({to: this.roomjid, type: 'set'})
  327. .c('query', {xmlns: 'http://jabber.org/protocol/muc#admin'})
  328. .c('item', {nick: Strophe.getResourceFromJid(jid), role: 'none'})
  329. .c('reason').t('You have been kicked.').up().up().up();
  330. this.connection.sendIQ(
  331. kickIQ,
  332. function (result) {
  333. console.log('Kick participant with jid: ', jid, result);
  334. },
  335. function (error) {
  336. console.log('Kick participant error: ', error);
  337. });
  338. },
  339. sendPresence: function () {
  340. var pres = $pres({to: this.presMap['to'] });
  341. pres.c('x', {xmlns: this.presMap['xns']});
  342. if (this.presMap['password']) {
  343. pres.c('password').t(this.presMap['password']).up();
  344. }
  345. pres.up();
  346. // Send XEP-0115 'c' stanza that contains our capabilities info
  347. if (this.connection.caps) {
  348. this.connection.caps.node = config.clientNode;
  349. pres.c('c', this.connection.caps.generateCapsAttrs()).up();
  350. }
  351. pres.c('user-agent', {xmlns: 'http://jitsi.org/jitmeet/user-agent'})
  352. .t(navigator.userAgent).up();
  353. if (this.presMap['bridgeIsDown']) {
  354. pres.c('bridgeIsDown').up();
  355. }
  356. if (this.presMap['email']) {
  357. pres.c('email').t(this.presMap['email']).up();
  358. }
  359. if (this.presMap['userId']) {
  360. pres.c('userId').t(this.presMap['userId']).up();
  361. }
  362. if (this.presMap['displayName']) {
  363. // XEP-0172
  364. pres.c('nick', {xmlns: 'http://jabber.org/protocol/nick'})
  365. .t(this.presMap['displayName']).up();
  366. }
  367. if (this.presMap['audions']) {
  368. pres.c('audiomuted', {xmlns: this.presMap['audions']})
  369. .t(this.presMap['audiomuted']).up();
  370. }
  371. if (this.presMap['videons']) {
  372. pres.c('videomuted', {xmlns: this.presMap['videons']})
  373. .t(this.presMap['videomuted']).up();
  374. }
  375. if (this.presMap['statsns']) {
  376. var stats = pres.c('stats', {xmlns: this.presMap['statsns']});
  377. for (var stat in this.presMap["stats"])
  378. if (this.presMap["stats"][stat] != null)
  379. stats.c("stat", {name: stat, value: this.presMap["stats"][stat]}).up();
  380. pres.up();
  381. }
  382. if (this.presMap['prezins']) {
  383. pres.c('prezi',
  384. {xmlns: this.presMap['prezins'],
  385. 'url': this.presMap['preziurl']})
  386. .c('current').t(this.presMap['prezicurrent']).up().up();
  387. }
  388. if (this.presMap['etherpadns']) {
  389. pres.c('etherpad', {xmlns: this.presMap['etherpadns']})
  390. .t(this.presMap['etherpadname']).up();
  391. }
  392. if (this.presMap['medians']) {
  393. pres.c('media', {xmlns: this.presMap['medians']});
  394. var sourceNumber = 0;
  395. Object.keys(this.presMap).forEach(function (key) {
  396. if (key.indexOf('source') >= 0) {
  397. sourceNumber++;
  398. }
  399. });
  400. if (sourceNumber > 0)
  401. for (var i = 1; i <= sourceNumber / 3; i++) {
  402. pres.c('source',
  403. {type: this.presMap['source' + i + '_type'],
  404. ssrc: this.presMap['source' + i + '_ssrc'],
  405. direction: this.presMap['source' + i + '_direction']
  406. || 'sendrecv' }
  407. ).up();
  408. }
  409. }
  410. pres.up();
  411. this.connection.send(pres);
  412. },
  413. addDisplayNameToPresence: function (displayName) {
  414. this.presMap['displayName'] = displayName;
  415. },
  416. addMediaToPresence: function (sourceNumber, mtype, ssrcs, direction) {
  417. if (!this.presMap['medians'])
  418. this.presMap['medians'] = 'http://estos.de/ns/mjs';
  419. this.presMap['source' + sourceNumber + '_type'] = mtype;
  420. this.presMap['source' + sourceNumber + '_ssrc'] = ssrcs;
  421. this.presMap['source' + sourceNumber + '_direction'] = direction;
  422. },
  423. clearPresenceMedia: function () {
  424. var self = this;
  425. Object.keys(this.presMap).forEach(function (key) {
  426. if (key.indexOf('source') != -1) {
  427. delete self.presMap[key];
  428. }
  429. });
  430. },
  431. addPreziToPresence: function (url, currentSlide) {
  432. this.presMap['prezins'] = 'http://jitsi.org/jitmeet/prezi';
  433. this.presMap['preziurl'] = url;
  434. this.presMap['prezicurrent'] = currentSlide;
  435. },
  436. removePreziFromPresence: function () {
  437. delete this.presMap['prezins'];
  438. delete this.presMap['preziurl'];
  439. delete this.presMap['prezicurrent'];
  440. },
  441. addCurrentSlideToPresence: function (currentSlide) {
  442. this.presMap['prezicurrent'] = currentSlide;
  443. },
  444. getPrezi: function (roomjid) {
  445. return this.preziMap[roomjid];
  446. },
  447. addEtherpadToPresence: function (etherpadName) {
  448. this.presMap['etherpadns'] = 'http://jitsi.org/jitmeet/etherpad';
  449. this.presMap['etherpadname'] = etherpadName;
  450. },
  451. addAudioInfoToPresence: function (isMuted) {
  452. this.presMap['audions'] = 'http://jitsi.org/jitmeet/audio';
  453. this.presMap['audiomuted'] = isMuted.toString();
  454. },
  455. addVideoInfoToPresence: function (isMuted) {
  456. this.presMap['videons'] = 'http://jitsi.org/jitmeet/video';
  457. this.presMap['videomuted'] = isMuted.toString();
  458. },
  459. addConnectionInfoToPresence: function (stats) {
  460. this.presMap['statsns'] = 'http://jitsi.org/jitmeet/stats';
  461. this.presMap['stats'] = stats;
  462. },
  463. findJidFromResource: function (resourceJid) {
  464. if (resourceJid &&
  465. resourceJid === Strophe.getResourceFromJid(this.myroomjid)) {
  466. return this.myroomjid;
  467. }
  468. var peerJid = null;
  469. Object.keys(this.members).some(function (jid) {
  470. peerJid = jid;
  471. return Strophe.getResourceFromJid(jid) === resourceJid;
  472. });
  473. return peerJid;
  474. },
  475. addBridgeIsDownToPresence: function () {
  476. this.presMap['bridgeIsDown'] = true;
  477. },
  478. addEmailToPresence: function (email) {
  479. this.presMap['email'] = email;
  480. },
  481. addUserIdToPresence: function (userId) {
  482. this.presMap['userId'] = userId;
  483. },
  484. isModerator: function () {
  485. return this.role === 'moderator';
  486. },
  487. getMemberRole: function (peerJid) {
  488. if (this.members[peerJid]) {
  489. return this.members[peerJid].role;
  490. }
  491. return null;
  492. },
  493. onParticipantLeft: function (jid) {
  494. eventEmitter.emit(XMPPEvents.MUC_LEFT, jid);
  495. this.connection.jingle.terminateByJid(jid);
  496. if (this.getPrezi(jid)) {
  497. $(document).trigger('presentationremoved.muc',
  498. [jid, this.getPrezi(jid)]);
  499. }
  500. Moderator.onMucLeft(jid);
  501. },
  502. parsePresence: function (from, memeber, pres) {
  503. if($(pres).find(">bridgeIsDown").length > 0 && !bridgeIsDown) {
  504. bridgeIsDown = true;
  505. eventEmitter.emit(XMPPEvents.BRIDGE_DOWN);
  506. }
  507. if(memeber.isFocus)
  508. return;
  509. var self = this;
  510. // Remove old ssrcs coming from the jid
  511. Object.keys(this.ssrc2jid).forEach(function (ssrc) {
  512. if (self.ssrc2jid[ssrc] == from) {
  513. delete self.ssrc2jid[ssrc];
  514. }
  515. });
  516. var changedStreams = [];
  517. $(pres).find('>media[xmlns="http://estos.de/ns/mjs"]>source').each(function (idx, ssrc) {
  518. //console.log(jid, 'assoc ssrc', ssrc.getAttribute('type'), ssrc.getAttribute('ssrc'));
  519. var ssrcV = ssrc.getAttribute('ssrc');
  520. self.ssrc2jid[ssrcV] = from;
  521. JingleSession.notReceivedSSRCs.push(ssrcV);
  522. var type = ssrc.getAttribute('type');
  523. var direction = ssrc.getAttribute('direction');
  524. changedStreams.push({type: type, direction: direction});
  525. });
  526. eventEmitter.emit(XMPPEvents.CHANGED_STREAMS, from, changedStreams);
  527. var displayName = !config.displayJids
  528. ? memeber.displayName : Strophe.getResourceFromJid(from);
  529. if (displayName && displayName.length > 0)
  530. {
  531. eventEmitter.emit(XMPPEvents.DISPLAY_NAME_CHANGED, from, displayName);
  532. }
  533. var id = $(pres).find('>userID').text();
  534. var email = $(pres).find('>email');
  535. if(email.length > 0) {
  536. id = email.text();
  537. }
  538. eventEmitter.emit(XMPPEvents.USER_ID_CHANGED, from, id);
  539. }
  540. });
  541. };