- rename classes to match event names generated by appkonference

git-svn-id: http://bigbluebutton.googlecode.com/svn/trunk@3055 af16638f-c34d-0410-8cfa-b39d5352b314
This commit is contained in:
Richard Alam 2009-12-01 15:55:46 +00:00
parent 69558d3dc9
commit 1983b03fa8
17 changed files with 196 additions and 68 deletions

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<classpath> <classpath>
<classpathentry kind="src" path="src/main/java"/> <classpathentry kind="src" path="src/main/java"/>
<classpathentry kind="src" path="src/main/groovy"/> <classpathentry excluding="org/bigbluebutton/webconference/voice/asterisk/" kind="src" path="src/main/groovy"/>
<classpathentry kind="src" path="test/commandline/src"/> <classpathentry kind="src" path="test/commandline/src"/>
<classpathentry excluding="src/" kind="src" path="test/commandline"/> <classpathentry excluding="src/" kind="src" path="test/commandline"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>

View File

@ -1,25 +1,17 @@
package org.bigbluebutton.webconference.voice.asterisk.konference; package org.bigbluebutton.webconference.voice.asterisk.konference;
import org.asteriskjava.live.ManagerCommunicationException;
import org.asteriskjava.manager.ManagerConnection; import org.asteriskjava.manager.ManagerConnection;
import org.asteriskjava.manager.ManagerEventListener; import org.asteriskjava.manager.ManagerEventListener;
import org.asteriskjava.manager.action.CommandAction;
import org.asteriskjava.manager.event.ManagerEvent; import org.asteriskjava.manager.event.ManagerEvent;
import org.asteriskjava.manager.response.CommandResponse;
import org.asteriskjava.manager.response.ManagerError;
import org.asteriskjava.manager.response.ManagerResponse;
import org.asteriskjava.util.DateUtil;
import org.asteriskjava.util.Log; import org.asteriskjava.util.Log;
import org.asteriskjava.util.LogFactory; import org.asteriskjava.util.LogFactory;
import org.bigbluebutton.webconference.voice.asterisk.konference.events.AbstractKonferenceEvent; import org.bigbluebutton.webconference.voice.asterisk.konference.events.AbstractConferenceEvent;
import org.bigbluebutton.webconference.voice.asterisk.konference.events.KonferenceJoinEvent; import org.bigbluebutton.webconference.voice.asterisk.konference.events.ConferenceJoinEvent;
import org.bigbluebutton.webconference.voice.asterisk.konference.events.KonferenceLeaveEvent; import org.bigbluebutton.webconference.voice.asterisk.konference.events.ConferenceLeaveEvent;
import org.bigbluebutton.webconference.voice.asterisk.konference.events.KonferenceMemberMuteEvent; import org.bigbluebutton.webconference.voice.asterisk.konference.events.ConferenceMemberMuteEvent;
import org.bigbluebutton.webconference.voice.asterisk.konference.events.KonferenceMemberUnmuteEvent; import org.bigbluebutton.webconference.voice.asterisk.konference.events.ConferenceMemberUnmuteEvent;
import org.bigbluebutton.webconference.voice.asterisk.konference.events.KonferenceStateEvent; import org.bigbluebutton.webconference.voice.asterisk.konference.events.ConferenceStateEvent;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
class KonferenceManager implements ManagerEventListener { class KonferenceManager implements ManagerEventListener {
@ -29,18 +21,16 @@ class KonferenceManager implements ManagerEventListener {
private final Log logger = LogFactory.getLog(getClass()); private final Log logger = LogFactory.getLog(getClass());
private final ManagerConnection manager; private final ManagerConnection manager;
// private final Map<String, ConferenceRoomImpl> rooms;
KonferenceManager(ManagerConnection manager) { KonferenceManager(ManagerConnection manager) {
this.manager = manager; this.manager = manager;
// this.rooms = new HashMap<String, ConferenceRoomImpl>(); // this.rooms = new HashMap<String, ConferenceRoomImpl>();
manager.registerUserEventClass(KonferenceJoinEvent.class); manager.registerUserEventClass(ConferenceJoinEvent.class);
manager.registerUserEventClass(KonferenceLeaveEvent.class); manager.registerUserEventClass(ConferenceLeaveEvent.class);
manager.registerUserEventClass(KonferenceStateEvent.class); manager.registerUserEventClass(ConferenceStateEvent.class);
manager.registerUserEventClass(KonferenceMemberMuteEvent.class); manager.registerUserEventClass(ConferenceMemberMuteEvent.class);
manager.registerUserEventClass(KonferenceMemberUnmuteEvent.class); manager.registerUserEventClass(ConferenceMemberUnmuteEvent.class);
} }
@ -54,7 +44,7 @@ class KonferenceManager implements ManagerEventListener {
*/ */
} }
private void handleConferenceEvent(AbstractKonferenceEvent event) { private void handleConferenceEvent(AbstractConferenceEvent event) {
} }
@ -261,6 +251,6 @@ class KonferenceManager implements ManagerEventListener {
} }
*/ */
public void onManagerEvent(ManagerEvent event) { public void onManagerEvent(ManagerEvent event) {
handleConferenceEvent((AbstractKonferenceEvent)event); handleConferenceEvent((AbstractConferenceEvent)event);
} }
} }

