From 03ee9fffba851f726293272a6f7a2a7954bd829c Mon Sep 17 00:00:00 2001 From: isymchych Date: Wed, 13 Jan 2016 18:33:54 +0200 Subject: [PATCH] handle PRESENCE_STATUS event --- JitsiConference.js | 10 ++++++++++ JitsiConferenceEvents.js | 4 ++++ JitsiParticipant.js | 8 ++++++++ doc/API.md | 1 + modules/RTC/DataChannels.js | 1 - modules/xmpp/ChatRoom.js | 2 +- 6 files changed, 24 insertions(+), 2 deletions(-) diff --git a/JitsiConference.js b/JitsiConference.js index 531aa070e..225d1a139 100644 --- a/JitsiConference.js +++ b/JitsiConference.js @@ -871,6 +871,16 @@ function setupListeners(conference) { conference.eventEmitter.emit(JitsiConferenceEvents.MESSAGE_RECEIVED, id, txt, ts); }); + conference.room.addListener(XMPPEvents.PRESENCE_STATUS, function (jid, status) { + var id = Strophe.getResourceFromJid(jid); + var participant = conference.getParticipantById(id); + if (!participant || participant._status === status) { + return; + } + participant._status = status; + conference.eventEmitter.emit(JitsiConferenceEvents.USER_STATUS_CHANGED, id, status); + }); + conference.rtc.addListener(DSEvents.FIREFOX_EXTENSION_NEEDED, function (url) { conference.eventEmitter.emit(JitsiConferenceEvents.FIREFOX_EXTENSION_NEEDED, url); }); diff --git a/JitsiConferenceEvents.js b/JitsiConferenceEvents.js index 15d58986e..739152dce 100644 --- a/JitsiConferenceEvents.js +++ b/JitsiConferenceEvents.js @@ -27,6 +27,10 @@ var JitsiConferenceEvents = { * User role changed. */ USER_ROLE_CHANGED: "conference.roleChanged", + /** + * User status changed. + */ + USER_STATUS_CHANGED: "conference.statusChanged", /** * New text message was received. */ diff --git a/JitsiParticipant.js b/JitsiParticipant.js index 7be1958d7..2c13f1a6e 100644 --- a/JitsiParticipant.js +++ b/JitsiParticipant.js @@ -11,6 +11,7 @@ function JitsiParticipant(jid, conference, displayName){ this._supportsDTMF = false; this._tracks = []; this._role = 'none'; + this._status = null; } /** @@ -48,6 +49,13 @@ JitsiParticipant.prototype.getDisplayName = function() { return this._displayName; }; +/** + * @returns {String} The status of the participant. + */ +JitsiParticipant.prototype.getStatus = function () { + return this._status; +}; + /** * @returns {Boolean} Whether this participant is a moderator or not. */ diff --git a/doc/API.md b/doc/API.md index 3d26a95ee..88be73325 100644 --- a/doc/API.md +++ b/doc/API.md @@ -88,6 +88,7 @@ JitsiMeetJS.setLogLevel(JitsiMeetJS.logLevels.ERROR); - CONFERENCE_LEFT - notifies the local user that he left the conference successfully. (no parameters) - DTMF_SUPPORT_CHANGED - notifies if at least one user supports DTMF. (parameters - supports(boolean)) - USER_ROLE_CHANGED - notifies that role of some user changed. (parameters - id(string), role(string)) + - USER_STATUS_CHANGED - notifies that status of some user changed. (parameters - id(string), status(string)) - CONFERENCE_FAILED - notifies that user failed to join the conference. (parameters - errorCode(JitsiMeetJS.errors.conference)) - KICKED - notifies that user has been kicked from the conference. - START_MUTED_POLICY_CHANGED - notifies that all new participants will join with muted audio/video stream (parameters - JS object with 2 properties - audio(boolean), video(boolean)) diff --git a/modules/RTC/DataChannels.js b/modules/RTC/DataChannels.js index aaeed319f..3ff2e849c 100644 --- a/modules/RTC/DataChannels.js +++ b/modules/RTC/DataChannels.js @@ -217,4 +217,3 @@ DataChannels.prototype._some = function (callback, thisArg) { } module.exports = DataChannels; - diff --git a/modules/xmpp/ChatRoom.js b/modules/xmpp/ChatRoom.js index ad856f6c8..e809a5ccb 100644 --- a/modules/xmpp/ChatRoom.js +++ b/modules/xmpp/ChatRoom.js @@ -324,7 +324,7 @@ ChatRoom.prototype.onPresence = function (pres) { // Trigger status message update if (member.status) { - this.eventEmitter.emit(XMPPEvents.PRESENCE_STATUS, from, member); + this.eventEmitter.emit(XMPPEvents.PRESENCE_STATUS, from, member.status); } if(jibri)