public synchronized Map screenSharerAction(Map map) {
try {
IConnection current = Red5.getConnectionLocal();
IServiceCapableConnection service = (IServiceCapableConnection) current;
RoomClient currentClient = this.clientListManager.getClientByStreamId(current.getClient().getId());
Map returnMap = new HashMap();
returnMap.put("result", "stopAll");
log.debug("----------- ");
if (currentClient != null) {
boolean stopStreaming = Boolean.valueOf(map.get("stopStreaming").toString());
boolean stopRecording = Boolean.valueOf(map.get("stopRecording").toString());
if (stopStreaming) {
log.debug("start streamPublishStart Is Screen Sharing -- Stop ");
//Notify all users of the same Scope
Collection<Set<IConnection>> conCollection = current.getScope().getConnections();
for (Set<IConnection> conset : conCollection) {
for (IConnection conn : conset) {
if (conn != null) {
if (conn instanceof IServiceCapableConnection) {
if (conn.equals(current)){
continue;
} else {
RoomClient rcl = this.clientListManager.getClientByStreamId(conn.getClient().getId());
//log.debug("is this users still alive? :"+rcl);
//Check if the Client is in the same room and same domain
if (rcl == null) {
//continue;
} else if (rcl.getIsScreenClient() != null && rcl.getIsScreenClient()) {
//continue;
} else {
IServiceCapableConnection iStream = (IServiceCapableConnection) conn;
//log.info("IServiceCapableConnection ID " + iStream.getClient().getId());
iStream.invoke("stopRed5ScreenSharing",new Object[] { currentClient }, this);
log.debug("send Notification to");
}
}
}
}
}
}
if (currentClient.isStartRecording()) {
returnMap.put("result", "stopSharingOnly");
}
currentClient.setStartStreaming(false);
currentClient.setScreenPublishStarted(false);
this.clientListManager.updateClientByStreamId(currentClient.getStreamid(), currentClient);
}
if (stopRecording) {
if (currentClient.isStartStreaming()) {
returnMap.put("result", "stopRecordingOnly");
}
//Notify all users of the same Scope
Collection<Set<IConnection>> conCollection = current.getScope().getConnections();
for (Set<IConnection> conset : conCollection) {
for (IConnection conn : conset) {
if (conn != null) {
if (conn instanceof IServiceCapableConnection) {
if (conn.equals(current)){
continue;
} else {
RoomClient rcl = this.clientListManager.getClientByStreamId(conn.getClient().getId());
//log.debug("is this users still alive? :"+rcl);
//Check if the Client is in the same room and same domain
if (rcl == null) {
//continue;
} else if (rcl.getIsScreenClient() != null && rcl.getIsScreenClient()) {
//continue;
} else {
IServiceCapableConnection iStream = (IServiceCapableConnection) conn;
//log.info("IServiceCapableConnection ID " + iStream.getClient().getId());
iStream.invoke("stopRecordingMessage",new Object[] { currentClient }, this);
log.debug("send Notification to");
}
}
}
}