View File

@ -2,12 +2,12 @@ package org.bigbluebutton.webconference.voice.asterisk.konference.events;
import org.asteriskjava.manager.event.ManagerEvent; import org.asteriskjava.manager.event.ManagerEvent;
public abstract class AbstractKonferenceEvent extends ManagerEvent { public abstract class AbstractConferenceEvent extends ManagerEvent {
private static final long serialVersionUID = 4049251911383919117L; private static final long serialVersionUID = 4049251911383919117L;
private String channel; private String channel;
private String conferenceName; private String conferenceName;
protected AbstractKonferenceEvent(Object source) { protected AbstractConferenceEvent(Object source) {
super(source); super(source);
} }

View File

@ -1,6 +1,6 @@
package org.bigbluebutton.webconference.voice.asterisk.konference.events; package org.bigbluebutton.webconference.voice.asterisk.konference.events;
public class KonferenceJoinEvent extends AbstractKonferenceEvent { public class ConferenceJoinEvent extends AbstractConferenceEvent {
private static final long serialVersionUID = 1926565708226475330L; private static final long serialVersionUID = 1926565708226475330L;
@ -13,7 +13,7 @@ public class KonferenceJoinEvent extends AbstractKonferenceEvent {
private Integer moderators; private Integer moderators;
private Integer count; private Integer count;
public KonferenceJoinEvent(Object source) { public ConferenceJoinEvent(Object source) {
super(source); super(source);
} }

View File

@ -1,7 +1,8 @@
package org.bigbluebutton.webconference.voice.asterisk.konference.events; package org.bigbluebutton.webconference.voice.asterisk.konference.events;
public class KonferenceLeaveEvent extends AbstractKonferenceEvent { public class ConferenceLeaveEvent extends AbstractConferenceEvent {
private static final long serialVersionUID = 4836233262809045338L;
private String type; private String type;
private String uniqueID; private String uniqueID;
private Integer member; private Integer member;
@ -12,8 +13,7 @@ public class KonferenceLeaveEvent extends AbstractKonferenceEvent {
private Integer moderators; private Integer moderators;
private Integer count; private Integer count;
public KonferenceLeaveEvent(Object source) public ConferenceLeaveEvent(Object source) {
{
super(source); super(source);
} }

View File

@ -0,0 +1,8 @@
package org.bigbluebutton.webconference.voice.asterisk.konference.events;
public class ConferenceLockEvent extends AbstractConferenceEvent {
public ConferenceLockEvent(Object source) {
super(source);
}
}

View File

@ -0,0 +1,8 @@
package org.bigbluebutton.webconference.voice.asterisk.konference.events;
public class ConferenceMemberMuteEvent extends AbstractConferenceEvent {
public ConferenceMemberMuteEvent(Object source) {
super(source);
}
}

View File

@ -0,0 +1,8 @@
package org.bigbluebutton.webconference.voice.asterisk.konference.events;
public class ConferenceMemberUnmuteEvent extends AbstractConferenceEvent {
public ConferenceMemberUnmuteEvent(Object source) {
super(source);
}
}

View File

@ -2,13 +2,13 @@ package org.bigbluebutton.webconference.voice.asterisk.konference.events;
import org.asteriskjava.manager.event.ManagerEvent; import org.asteriskjava.manager.event.ManagerEvent;
public class KonferenceMuteEvent extends ManagerEvent { public class ConferenceMuteEvent extends ManagerEvent {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private String conferenceName; private String conferenceName;
public KonferenceMuteEvent(Object source) { public ConferenceMuteEvent(Object source) {
super(source); super(source);
} }

View File

@ -1,10 +1,10 @@
package org.bigbluebutton.webconference.voice.asterisk.konference.events; package org.bigbluebutton.webconference.voice.asterisk.konference.events;
public class KonferenceSoundCompleteEvent extends AbstractKonferenceEvent { public class ConferenceSoundCompleteEvent extends AbstractConferenceEvent {
private String sound; private String sound;
public KonferenceSoundCompleteEvent(Object source) { public ConferenceSoundCompleteEvent(Object source) {
super(source); super(source);
} }

View File

@ -1,11 +1,11 @@
package org.bigbluebutton.webconference.voice.asterisk.konference.events; package org.bigbluebutton.webconference.voice.asterisk.konference.events;
public class KonferenceStateEvent extends AbstractKonferenceEvent { public class ConferenceStateEvent extends AbstractConferenceEvent {
private String flags; private String flags;
private String state; private String state;
public KonferenceStateEvent(Object source) public ConferenceStateEvent(Object source)
{ {
super(source); super(source);
} }

View File

@ -2,13 +2,13 @@ package org.bigbluebutton.webconference.voice.asterisk.konference.events;
import org.asteriskjava.manager.event.ManagerEvent; import org.asteriskjava.manager.event.ManagerEvent;
public class KonferenceUnlockEvent extends ManagerEvent { public class ConferenceUnlockEvent extends ManagerEvent {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private String conferenceName; private String conferenceName;
public KonferenceUnlockEvent(Object source) public ConferenceUnlockEvent(Object source)
{ {
super(source); super(source);
} }

View File

@ -2,13 +2,13 @@ package org.bigbluebutton.webconference.voice.asterisk.konference.events;
import org.asteriskjava.manager.event.ManagerEvent; import org.asteriskjava.manager.event.ManagerEvent;
public class KonferenceUnmuteEvent extends ManagerEvent { public class ConferenceUnmuteEvent extends ManagerEvent {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private String conferenceName; private String conferenceName;
public KonferenceUnmuteEvent(Object source) public ConferenceUnmuteEvent(Object source)
{ {
super(source); super(source);
} }

View File

@ -1,8 +0,0 @@
package org.bigbluebutton.webconference.voice.asterisk.konference.events;
public class KonferenceLockEvent extends AbstractKonferenceEvent {
public KonferenceLockEvent(Object source) {
super(source);
}
}

View File

@ -1,8 +0,0 @@
package org.bigbluebutton.webconference.voice.asterisk.konference.events;
public class KonferenceMemberMuteEvent extends AbstractKonferenceEvent {
public KonferenceMemberMuteEvent(Object source) {
super(source);
}
}

View File

@ -1,8 +0,0 @@
package org.bigbluebutton.webconference.voice.asterisk.konference.events;
public class KonferenceMemberUnmuteEvent extends AbstractKonferenceEvent {
public KonferenceMemberUnmuteEvent(Object source) {
super(source);
}
}

View File

@ -1,16 +1,32 @@
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.regex.Pattern;
import org.asteriskjava.live.ManagerCommunicationException;
import org.asteriskjava.manager.AuthenticationFailedException; import org.asteriskjava.manager.AuthenticationFailedException;
import org.asteriskjava.manager.ManagerConnection; import org.asteriskjava.manager.ManagerConnection;
import org.asteriskjava.manager.ManagerConnectionFactory; import org.asteriskjava.manager.ManagerConnectionFactory;
import org.asteriskjava.manager.ManagerEventListener; import org.asteriskjava.manager.ManagerEventListener;
import org.asteriskjava.manager.TimeoutException; import org.asteriskjava.manager.TimeoutException;
import org.asteriskjava.manager.action.CommandAction;
import org.asteriskjava.manager.action.StatusAction; import org.asteriskjava.manager.action.StatusAction;
import org.asteriskjava.manager.event.ManagerEvent; import org.asteriskjava.manager.event.ManagerEvent;
import org.asteriskjava.manager.response.CommandResponse;
import org.asteriskjava.manager.response.ManagerError;
import org.asteriskjava.manager.response.ManagerResponse;
import org.bigbluebutton.webconference.voice.asterisk.konference.events.ConferenceJoinEvent;
import org.bigbluebutton.webconference.voice.asterisk.konference.events.ConferenceLeaveEvent;
import org.bigbluebutton.webconference.voice.asterisk.konference.events.ConferenceMemberMuteEvent;
import org.bigbluebutton.webconference.voice.asterisk.konference.events.ConferenceMemberUnmuteEvent;
import org.bigbluebutton.webconference.voice.asterisk.konference.events.ConferenceStateEvent;
public class HelloEvents implements ManagerEventListener {
private static final String KONFERENCE_LIST_COMMAND = "konference list";
private static final Pattern KONFERENCE_LIST_PATTERN = Pattern.compile("^User #: ([0-9]+).*Channel: (\\S+).*$");
public class HelloEvents implements ManagerEventListener
{
private ManagerConnection managerConnection; private ManagerConnection managerConnection;
public HelloEvents() throws IOException public HelloEvents() throws IOException
@ -19,6 +35,11 @@ public class HelloEvents implements ManagerEventListener
"192.168.0.120", "bbb", "secret"); "192.168.0.120", "bbb", "secret");
this.managerConnection = factory.createManagerConnection(); this.managerConnection = factory.createManagerConnection();
managerConnection.registerUserEventClass(ConferenceJoinEvent.class);
managerConnection.registerUserEventClass(ConferenceLeaveEvent.class);
managerConnection.registerUserEventClass(ConferenceStateEvent.class);
managerConnection.registerUserEventClass(ConferenceMemberMuteEvent.class);
managerConnection.registerUserEventClass(ConferenceMemberUnmuteEvent.class);
} }
public void run() throws IOException, AuthenticationFailedException, public void run() throws IOException, AuthenticationFailedException,
@ -36,12 +57,129 @@ public class HelloEvents implements ManagerEventListener
// wait 10 seconds for events to come in // wait 10 seconds for events to come in
Thread.sleep(10000); Thread.sleep(10000);
populateRoom("85115");
// and finally log off and disconnect // and finally log off and disconnect
// managerConnection.logoff(); // managerConnection.logoff();
} }
private void populateRoom(String room) {
final CommandAction meetMeListAction;
ManagerResponse response = null;
final List<String> lines;
final Collection<Integer> userNumbers = new ArrayList<Integer>(); // list of user numbers in the room
meetMeListAction = new CommandAction(KONFERENCE_LIST_COMMAND + " " + room);
try {
response = managerConnection.sendAction(meetMeListAction);
} catch (TimeoutException e) {
System.out.println("Unable to send \"" + KONFERENCE_LIST_COMMAND + "\" command");
return;
} catch (IllegalArgumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalStateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if (response instanceof ManagerError) {
System.out.println("Unable to send \"" + KONFERENCE_LIST_COMMAND + "\" command: " + response.getMessage());
return;
}
if (!(response instanceof CommandResponse)) {
System.out.println("Response to \"" + KONFERENCE_LIST_COMMAND + "\" command is not a CommandResponse but "
+ response.getClass());
return;
}
lines = ((CommandResponse) response).getResult();
for (String line : lines) {
System.out.println(line);
/*
final Matcher matcher;
final Integer userNumber;
boolean muted = false;
boolean talking = false;
ConferenceMemberImpl channelUser;
ConferenceMemberImpl roomUser;
matcher = KONFERENCE_LIST_PATTERN.matcher(line);
if (!matcher.matches()) {
continue;
}
userNumber = Integer.valueOf(matcher.group(1));
channel = channelManager.getChannelImplByName(matcher.group(2));
userNumbers.add(userNumber);
if (line.contains("(Admin Muted)") || line.contains("(Muted)")) {
muted = true;
}
if (line.contains("(talking)")) {
talking = true;
}
channelUser = channel.getMeetMeUser();
if (channelUser != null && channelUser.getRoom() != room) {
channelUser.left(DateUtil.getDate());
channelUser = null;
}
roomUser = room.getUser(userNumber);
if (roomUser != null && roomUser.getChannel() != channel) {
room.removeUser(roomUser);
roomUser = null;
}
if (channelUser == null && roomUser == null) {
final ConferenceMemberImpl user;
// using the current date as dateJoined is not correct but we
// don't have anything that is better
user = new ConferenceMemberImpl(server, room, userNumber, channel, DateUtil.getDate());
user.setMuted(muted);
user.setTalking(talking);
room.addUser(user);
channel.setMeetMeUserImpl(user);
server.fireNewMeetMeUser(user);
} else if (channelUser != null && roomUser == null) {
channelUser.setMuted(muted);
room.addUser(channelUser);
} else if (channelUser == null) {
roomUser.setMuted(muted);
channel.setMeetMeUserImpl(roomUser);
} else {
if (channelUser != roomUser) {
logger.error("Inconsistent state: channelUser != roomUser, channelUser=" + channelUser + ", roomUser="
+ roomUser);
}
}
*/
}
/*
Collection<ConferenceMemberImpl> users = room.getUserImpls();
Collection<ConferenceMemberImpl> usersToRemove = new ArrayList<ConferenceMemberImpl>();
for (ConferenceMemberImpl user : users) {
if (!userNumbers.contains(user.getUserNumber())) {
// remove user as he is no longer in the room
usersToRemove.add(user);
}
}
for (ConferenceMemberImpl user : usersToRemove) {
user.left(DateUtil.getDate());
room.removeUser(user);
user.getChannel().setMeetMeUserImpl(null);
}
*/
}
public void onManagerEvent(ManagerEvent event) public void onManagerEvent(ManagerEvent event)
{ {
// just print received events // just print received events