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:
Richard Alam 2008-12-09 20:10:38 +00:00
parent ce7f74f011
commit 9d670d9486
3 changed files with 76 additions and 36 deletions

View File

@ -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);
}

View File

@ -61,18 +61,19 @@ 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)
*/
@Override
public boolean appStart (IScope app )
public boolean appStart(IScope app )
{
super.appStart(app);
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 {
voiceService.addAsteriskServerListener(roomListener);
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;
}

View File

@ -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)
*/
@ -133,10 +144,26 @@ public class ConferenceRoomListener extends AbstractAsteriskServerListener {
return oneUser;
}
}
}
}
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")) {
List <Object>args = new ArrayList<Object>();
args.add(changedUser.getUserNumber());
args.add(changedUser.isMuted());
so.sendMessage("userMute", args);
log.info("User mute event: [" + changedUser.getUserNumber()
if (evt.getPropertyName().equals("muted")) {
if ((muted == null) || (muted.booleanValue() != changedUser.isMuted())) {
List <Object>args = new ArrayList<Object>();
args.add(changedUser.getUserNumber());
log.info("User mute changed: [" + changedUser.getUserNumber()
+ ",old=" + muted + ",new=" + changedUser.isMuted() + "]");
muted = changedUser.isMuted();
args.add(muted);
so.sendMessage("userMute", args);
} 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());
so.sendMessage("userTalk", args);
log.info("User talk event: [" + changedUser.getUserNumber()
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);
} 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());