Remove client when he exits meeting.

This commit is contained in:
Hugo Lazzari 2013-04-01 10:14:49 -03:00
parent fa9371ef4c
commit 9f9f3aaf0a
4 changed files with 27 additions and 13 deletions

View File

@ -64,6 +64,14 @@ public class SharedNotesApplication {
log.warn("Adding client to a non-existant room " + room);
return false;
}
public boolean removeRoomClient(String room, Long userid) {
if (roomsManager.hasRoom(room)){
roomsManager.removeRoomClient(room, userid);
return true;
}
log.warn("Removing client to a non-existant room " + room);
return false;
}
public void setRoomsManager(SharedNotesRoomsManager r) {
log.debug("Setting room manager");

View File

@ -87,6 +87,8 @@ public class SharedNotesHandler extends ApplicationAdapter implements IApplicati
@Override
public void roomDisconnect(IConnection connection) {
String room = connection.getScope().getName();
sharedNotesApplication.removeRoomClient(room, Long.parseLong(Red5.getConnectionLocal().getClient().getId()));
log.debug(APP + ":roomDisconnect");
}

View File

@ -69,29 +69,24 @@ public class SharedNotesRoom {
if (! clients.containsKey(userid)) {
synchronized (syncObject) {
clients.put(userid, new ClientSharedNotes(userid, _document));
for (Iterator<ISharedNotesRoomListener> iter = listeners.values().iterator(); iter.hasNext();) {
log.debug("calling on listener");
ISharedNotesRoomListener listener = (ISharedNotesRoomListener) iter.next();
}
}
}
}
public void removeRoomClient(Long userid) {
synchronized (syncObject) {
if (! clients.containsKey(userid)) {
clients.remove(userid);
}
}
}
public void removeRoomListener(ISharedNotesRoomListener listener) {
log.debug("removing room listener");
listeners.remove(listener);
}
private void updateDocument(String document) {
for (Iterator<ISharedNotesRoomListener> iter = listeners.values().iterator(); iter.hasNext();) {
log.debug("calling on listener");
ISharedNotesRoomListener listener = (ISharedNotesRoomListener) iter.next();
log.debug("calling updateSharedNotes on listener " + listener.getName());
//listener.updateLayout(currentLayout());
}
}
public String currentDocument(Long userid) {
String document = "";
synchronized (syncObject) {

View File

@ -84,6 +84,15 @@ public class SharedNotesRoomsManager {
log.warn("Adding client to a non-existing room " + roomName);
}
public void removeRoomClient(String roomName, Long userid) {
SharedNotesRoom r = getRoom(roomName);
if (r != null) {
r.removeRoomClient(userid);
return;
}
log.warn("Removing client to a non-existing room " + roomName);
}
public void removeRoomListener(String roomName, ISharedNotesRoomListener listener) {
SharedNotesRoom r = getRoom(roomName);
if (r != null) {