Fix issue where multiple notification are sent to the client if the user is muted/talking.
git-svn-id: http://bigbluebutton.googlecode.com/svn/trunk@775 af16638f-c34d-0410-8cfa-b39d5352b314
This commit is contained in:
parent
ce7f74f011
commit
9d670d9486
@ -142,6 +142,7 @@ public class AsteriskVoiceService implements IVoiceService {
|
||||
* @see org.bigbluebuttonproject.asterisk.IVoiceService#addAsteriskServerListener(org.asteriskjava.live.AsteriskServerListener)
|
||||
*/
|
||||
public void addAsteriskServerListener(AsteriskServerListener listener) throws ManagerCommunicationException {
|
||||
logger.info("Adding ConferenceRoomListener");
|
||||
asteriskServer.addAsteriskServerListener(listener);
|
||||
}
|
||||
|
||||
|
@ -61,6 +61,7 @@ public class Application extends ApplicationAdapter implements
|
||||
|
||||
/** The room listener. */
|
||||
private ConferenceRoomListener roomListener;
|
||||
private boolean listenerStarted = false;
|
||||
|
||||
/**
|
||||
* @see org.red5.server.adapter.MultiThreadedApplicationAdapter#appStart(org.red5.server.api.IScope)
|
||||
@ -72,7 +73,7 @@ public class Application extends ApplicationAdapter implements
|
||||
|
||||
log.info( "MeetMe::appStart - " );
|
||||
appScope = app;
|
||||
|
||||
//initialize();
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -81,9 +82,11 @@ public class Application extends ApplicationAdapter implements
|
||||
*/
|
||||
private void initialize()
|
||||
{
|
||||
// roomListener = new ConferenceRoomListener();
|
||||
try {
|
||||
if (! listenerStarted) {
|
||||
voiceService.addAsteriskServerListener(roomListener);
|
||||
listenerStarted = true;
|
||||
}
|
||||
} catch (ManagerCommunicationException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
@ -106,13 +109,6 @@ public class Application extends ApplicationAdapter implements
|
||||
super.appConnect(conn, params);
|
||||
|
||||
log.info( "MeetMe::appConnect - " + conn.getClient().getId() );
|
||||
|
||||
// initialize();
|
||||
|
||||
// boolean accept = ((Boolean)params[0]).booleanValue();
|
||||
|
||||
// if ( !accept ) rejectClient( "you passed false..." );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -129,10 +125,21 @@ public class Application extends ApplicationAdapter implements
|
||||
*/
|
||||
public boolean roomStart(IScope room) {
|
||||
log.info( "MeetMe::roomStart - " + room.getName() );
|
||||
|
||||
if (!super.roomStart(room))
|
||||
return false;
|
||||
|
||||
initialize();
|
||||
|
||||
if (!hasSharedObject(room, "meetMeUsersSO")) {
|
||||
createSharedObject(room, "meetMeUsersSO", false);
|
||||
ISharedObject so = getSharedObject(room, "meetMeUsersSO", false);
|
||||
roomListener.addRoom(room.getName(), so);
|
||||
} else {
|
||||
ISharedObject so = getSharedObject(room, "meetMeUsersSO", false);
|
||||
}
|
||||
|
||||
roomListener.initializeConferenceUsers(room.getName());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -27,10 +27,11 @@ import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.lang.Boolean;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.asteriskjava.live.ManagerCommunicationException;
|
||||
import org.asteriskjava.live.AbstractAsteriskServerListener;
|
||||
import org.asteriskjava.live.MeetMeUser;
|
||||
import org.asteriskjava.live.MeetMeUserState;
|
||||
@ -68,6 +69,16 @@ public class ConferenceRoomListener extends AbstractAsteriskServerListener {
|
||||
log.debug("RoomListener started...");
|
||||
}
|
||||
|
||||
private void initialize()
|
||||
{
|
||||
try {
|
||||
voiceService.addAsteriskServerListener(this);
|
||||
} catch (ManagerCommunicationException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.asteriskjava.live.AbstractAsteriskServerListener#onNewMeetMeUser(org.asteriskjava.live.MeetMeUser)
|
||||
*/
|
||||
@ -134,10 +145,26 @@ public class ConferenceRoomListener extends AbstractAsteriskServerListener {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void initializeConferenceUsers(String room) {
|
||||
if (meetMeSOs.containsKey(room)) {
|
||||
ISharedObject so = (ISharedObject) meetMeSOs.get(room);
|
||||
|
||||
// Get the users in the room
|
||||
Collection<MeetMeUser> currentUsers = voiceService.getUsers(room);
|
||||
|
||||
log.info("initializeConferenceUsers - There are " + currentUsers.size()
|
||||
+ " current users in room [" + room + "]");
|
||||
|
||||
for (Iterator it = currentUsers.iterator(); it.hasNext();) {
|
||||
MeetMeUser oneUser = (MeetMeUser) it.next();
|
||||
oneUser.addPropertyChangeListener(new ParticipantPropertyChangeListener(so));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current users.
|
||||
*
|
||||
@ -157,7 +184,7 @@ public class ConferenceRoomListener extends AbstractAsteriskServerListener {
|
||||
|
||||
for (Iterator it = currentUsers.iterator(); it.hasNext();) {
|
||||
MeetMeUser oneUser = (MeetMeUser) it.next();
|
||||
oneUser.addPropertyChangeListener(new ParticipantPropertyChangeListener(so));
|
||||
//oneUser.addPropertyChangeListener(new ParticipantPropertyChangeListener(so));
|
||||
}
|
||||
|
||||
return currentUsers;
|
||||
@ -194,6 +221,9 @@ public class ConferenceRoomListener extends AbstractAsteriskServerListener {
|
||||
*/
|
||||
private class ParticipantPropertyChangeListener implements PropertyChangeListener {
|
||||
|
||||
private Boolean talking = null;
|
||||
private Boolean muted = null;
|
||||
|
||||
/** The so. */
|
||||
private ISharedObject so;
|
||||
|
||||
@ -216,32 +246,34 @@ public class ConferenceRoomListener extends AbstractAsteriskServerListener {
|
||||
" old = '" + evt.getOldValue() + "' new = '" + evt.getNewValue() +
|
||||
"' room = '" + ((MeetMeUser) evt.getSource()).getRoom() + "'");
|
||||
|
||||
log.info("New data mute = " + changedUser.isMuted());
|
||||
|
||||
// MeetMeUserVo userVo = new MeetMeUserVo(changedUser);
|
||||
//
|
||||
// List <Object>args1 = new ArrayList<Object>();
|
||||
// args1.add(userVo);
|
||||
// so.sendMessage("newStatus", args1);
|
||||
|
||||
if (evt.getPropertyName().equals("muted")) {
|
||||
if ((muted == null) || (muted.booleanValue() != changedUser.isMuted())) {
|
||||
List <Object>args = new ArrayList<Object>();
|
||||
args.add(changedUser.getUserNumber());
|
||||
args.add(changedUser.isMuted());
|
||||
log.info("User mute changed: [" + changedUser.getUserNumber()
|
||||
+ ",old=" + muted + ",new=" + changedUser.isMuted() + "]");
|
||||
muted = changedUser.isMuted();
|
||||
args.add(muted);
|
||||
so.sendMessage("userMute", args);
|
||||
|
||||
log.info("User mute event: [" + changedUser.getUserNumber()
|
||||
} else {
|
||||
log.info("User mute same: [" + changedUser.getUserNumber()
|
||||
+ "," + changedUser.isMuted() + "]");
|
||||
}
|
||||
} else if (evt.getPropertyName().equals("talking")) {
|
||||
List <Object>args = new ArrayList<Object>();
|
||||
args.add(changedUser.getUserNumber());
|
||||
args.add(changedUser.isTalking());
|
||||
if ((talking == null) || (talking.booleanValue() != changedUser.isTalking())) {
|
||||
log.info("User talk changed: [" + changedUser.getUserNumber()
|
||||
+ ",old=" + talking + ",new="+ changedUser.isTalking() + "]");
|
||||
talking = changedUser.isTalking();
|
||||
args.add(talking);
|
||||
so.sendMessage("userTalk", args);
|
||||
|
||||
log.info("User talk event: [" + changedUser.getUserNumber()
|
||||
} else {
|
||||
log.info("User talk same: [" + changedUser.getUserNumber()
|
||||
+ "," + changedUser.isTalking() + "]");
|
||||
}
|
||||
} else if ("state".equals(evt.getPropertyName())) {
|
||||
log.info("User is changing state to [" + evt.getNewValue() + "]");
|
||||
log.info("User [" + changedUser.getUserNumber() + "," + evt.getNewValue() + "]");
|
||||
|
||||
List <Object>args = new ArrayList<Object>();
|
||||
args.add(changedUser.getUserNumber());
|
||||
|
Loading…
Reference in New Issue
Block a user