Implements display name changed event.

This commit is contained in:
hristoterezov 2015-10-15 17:03:42 -05:00
parent ff779512c2
commit ee471fe06f
4 changed files with 16 additions and 0 deletions

View File

@ -151,6 +151,7 @@ JitsiConference.prototype.removeCommand = function (name) {
*/
JitsiConference.prototype.setDisplayName = function(name) {
this.room.addToPresence("nick", {attributes: {xmlns: 'http://jabber.org/protocol/nick'}, value: name});
this.room.sendPresence();
}
/**
@ -249,6 +250,11 @@ function setupListeners(conference) {
conference.room.addListener(XMPPEvents.MUC_MEMBER_LEFT,function (jid) {
conference.eventEmitter.emit(JitsiConferenceEvents.USER_LEFT, Strophe.getResourceFromJid(jid));
});
conference.room.addListener(XMPPEvents.DISPLAY_NAME_CHANGED, function (from, displayName) {
conference.eventEmitter.emit(JitsiConferenceEvents.DISPLAY_NAME_CHANGED,
Strophe.getResourceFromJid(from), displayName);
});
}

View File

@ -87,6 +87,9 @@ function onConnectionSuccess(){
room.on(JitsiMeetJS.events.conference.TRACK_MUTE_CHANGED, function (track) {
console.debug(track.getType() + " - " + track.isMuted());
});
room.on(JitsiMeetJS.events.conference.DISPLAY_NAME_CHANGED, function (userID, displayName) {
console.debug(userID + " - " + displayName);
});
room.join();
};

View File

@ -11,6 +11,7 @@
<script src="example.js" ></script>
</head>
<body>
<a onclick="room.setDisplayName(Math.random())">Change Display Name</a>
<video id="localVideo" autoplay="true"></video>
<!--<audio id="localAudio" autoplay="true" muted="true"></audio>-->
</body>

View File

@ -152,6 +152,7 @@ JitsiConference.prototype.removeCommand = function (name) {
*/
JitsiConference.prototype.setDisplayName = function(name) {
this.room.addToPresence("nick", {attributes: {xmlns: 'http://jabber.org/protocol/nick'}, value: name});
this.room.sendPresence();
}
/**
@ -250,6 +251,11 @@ function setupListeners(conference) {
conference.room.addListener(XMPPEvents.MUC_MEMBER_LEFT,function (jid) {
conference.eventEmitter.emit(JitsiConferenceEvents.USER_LEFT, Strophe.getResourceFromJid(jid));
});
conference.room.addListener(XMPPEvents.DISPLAY_NAME_CHANGED, function (from, displayName) {
conference.eventEmitter.emit(JitsiConferenceEvents.DISPLAY_NAME_CHANGED,
Strophe.getResourceFromJid(from), displayName);
});
}