You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openmeetings.apache.org by so...@apache.org on 2017/06/30 05:46:57 UTC
[1/3] openmeetings git commit: [OPENMEETINGS-1646] work with streams
refactored (incomplete)
Repository: openmeetings
Updated Branches:
refs/heads/master 417fdd64f -> 117e8d6bc
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/117e8d6b/openmeetings-web/src/main/java/org/apache/openmeetings/web/common/MainPanel.java
----------------------------------------------------------------------
diff --git a/openmeetings-web/src/main/java/org/apache/openmeetings/web/common/MainPanel.java b/openmeetings-web/src/main/java/org/apache/openmeetings/web/common/MainPanel.java
index 1527797..50afb36 100644
--- a/openmeetings-web/src/main/java/org/apache/openmeetings/web/common/MainPanel.java
+++ b/openmeetings-web/src/main/java/org/apache/openmeetings/web/common/MainPanel.java
@@ -26,8 +26,8 @@ import static org.apache.openmeetings.util.OpenmeetingsVariables.LEVEL_USER;
import static org.apache.openmeetings.util.OpenmeetingsVariables.MENU_ROOMS_NAME;
import static org.apache.openmeetings.util.OpenmeetingsVariables.webAppRootKey;
import static org.apache.openmeetings.web.app.Application.addOnlineUser;
-import static org.apache.openmeetings.web.app.Application.exit;
import static org.apache.openmeetings.web.app.Application.getBean;
+import static org.apache.openmeetings.web.app.Application.getOnlineClient;
import static org.apache.openmeetings.web.app.WebSession.getUserId;
import static org.apache.openmeetings.web.util.CallbackFunctionHelper.getNamedFunction;
import static org.apache.openmeetings.web.util.CallbackFunctionHelper.getParam;
@@ -101,7 +101,7 @@ public class MainPanel extends Panel {
private static final String DELIMITER = " ";
private static final WebMarkupContainer EMPTY = new WebMarkupContainer(CHILD_ID);
public static final String PARAM_USER_ID = "userId";
- private Client client = null;
+ private String uid = null;
private final MenuPanel menu;
private final WebMarkupContainer topControls = new WebMarkupContainer("topControls");
private final WebMarkupContainer topLinks = new WebMarkupContainer("topLinks");
@@ -116,7 +116,7 @@ public class MainPanel extends Panel {
@Override
protected void onTimer(AjaxRequestTarget target) {
log.debug("Sending WebSocket PING");
- WebSocketHelper.sendClient(client, new byte[]{getUserId().byteValue()});
+ WebSocketHelper.sendClient(getClient(), new byte[]{getUserId().byteValue()});
}
};
@@ -150,7 +150,7 @@ public class MainPanel extends Panel {
protected void onInitialize() {
super.onInitialize();
add(topControls.setOutputMarkupPlaceholderTag(true).setMarkupId("topControls"));
- add(contents.add(client == null ? EMPTY : panel).setOutputMarkupId(true).setMarkupId("contents"));
+ add(contents.add(getClient() == null ? EMPTY : panel).setOutputMarkupId(true).setMarkupId("contents"));
topControls.add(menu.setVisible(false), topLinks.setVisible(false).setOutputMarkupPlaceholderTag(true).setMarkupId("topLinks"));
topLinks.add(new AjaxLink<Void>("messages") {
private static final long serialVersionUID = 1L;
@@ -242,7 +242,8 @@ public class MainPanel extends Panel {
protected void onConnect(ConnectedMessage msg) {
super.onConnect(msg);
ExtendedClientProperties cp = WebSession.get().getExtendedProperties();
- client = new Client(getSession().getId(), msg.getKey().hashCode(), getUserId(), getBean(UserDao.class));
+ final Client client = new Client(getSession().getId(), msg.getKey().hashCode(), getUserId(), getBean(UserDao.class));
+ uid = client.getUid();
addOnlineUser(cp.update(client));
log.debug("WebSocketBehavior::onConnect [uid: {}, session: {}, key: {}]", client.getUid(), msg.getSessionId(), msg.getKey());
}
@@ -278,10 +279,10 @@ public class MainPanel extends Panel {
private void closeHandler(AbstractClientMessage msg) {
//no chance to stop pingTimer here :(
- if (client != null) {
- log.debug("WebSocketBehavior::closeHandler [uid: {}, session: {}, key: {}]", client.getUid(), msg.getSessionId(), msg.getKey());
- exit(client);
- client = null;
+ if (uid != null) {
+ log.debug("WebSocketBehavior::closeHandler [uid: {}, session: {}, key: {}]", uid, msg.getSessionId(), msg.getKey());
+ Application.get().exit(uid);
+ uid = null;
}
}
});
@@ -343,7 +344,7 @@ public class MainPanel extends Panel {
public void updateContents(OmUrlFragment f, IPartialPageRequestHandler handler, boolean updateFragment) {
BasePanel panel = getPanel(f.getArea(), f.getType());
if (panel != null) {
- if (client != null) {
+ if (getClient() != null) {
updateContents(panel, handler);
} else {
this.panel = panel;
@@ -383,6 +384,6 @@ public class MainPanel extends Panel {
}
public Client getClient() {
- return client;
+ return getOnlineClient(uid);
}
}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/117e8d6b/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/RoomBroadcaster.java
----------------------------------------------------------------------
diff --git a/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/RoomBroadcaster.java b/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/RoomBroadcaster.java
index d9e203e..c0af7b7 100644
--- a/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/RoomBroadcaster.java
+++ b/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/RoomBroadcaster.java
@@ -24,6 +24,7 @@ import static org.apache.openmeetings.web.app.Application.getBean;
import org.apache.openmeetings.core.remote.ScopeApplicationAdapter;
import org.apache.openmeetings.core.session.SessionManager;
import org.apache.openmeetings.db.dto.server.ClientSessionInfo;
+import org.apache.openmeetings.db.entity.basic.Client;
import org.apache.openmeetings.db.entity.room.StreamClient;
import org.apache.openmeetings.web.app.Application;
import org.red5.logging.Red5LoggerFactory;
@@ -33,7 +34,7 @@ public class RoomBroadcaster {
private static final Logger log = Red5LoggerFactory.getLogger(RoomBroadcaster.class, webAppRootKey);
public static StreamClient getClient(String publicSid) {
- ClientSessionInfo csi = getBean(SessionManager.class).getClientByPublicSIDAnyServer(publicSid);
+ ClientSessionInfo csi = getBean(SessionManager.class).getClientByUidAnyServer(publicSid);
return csi == null ? null : csi.getRcl();
}
@@ -50,8 +51,9 @@ public class RoomBroadcaster {
sa.sendToScope(roomId, method, obj);
}
- public static void sendUpdatedClient(org.apache.openmeetings.db.entity.basic.Client client) {
- StreamClient rcl = Application.get().updateClient(getClient(client.getUid()), true);
+ public static void sendUpdatedClient(Client client) {
+ String uid = client.getUid();
+ StreamClient rcl = Application.get().updateClient(getClient(uid), true);
log.debug("----------- sendUpdatedClient ");
if (rcl == null) {
@@ -59,7 +61,7 @@ public class RoomBroadcaster {
}
// Put the mod-flag to true for this client
- getBean(SessionManager.class).updateClientByStreamId(rcl.getStreamid(), rcl, false, null);
+ getBean(SessionManager.class).update(rcl);
// Notify all clients of the same scope (room)
broadcast(client.getRoomId(), "clientUpdated", rcl);
}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/117e8d6b/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/RoomPanel.java
----------------------------------------------------------------------
diff --git a/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/RoomPanel.java b/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/RoomPanel.java
index 8ee4ca9..4ff3dc6 100644
--- a/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/RoomPanel.java
+++ b/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/RoomPanel.java
@@ -22,10 +22,10 @@ import static org.apache.openmeetings.util.OpenmeetingsVariables.webAppRootKey;
import static org.apache.openmeetings.web.app.Application.addUserToRoom;
import static org.apache.openmeetings.web.app.Application.exitRoom;
import static org.apache.openmeetings.web.app.Application.getBean;
+import static org.apache.openmeetings.web.app.Application.getClientBySid;
import static org.apache.openmeetings.web.app.Application.getOnlineClient;
import static org.apache.openmeetings.web.app.Application.getRoomClients;
import static org.apache.openmeetings.web.app.WebSession.getDateFormat;
-import static org.apache.openmeetings.web.app.WebSession.getSid;
import static org.apache.openmeetings.web.app.WebSession.getUserId;
import java.util.Calendar;
@@ -158,13 +158,10 @@ public class RoomPanel extends BasePanel {
StringBuilder sb = new StringBuilder();
for (Client c: getRoomClients(getRoom().getId()) ) {
boolean self = getClient().getUid().equals(c.getUid());
- if (c.hasAnyActivity(Client.Activity.broadcastA, Client.Activity.broadcastV)) {
- sb.append(String.format("VideoManager.play(%s);"
- , RoomHelper.videoJson(c, self, getSid(), getBean(ISessionManager.class), false)));
- }
- if (c.hasActivity(Client.Activity.share)) {
- sb.append(String.format("VideoManager.play(%s);"
- , RoomHelper.videoJson(c, self, getSid(), getBean(ISessionManager.class), true)));
+ for (Client.Stream s : c.getStreams()) {
+ JSONObject jo = RoomHelper.videoJson(c, self, c.getSid(), getBean(ISessionManager.class), s.getStreamClientId(), s.isSharing())
+ .put("broadcastId", s.getBroadcastId());
+ sb.append(String.format("VideoManager.play(%s);", jo));
}
}
if (!Strings.isEmpty(sb)) {
@@ -338,7 +335,7 @@ public class RoomPanel extends BasePanel {
case recordingStoped:
{
String uid = ((TextRoomMessage)m).getText();
- Client c = getOnlineClient(uid);
+ Client c = getClientBySid(uid);
if (c == null) {
log.error("Not existing/BAD user has stopped recording {} != {} !!!!", uid);
return;
@@ -351,7 +348,7 @@ public class RoomPanel extends BasePanel {
case recordingStarted:
{
String uid = ((TextRoomMessage)m).getText();
- Client c = getOnlineClient(uid);
+ Client c = getClientBySid(uid);
if (c == null) {
log.error("Not existing user has started recording {} !!!!", uid);
return;
@@ -363,12 +360,13 @@ public class RoomPanel extends BasePanel {
break;
case sharingStoped:
{
- String uid = ((TextRoomMessage)m).getText();
- Client c = getOnlineClient(uid);
+ JSONObject obj = new JSONObject(((TextRoomMessage)m).getText());
+ Client c = getClientBySid(obj.getString("ownerSid"));
if (c == null) {
- log.error("Not existing user has started sharing {} !!!!", uid);
+ log.error("Not existing user has started sharing {} !!!!", obj);
return;
}
+ handler.appendJavaScript(String.format("VideoManager.close('%s', true);", obj.getString("uid")));
sharingUser = null;
c.remove(Client.Activity.share);
menu.update(handler);
@@ -389,9 +387,14 @@ public class RoomPanel extends BasePanel {
break;
case rightUpdated:
{
- Client c = getOnlineClient(((TextRoomMessage)m).getText());
+ String uid = ((TextRoomMessage)m).getText();
+ Client c = getOnlineClient(uid);
+ if (c == null) {
+ log.error("Not existing user in rightUpdated {} !!!!", uid);
+ return;
+ }
handler.appendJavaScript(String.format("VideoManager.update(%s);"
- , c.toJson(getClient().getUid().equals(c.getUid())).put("sid", getSid())));
+ , c.toJson(getClient().getUid().equals(c.getUid())).put("sid", getClient().getSid())));
sidebar.update(handler);
menu.update(handler);
wb.update(handler);
@@ -400,12 +403,26 @@ public class RoomPanel extends BasePanel {
case newStream:
{
JSONObject obj = new JSONObject(((TextRoomMessage)m).getText());
- Client c = getOnlineClient(obj.getString("uid"));
- c.setBroadcastId(obj.getString("stream"));
+ boolean share = obj.optBoolean("screenShare", false);
+ String uid = obj.getString("uid");
+ Client c = getOnlineClient(uid);
+ if (c == null) {
+ // screen client, ext video stream ??
+ c = getClientBySid(obj.getString("ownerSid"));
+ }
+ if (c == null) {
+ log.error("Not existing user in newStream {} !!!!", uid);
+ return;
+ }
boolean self = getClient().getUid().equals(c.getUid());
+ String broadcastId = obj.getString("stream");
+ Long streamClientId = obj.getLong("streamClientId");
if (!self) {
- handler.appendJavaScript(String.format("VideoManager.play(%s);"
- , RoomHelper.videoJson(c, self, getSid(), getBean(ISessionManager.class), obj.optBoolean("screenShare", false))));
+ JSONObject jo = RoomHelper.videoJson(c, uid, self, c.getSid(), getBean(ISessionManager.class), streamClientId, share)
+ .put("broadcastId", broadcastId);
+ handler.appendJavaScript(String.format("VideoManager.play(%s);", jo));
+ } else {
+ c.addStream(streamClientId, broadcastId, share);
}
}
break;
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/117e8d6b/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/VideoSettings.java
----------------------------------------------------------------------
diff --git a/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/VideoSettings.java b/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/VideoSettings.java
index 94abced..d7666c7 100644
--- a/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/VideoSettings.java
+++ b/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/VideoSettings.java
@@ -29,9 +29,7 @@ import static org.apache.openmeetings.web.app.Application.getBean;
import java.net.URL;
-import org.apache.directory.api.util.Strings;
import org.apache.openmeetings.core.remote.ScopeApplicationAdapter;
-import org.apache.openmeetings.web.app.WebSession;
import org.apache.openmeetings.web.util.ExtendedClientProperties;
import org.apache.wicket.markup.head.IHeaderResponse;
import org.apache.wicket.markup.head.JavaScriptHeaderItem;
@@ -65,16 +63,13 @@ public class VideoSettings extends Panel {
return String.format("%s://%s:%s/%s", protocol, host, port, app);
}
- public static JSONObject getInitJson(ExtendedClientProperties cp, String scope, String uid) {
+ public static JSONObject getInitJson(ExtendedClientProperties cp, String scope, String sid) {
JSONObject gs = getBean(ScopeApplicationAdapter.class).getFlashSettings();
JSONObject s = new JSONObject()
.put(FLASH_VIDEO_CODEC, gs.get(FLASH_VIDEO_CODEC))
.put(FLASH_FPS, gs.get(FLASH_FPS))
- .put("sid", WebSession.getSid())
+ .put("sid", sid)
.put("wmode", cp.isBrowserInternetExplorer() && cp.getBrowserVersionMajor() == 11 ? "opaque" : "direct");
- if (!Strings.isEmpty(uid)) {
- s.put("uid", uid);
- }
try {
URL url = new URL(cp.getCodebase());
String path = url.getPath();
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/117e8d6b/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/menu/RoomMenuPanel.java
----------------------------------------------------------------------
diff --git a/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/menu/RoomMenuPanel.java b/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/menu/RoomMenuPanel.java
index bdb1ea8..ff7891f 100644
--- a/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/menu/RoomMenuPanel.java
+++ b/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/menu/RoomMenuPanel.java
@@ -301,13 +301,13 @@ public class RoomMenuPanel extends Panel {
StringBuilder roomTitle = new StringBuilder();
if (room.getRecordingUser() != null) {
ISessionManager sessMngr = getBean(ISessionManager.class);
- StreamClient recUser = sessMngr.getClientByPublicSID(room.getRecordingUser(), null); //TODO check server
+ StreamClient recUser = sessMngr.getClientByUid(room.getRecordingUser(), null); //TODO check server
if (recUser != null) {
roomTitle.append(String.format("%s %s %s %s %s", getString("419")
, recUser.getUsername(), recUser.getFirstname(), recUser.getLastname(), df.format(recUser.getConnectedSince())));
roomClass.append(" screen");
}
- StreamClient pubUser = sessMngr.getClientByPublicSID(room.getPublishingUser(), null); //TODO check server
+ StreamClient pubUser = sessMngr.getClientByUid(room.getPublishingUser(), null); //TODO check server
if (pubUser != null) {
if (recUser != null) {
roomTitle.append('\n');
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/117e8d6b/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/menu/StartSharingButton.java
----------------------------------------------------------------------
diff --git a/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/menu/StartSharingButton.java b/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/menu/StartSharingButton.java
index bc0744d..3f935a6 100644
--- a/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/menu/StartSharingButton.java
+++ b/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/menu/StartSharingButton.java
@@ -91,8 +91,8 @@ public class StartSharingButton extends OmButton {
try (InputStream jnlp = getClass().getClassLoader().getResourceAsStream("APPLICATION.jnlp")) {
ConfigurationDao cfgDao = getBean(ConfigurationDao.class);
app = IOUtils.toString(jnlp, UTF_8);
- String publicSid = c.getUid();
- JSONObject s = VideoSettings.getInitJson(WebSession.get().getExtendedProperties(), "" + c.getRoomId(), publicSid);
+ String sid = c.getSid();
+ JSONObject s = VideoSettings.getInitJson(WebSession.get().getExtendedProperties(), "" + c.getRoomId(), sid);
String _url = s.getString(VideoSettings.URL);
long roomId = c.getRoomId();
Room room = getBean(RoomDao.class).get(roomId);
@@ -102,7 +102,7 @@ public class StartSharingButton extends OmButton {
.replace("$applicationName", cfgDao.getAppName())
.replace("$url", _url)
.replace("$fallback", s.getString(VideoSettings.FALLBACK))
- .replace("$publicSid", publicSid)
+ .replace("$sid", sid)
.replace("$labels", getLabels(730, 731, 732, 733, 734
, 735, 737, 738, 739, 740
, 741, 742, 844, 869, 870
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/117e8d6b/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/room.js
----------------------------------------------------------------------
diff --git a/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/room.js b/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/room.js
index 7db4666..c076069 100644
--- a/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/room.js
+++ b/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/room.js
@@ -16,6 +16,18 @@
* specific language governing permissions and limitations
* under the License.
*/
+var VideoUtil = (function() {
+ var self = {};
+ function _getVid(uid) {
+ return "video" + uid;
+ }
+ function _getShareVid(uid) {
+ return "video-share" + uid;
+ }
+ self.getVid = _getVid;
+ self.getShareVid = _getShareVid;
+ return self;
+})();
var Video = (function() {
var self = {}, c, box, v, vc, t, swf, size;
@@ -35,7 +47,8 @@ var Video = (function() {
c = _c;
box = _box;
size = {width: c.width, height: c.height};
- var _id = "video" + c.uid, name = _getName()
+ var _id = !!c.screenShare ? VideoUtil.getShareVid(c.uid) : VideoUtil.getVid(c.uid)
+ , name = _getName()
, _w = c.self ? Math.max(300, c.width) : c.width
, _h = c.self ? Math.max(200, c.height) : c.height;
box.append($('#user-video').clone().attr('id', _id).attr('title', name).data(self));
@@ -106,6 +119,7 @@ var Video = (function() {
o.width = c.width;
o.height = c.height;
o.sid = c.sid;
+ o.uid = c.uid;
o.broadcastId = c.broadcastId;
swf = initVideo(vc, _id + '-swf', o);
swf.attr('width', _w).attr('height', _h);
@@ -130,11 +144,8 @@ var VideoManager = (function() {
box = $('.room.box');
share = box.find('.icon.shared.ui-button');
}
- function _getVid(uid) {
- return "video" + uid;
- }
function _update(c) {
- var _id = _getVid(c.uid)
+ var _id = VideoUtil.getVid(c.uid)
, video = c.activities.indexOf('broadcastV') > -1
, audio = c.activities.indexOf('broadcastA') > -1
, av = audio || video
@@ -156,8 +167,8 @@ var VideoManager = (function() {
function _play(c) {
if (!!c.screenShare) {
_highlight(share.attr('title', share.data('user') + ' ' + c.user.firstName + ' ' + c.user.lastName + ' ' + share.data('text')).show(), 10);
- share.tooltip().click(function() {
- var v = $('#' + _getVid(c.uid))
+ share.tooltip().off('click').click(function() {
+ var v = $('#' + VideoUtil.getShareVid(c.uid))
if (v.length != 1) {
Video().init(box, options.uid, c);
} else {
@@ -168,8 +179,9 @@ var VideoManager = (function() {
Video().init(box, options.uid, c);
}
}
- function _close(uid) {
- var _id = _getVid(uid), v = $('#' + _id);
+ function _close(uid, screenShare) {
+ var _id = !!screenShare ? VideoUtil.getShareVid(uid) : VideoUtil.getVid(uid)
+ , v = $('#' + _id);
if (v.length == 1) {
if (v.data().client().screenShare) {
share.off('click').hide();
@@ -193,7 +205,7 @@ var VideoManager = (function() {
self.update = _update;
self.play = _play;
self.close = _close;
- self.resetSize = function(uid) { $('#' + _getVid(uid)).data().resetSize(); };
+ self.resetSize = function(uid) { $('#' + VideoUtil.getVid(uid)).data().resetSize(); };
return self;
})();
function setRoomSizes() {
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/117e8d6b/openmeetings-web/src/main/webapp/WEB-INF/classes/applicationContext.xml
----------------------------------------------------------------------
diff --git a/openmeetings-web/src/main/webapp/WEB-INF/classes/applicationContext.xml b/openmeetings-web/src/main/webapp/WEB-INF/classes/applicationContext.xml
index 99674d6..0a6729a 100644
--- a/openmeetings-web/src/main/webapp/WEB-INF/classes/applicationContext.xml
+++ b/openmeetings-web/src/main/webapp/WEB-INF/classes/applicationContext.xml
@@ -75,7 +75,6 @@
<!-- Start of Services -->
<bean id="xmlcrm.service" class="org.apache.openmeetings.core.remote.MainService" />
- <bean id="userservice.service" class="org.apache.openmeetings.core.remote.UserService" />
<bean id="fileservice.service" class="org.apache.openmeetings.core.remote.ConferenceLibrary" />
<bean id="openmeetings.FileProcessor" class="org.apache.openmeetings.core.data.file.FileProcessor" />
<bean id="openmeetings.FlvExplorerConverter" class="org.apache.openmeetings.core.converter.FlvExplorerConverter" />
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/117e8d6b/openmeetings-web/src/main/webapp/WEB-INF/classes/logback-config.xml
----------------------------------------------------------------------
diff --git a/openmeetings-web/src/main/webapp/WEB-INF/classes/logback-config.xml b/openmeetings-web/src/main/webapp/WEB-INF/classes/logback-config.xml
index f173c2a..1009f39 100644
--- a/openmeetings-web/src/main/webapp/WEB-INF/classes/logback-config.xml
+++ b/openmeetings-web/src/main/webapp/WEB-INF/classes/logback-config.xml
@@ -48,7 +48,7 @@
</appender>
<appender name="CONSOLE2" class="ch.qos.logback.core.ConsoleAppender">
<layout class="ch.qos.logback.classic.PatternLayout">
- <pattern>%5p %d{MM-dd HH:mm:ss.SSS } %F %r %L %c [%t] - %m%n</pattern>
+ <pattern>%5p %d{MM-dd HH:mm:ss.SSS } %r %L %c{15} [%t] - %m%n</pattern>
</layout>
</appender>
<logger name="com.mchange.v2" level="ERROR" />
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/117e8d6b/openmeetings-web/src/test/java/org/apache/openmeetings/test/poll/TestClientListManager.java
----------------------------------------------------------------------
diff --git a/openmeetings-web/src/test/java/org/apache/openmeetings/test/poll/TestClientListManager.java b/openmeetings-web/src/test/java/org/apache/openmeetings/test/poll/TestClientListManager.java
deleted file mode 100644
index c5e1b36..0000000
--- a/openmeetings-web/src/test/java/org/apache/openmeetings/test/poll/TestClientListManager.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License") + you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.openmeetings.test.poll;
-
-import static org.junit.Assert.assertNotNull;
-
-import java.util.Random;
-
-import org.apache.openmeetings.db.dao.server.ISessionManager;
-import org.apache.openmeetings.test.AbstractJUnitDefaults;
-import org.junit.Test;
-import org.springframework.beans.factory.annotation.Autowired;
-
-public class TestClientListManager extends AbstractJUnitDefaults {
- @Autowired
- private ISessionManager sessionManager;
-
- @Test
- public void addClientListItem() {
- Random rnd = new Random();
- assertNotNull("RoomClientId created is null",
- sessionManager.addClientListItem(rnd.nextLong() + "ABCDE"
- + rnd.nextLong(), "scopeName", 66666, "remoteAddress",
- "swfUrl", null));
- }
-
-}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/117e8d6b/openmeetings-web/src/test/java/org/apache/openmeetings/test/session/TestDbSession.java
----------------------------------------------------------------------
diff --git a/openmeetings-web/src/test/java/org/apache/openmeetings/test/session/TestDbSession.java b/openmeetings-web/src/test/java/org/apache/openmeetings/test/session/TestDbSession.java
index 6963911..ccd01d5 100644
--- a/openmeetings-web/src/test/java/org/apache/openmeetings/test/session/TestDbSession.java
+++ b/openmeetings-web/src/test/java/org/apache/openmeetings/test/session/TestDbSession.java
@@ -18,6 +18,7 @@
*/
package org.apache.openmeetings.test.session;
+import static org.apache.openmeetings.util.OpenmeetingsVariables.webAppRootKey;
import static org.junit.Assert.assertEquals;
import java.util.List;
@@ -27,7 +28,6 @@ import org.apache.openmeetings.db.dao.server.ServerDao;
import org.apache.openmeetings.db.entity.room.StreamClient;
import org.apache.openmeetings.db.entity.server.Server;
import org.apache.openmeetings.test.AbstractJUnitDefaults;
-import static org.apache.openmeetings.util.OpenmeetingsVariables.webAppRootKey;
import org.junit.Test;
import org.red5.logging.Red5LoggerFactory;
import org.slf4j.Logger;
@@ -45,7 +45,7 @@ public class TestDbSession extends AbstractJUnitDefaults {
@Test
public void testDbSessionFunctions() {
clientDao.cleanAllClients();
-
+
List<Server> serverList = serverDao.getActiveServers();
Server server = null;
@@ -59,132 +59,93 @@ public class TestDbSession extends AbstractJUnitDefaults {
}
StreamClient cl1 = new StreamClient();
- cl1.setStreamid("1");
cl1.setServer(null);
cl1.setUserId(1L);
- cl1.setRoomId(1L);
- cl1.setPublicSID("public1");
+ cl1.setScope("1");
+ cl1.setUid("public1");
clientDao.add(cl1);
StreamClient cl2 = new StreamClient();
- cl2.setStreamid("2");
cl2.setServer(null);
- cl2.setRoomId(1L);
+ cl2.setScope("1");
cl2.setUserId(2L);
- cl2.setPublicSID("public2");
+ cl2.setUid("public2");
clientDao.add(cl2);
StreamClient cl3 = new StreamClient();
- cl3.setStreamid("3");
cl3.setServer(server);
- cl3.setRoomId(3L);
+ cl3.setScope("3");
cl3.setUserId(3L);
- cl3.setPublicSID("public3");
+ cl3.setUid("public3");
clientDao.add(cl3);
-
- StreamClient clTest = clientDao.getClientByServerAndStreamId(null, "1");
-
- log.debug("cl1 " + cl1);
- log.debug("clTest " + clTest);
-
- assertEquals(clTest.getId(), cl1.getId());
-
- StreamClient clTest3 = clientDao.getClientByServerAndStreamId(server, "3");
-
- log.debug("cl3 " + cl3);
- log.debug("clTest3 " + clTest3);
-
- assertEquals(clTest3.getId(), cl3.getId());
- StreamClient clTest_NOT_3 = clientDao.getClientByServerAndStreamId(null, "3");
-
- log.debug("clTest_NOT_3 " + clTest_NOT_3);
- assertEquals(null, clTest_NOT_3);
-
- long numberOfClients1 = clientDao.countClientsByServerAndStreamId(null, "1");
- assertEquals(1, numberOfClients1);
-
- long numberOfClients3 = clientDao.countClientsByServerAndStreamId(server, "3");
- assertEquals(1, numberOfClients3);
-
- long numberOfClients4 = clientDao.countClientsByServerAndStreamId(null, "3");
- assertEquals(0, numberOfClients4);
-
- List<StreamClient> clTest_Pub_1_list = clientDao.getClientsByPublicSIDAndServer(null, "public1");
+ List<StreamClient> clTest_Pub_1_list = clientDao.getClientsByUidAndServer(null, "public1");
assertEquals(cl1.getId(), clTest_Pub_1_list.get(0).getId());
-
- List<StreamClient> clTest_Pub_3_list = clientDao.getClientsByPublicSIDAndServer(server, "public3");
+
+ List<StreamClient> clTest_Pub_3_list = clientDao.getClientsByUidAndServer(server, "public3");
assertEquals(cl3.getId(), clTest_Pub_3_list.get(0).getId());
-
- List<StreamClient> clTest_Fail_list = clientDao.getClientsByPublicSIDAndServer(null, "public3");
+
+ List<StreamClient> clTest_Fail_list = clientDao.getClientsByUidAndServer(null, "public3");
assertEquals(0, clTest_Fail_list.size());
-
- List<StreamClient> clTest_PubAll_1_list = clientDao.getClientsByPublicSID("public1");
+
+ List<StreamClient> clTest_PubAll_1_list = clientDao.getClientsByUid("public1");
assertEquals(cl1.getId(), clTest_PubAll_1_list.get(0).getId());
-
- List<StreamClient> clTest_PubAll_3_list = clientDao.getClientsByPublicSID("public3");
+
+ List<StreamClient> clTest_PubAll_3_list = clientDao.getClientsByUid("public3");
assertEquals(cl3.getId(), clTest_PubAll_3_list.get(0).getId());
-
- List<StreamClient> clTest_FailAll_list = clientDao.getClientsByPublicSID("public4");
+
+ List<StreamClient> clTest_FailAll_list = clientDao.getClientsByUid("public4");
assertEquals(0, clTest_FailAll_list.size());
-
+
List<StreamClient> clientsByServerNull = clientDao.getClientsByServer(null);
assertEquals(2, clientsByServerNull.size());
-
+
List<StreamClient> clientsByServer = clientDao.getClientsByServer(server);
assertEquals(1, clientsByServer.size());
-
+
List<StreamClient> clientsAll = clientDao.getClients();
assertEquals(3, clientsAll.size());
-
+
//by userid
List<StreamClient> clTest_User_1_list = clientDao.getClientsByUserId(null, 1L);
assertEquals(cl1.getId(), clTest_User_1_list.get(0).getId());
-
+
List<StreamClient> clTest_User_3_list = clientDao.getClientsByUserId(server, 3L);
assertEquals(cl3.getId(), clTest_User_3_list.get(0).getId());
-
+
List<StreamClient> clTest_UserFail_list = clientDao.getClientsByUserId(null, 3L);
assertEquals(0, clTest_UserFail_list.size());
-
+
//by roomid
List<StreamClient> clTest_Room_1_list = clientDao.getClientsByRoomId(1L);
assertEquals(2, clTest_Room_1_list.size());
-
+
List<StreamClient> clTest_Room_3_list = clientDao.getClientsByRoomId(3L);
assertEquals(cl3.getId(), clTest_Room_3_list.get(0).getId());
-
+
List<StreamClient> clTest_RoomFail_list = clientDao.getClientsByRoomId(2L);
assertEquals(0, clTest_RoomFail_list.size());
-
+
//count all
int countAll = clientDao.countClients();
assertEquals(3, countAll);
-
+
//count by server
int clTest_Count_1_list = clientDao.countClientsByServer(null);
assertEquals(2, clTest_Count_1_list);
-
+
int clTest_Count_3_list = clientDao.countClientsByServer(server);
assertEquals(1, clTest_Count_3_list);
-
+
//remove by id
clientDao.delete(cl1);
-
+
int clTest_Count_Delete_list = clientDao.countClientsByServer(null);
assertEquals(1, clTest_Count_Delete_list);
-
- //remove by server and streamid
- clientDao.removeClientByServerAndStreamId(null, "2");
-
- clTest_Count_Delete_list = clientDao.countClientsByServer(null);
- assertEquals(0, clTest_Count_Delete_list);
-
- clientDao.removeClientByServerAndStreamId(server, "3");
-
+
clTest_Count_Delete_list = clientDao.countClientsByServer(server);
assertEquals(0, clTest_Count_Delete_list);
-
+
//delete all
clientDao.cleanAllClients();
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/117e8d6b/openmeetings-web/src/test/java/org/apache/openmeetings/test/session/TestDbSessionGetRoomIds.java
----------------------------------------------------------------------
diff --git a/openmeetings-web/src/test/java/org/apache/openmeetings/test/session/TestDbSessionGetRoomIds.java b/openmeetings-web/src/test/java/org/apache/openmeetings/test/session/TestDbSessionGetRoomIds.java
index 946e15c..3225508 100644
--- a/openmeetings-web/src/test/java/org/apache/openmeetings/test/session/TestDbSessionGetRoomIds.java
+++ b/openmeetings-web/src/test/java/org/apache/openmeetings/test/session/TestDbSessionGetRoomIds.java
@@ -18,6 +18,7 @@
*/
package org.apache.openmeetings.test.session;
+import static org.apache.openmeetings.util.OpenmeetingsVariables.webAppRootKey;
import static org.junit.Assert.assertEquals;
import java.util.List;
@@ -27,7 +28,6 @@ import org.apache.openmeetings.db.dao.server.ServerDao;
import org.apache.openmeetings.db.entity.room.StreamClient;
import org.apache.openmeetings.db.entity.server.Server;
import org.apache.openmeetings.test.AbstractJUnitDefaults;
-import static org.apache.openmeetings.util.OpenmeetingsVariables.webAppRootKey;
import org.junit.Test;
import org.red5.logging.Red5LoggerFactory;
import org.slf4j.Logger;
@@ -45,7 +45,7 @@ public class TestDbSessionGetRoomIds extends AbstractJUnitDefaults {
@Test
public void testDbSessionFunctions() {
clientDao.cleanAllClients();
-
+
List<Server> serverList = serverDao.getActiveServers();
Server server = null;
@@ -59,33 +59,30 @@ public class TestDbSessionGetRoomIds extends AbstractJUnitDefaults {
}
StreamClient cl1 = new StreamClient();
- cl1.setStreamid("1");
cl1.setServer(server);
cl1.setUserId(1L);
- cl1.setRoomId(1L);
- cl1.setPublicSID("public1");
+ cl1.setScope("1");
+ cl1.setUid("public1");
clientDao.add(cl1);
StreamClient cl2 = new StreamClient();
- cl2.setStreamid("2");
cl2.setServer(server);
- cl2.setRoomId(1L);
+ cl2.setScope("1");
cl2.setUserId(2L);
- cl2.setPublicSID("public2");
+ cl2.setUid("public2");
clientDao.add(cl2);
StreamClient cl3 = new StreamClient();
- cl3.setStreamid("3");
cl3.setServer(server);
- cl3.setRoomId(3L);
+ cl3.setScope("3");
cl3.setUserId(3L);
- cl3.setPublicSID("public3");
+ cl3.setUid("public3");
clientDao.add(cl3);
-
+
List<Long> roomids = clientDao.getRoomsIdsByServer(server);
assertEquals(2, roomids.size());
-
+
//delete all
clientDao.cleanAllClients();
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/117e8d6b/openmeetings-web/src/test/java/org/apache/openmeetings/test/session/TestHashMapSession.java
----------------------------------------------------------------------
diff --git a/openmeetings-web/src/test/java/org/apache/openmeetings/test/session/TestHashMapSession.java b/openmeetings-web/src/test/java/org/apache/openmeetings/test/session/TestHashMapSession.java
index 4a50e47..58024a3 100644
--- a/openmeetings-web/src/test/java/org/apache/openmeetings/test/session/TestHashMapSession.java
+++ b/openmeetings-web/src/test/java/org/apache/openmeetings/test/session/TestHashMapSession.java
@@ -18,74 +18,56 @@
*/
package org.apache.openmeetings.test.session;
+import static org.apache.openmeetings.util.OpenmeetingsVariables.webAppRootKey;
import static org.junit.Assert.assertEquals;
-import java.math.BigInteger;
import java.util.Arrays;
import java.util.Date;
-import java.util.Random;
+import java.util.UUID;
import org.apache.openmeetings.core.session.store.HashMapStore;
import org.apache.openmeetings.core.session.store.IClientPersistenceStore;
import org.apache.openmeetings.db.entity.room.StreamClient;
import org.apache.openmeetings.test.AbstractJUnitDefaults;
-import org.apache.openmeetings.util.OpenmeetingsVariables;
-import org.apache.openmeetings.util.crypt.CryptProvider;
import org.junit.Test;
import org.red5.logging.Red5LoggerFactory;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
public class TestHashMapSession extends AbstractJUnitDefaults {
-
- protected static final Logger log = Red5LoggerFactory.getLogger(
- TestHashMapSession.class, OpenmeetingsVariables.webAppRootKey);
-
+ protected static final Logger log = Red5LoggerFactory.getLogger(TestHashMapSession.class, webAppRootKey);
+
@Autowired
private HashMapStore cache;
-
+
@Test
public void testHashMapSession() {
-
//make sure the cache is empty before starting the test
cache.clear();
-
- for (int i=0;i<20;i++) {
-
- String streamId = ""+i;
-
+
+ for (int i = 0; i < 20; i++) {
+ Long id = (long)i;
+
StreamClient rcm = new StreamClient();
+ rcm.setId(id);
rcm.setConnectedSince(new Date());
- rcm.setStreamid(streamId);
rcm.setScope("scopeName");
- long random = System.currentTimeMillis() + new BigInteger(256, new Random()).longValue();
-
- rcm.setPublicSID(CryptProvider.get().hash(String.valueOf(random).toString()));
+
+ rcm.setUid(UUID.randomUUID().toString());
rcm.setUserport(0);
rcm.setUserip("remoteAddress");
rcm.setSwfurl("swfUrl");
- rcm.setIsMod(false);
- rcm.setCanDraw(false);
+ rcm.setMod(false);
- if (cache.containsKey(null, streamId)) {
- log.error("Tried to add an existing Client " + streamId);
+ if (cache.containsKey(id)) {
+ log.error("Tried to add an existing Client " + id);
break;
}
-
- cache.put(rcm.getStreamid(), rcm);
-
- cache.remove(null, streamId);
-
+ cache.remove(id);
}
-
String logString = cache.getDebugInformation(Arrays.asList(IClientPersistenceStore.DEBUG_DETAILS.SIZE));
-
-
log.debug("######## \n\r "+ logString + " \n\r ########");
-
assertEquals(0, cache.size());
-
}
-
}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/117e8d6b/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/RoomWebService.java
----------------------------------------------------------------------
diff --git a/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/RoomWebService.java b/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/RoomWebService.java
index adcfce6..e9b707d 100644
--- a/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/RoomWebService.java
+++ b/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/RoomWebService.java
@@ -396,7 +396,7 @@ public class RoomWebService {
try {
Sessiondata sd = sessionDao.check(sid);
if (AuthLevelUtil.hasWebServiceLevel(userDao.getRights(sd.getUserId()))) {
- boolean result = userManager.kickUserByStreamId(sid, id);
+ boolean result = userManager.kickUsersByRoomId(id);
return new ServiceResult(result ? 1L : 0L, "Kicked", Type.SUCCESS);
} else {
throw new ServiceException("Insufficient permissions"); //TODO code -26
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/117e8d6b/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/UserWebService.java
----------------------------------------------------------------------
diff --git a/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/UserWebService.java b/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/UserWebService.java
index 814f5d1..0979a11 100644
--- a/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/UserWebService.java
+++ b/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/UserWebService.java
@@ -26,8 +26,10 @@ import static org.apache.openmeetings.webservice.Constants.USER_SERVICE_NAME;
import static org.apache.openmeetings.webservice.Constants.USER_SERVICE_PORT_NAME;
import java.util.Date;
+import java.util.HashMap;
import java.util.List;
import java.util.Locale;
+import java.util.Map;
import javax.jws.WebMethod;
import javax.jws.WebParam;
@@ -44,8 +46,10 @@ import javax.ws.rs.core.MediaType;
import org.apache.cxf.feature.Features;
import org.apache.openmeetings.IApplication;
+import org.apache.openmeetings.core.remote.ScopeApplicationAdapter;
import org.apache.openmeetings.core.util.StrongPasswordValidator;
import org.apache.openmeetings.db.dao.basic.ConfigurationDao;
+import org.apache.openmeetings.db.dao.server.ISessionManager;
import org.apache.openmeetings.db.dao.server.SOAPLoginDao;
import org.apache.openmeetings.db.dao.server.SessiondataDao;
import org.apache.openmeetings.db.dao.user.IUserManager;
@@ -55,6 +59,7 @@ import org.apache.openmeetings.db.dto.basic.ServiceResult.Type;
import org.apache.openmeetings.db.dto.room.RoomOptionsDTO;
import org.apache.openmeetings.db.dto.user.ExternalUserDTO;
import org.apache.openmeetings.db.dto.user.UserDTO;
+import org.apache.openmeetings.db.entity.room.StreamClient;
import org.apache.openmeetings.db.entity.server.RemoteSessionObject;
import org.apache.openmeetings.db.entity.server.Sessiondata;
import org.apache.openmeetings.db.entity.user.Address;
@@ -72,6 +77,7 @@ import org.apache.wicket.validation.IValidator;
import org.apache.wicket.validation.Validatable;
import org.apache.wicket.validation.ValidationError;
import org.red5.logging.Red5LoggerFactory;
+import org.red5.server.api.scope.IScope;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
@@ -92,13 +98,17 @@ public class UserWebService implements UserService {
@Autowired
private ConfigurationDao cfgDao;
@Autowired
- private IUserManager userManagement;
+ private IUserManager userManager;
@Autowired
private SOAPLoginDao soapLoginDao;
@Autowired
private UserDao userDao;
@Autowired
private SessiondataDao sessionDao;
+ @Autowired
+ private ISessionManager sessionManager;
+ @Autowired
+ private ScopeApplicationAdapter scopeApplicationAdapter;
/* (non-Javadoc)
* @see org.apache.openmeetings.webservice.cluster.UserService#login(java.lang.String, java.lang.String)
@@ -187,7 +197,7 @@ public class UserWebService implements UserService {
}
throw new ServiceException(sb.toString());
}
- Long userId = userManagement.registerUser(user.getLogin(), user.getPassword(),
+ Long userId = userManager.registerUser(user.getLogin(), user.getPassword(),
user.getLastname(), user.getFirstname(), user.getAddress().getEmail(), new Date(), user.getAddress().getStreet(),
user.getAddress().getAdditionalname(), user.getAddress().getFax(), user.getAddress().getZip(), user.getAddress().getCountry()
, user.getAddress().getTown(), user.getLanguageId(),
@@ -331,18 +341,51 @@ public class UserWebService implements UserService {
return new ServiceResult(-1L, "Unknown error", Type.ERROR);
}
+ /**
+ * Kick a user by its publicSID.<br/>
+ * <br/>
+ * <i>Note:</i>
+ * This method will not perform a call to the slave, cause this call can only be
+ * invoked from inside the conference room, that means all clients are on the
+ * same server, no matter if clustered or not.
+ *
+ * @param sid
+ * @param uid
+ * @return - true in case user have sufficient permissions, null otherwise
+ */
+ private boolean kickUserByUid(String uid) {
+ StreamClient rcl = sessionManager.getClientByUid(uid, null);
+
+ if (rcl == null) {
+ return true;
+ }
+ String scopeName = "hibernate";
+ if (rcl.getRoomId() != null) {
+ scopeName = rcl.getRoomId().toString();
+ }
+ IScope currentScope = scopeApplicationAdapter.getRoomScope(scopeName);
+
+ Map<Integer, String> messageObj = new HashMap<>();
+ messageObj.put(0, "kick");
+
+ scopeApplicationAdapter.sendMessageById(messageObj, rcl.getId(), currentScope);
+ scopeApplicationAdapter.roomLeaveByScope(rcl, currentScope);
+
+ return true;
+ }
+
/* (non-Javadoc)
* @see org.apache.openmeetings.webservice.cluster.UserService#kick(java.lang.String, java.lang.String)
*/
@Override
@WebMethod
@POST
- @Path("/kick/{publicsid}")
- public ServiceResult kick(@WebParam(name="sid") @QueryParam("sid") String sid, @WebParam(name="publicsid") @PathParam("publicsid") String publicSID) throws ServiceException {
+ @Path("/kick/{uid}")
+ public ServiceResult kick(@WebParam(name="sid") @QueryParam("sid") String sid, @WebParam(name="uid") @PathParam("uid") String uid) throws ServiceException {
try {
Sessiondata sd = sessionDao.check(sid);
if (AuthLevelUtil.hasWebServiceLevel(userDao.getRights(sd.getUserId()))) {
- Boolean success = userManagement.kickUserByPublicSID(sid, publicSID);
+ boolean success = kickUserByUid(uid);
return new ServiceResult(Boolean.TRUE.equals(success) ? 1L : 0L, Boolean.TRUE.equals(success) ? "deleted" : "not deleted", Type.SUCCESS);
} else {
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/117e8d6b/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/cluster/UserService.java
----------------------------------------------------------------------
diff --git a/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/cluster/UserService.java b/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/cluster/UserService.java
index 6ccba83..ee26d20 100644
--- a/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/cluster/UserService.java
+++ b/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/cluster/UserService.java
@@ -141,12 +141,10 @@ public interface UserService {
*
* @param sid
* The SID from getSession
- * @param publicSID
- * the publicSID (you can get it from the call to get users in a
- * room)
+ * @param uid the uid of the client
* @return - <code>true</code> if user was kicked
*/
- ServiceResult kick(@WebParam(name="sid") @QueryParam("sid") String sid, @WebParam(name="publicsid") @PathParam("publicsid") String publicSID) throws ServiceException;
+ ServiceResult kick(@WebParam(name="sid") @QueryParam("sid") String sid, @WebParam(name="uid") @PathParam("uid") String uid) throws ServiceException;
/**
* Returns the count of users currently in the Room with given id
[3/3] openmeetings git commit: [OPENMEETINGS-1646] work with streams
refactored (incomplete)
Posted by so...@apache.org.
[OPENMEETINGS-1646] work with streams refactored (incomplete)
Project: http://git-wip-us.apache.org/repos/asf/openmeetings/repo
Commit: http://git-wip-us.apache.org/repos/asf/openmeetings/commit/117e8d6b
Tree: http://git-wip-us.apache.org/repos/asf/openmeetings/tree/117e8d6b
Diff: http://git-wip-us.apache.org/repos/asf/openmeetings/diff/117e8d6b
Branch: refs/heads/master
Commit: 117e8d6bcef5a17efdb4287a20ad6b7e1daf7049
Parents: 417fdd6
Author: Maxim Solodovnik <so...@gmail.com>
Authored: Fri Jun 30 12:46:47 2017 +0700
Committer: Maxim Solodovnik <so...@gmail.com>
Committed: Fri Jun 30 12:46:47 2017 +0700
----------------------------------------------------------------------
.../openmeetings/core/remote/MobileService.java | 72 +-
.../core/remote/RecordingService.java | 116 ++--
.../core/remote/ScopeApplicationAdapter.java | 425 ++++--------
.../openmeetings/core/remote/UserService.java | 225 ------
.../core/remote/util/SessionVariablesUtil.java | 91 ---
.../core/session/SessionManager.java | 154 +----
.../core/session/store/DatabaseStore.java | 28 +-
.../core/session/store/HashMapStore.java | 63 +-
.../session/store/IClientPersistenceStore.java | 59 +-
.../openmeetings/core/util/IClientUtil.java | 55 ++
.../openmeetings/core/util/RoomHelper.java | 14 +-
.../org/apache/openmeetings/IApplication.java | 10 +-
.../openmeetings/db/dao/room/ClientDao.java | 60 +-
.../db/dao/server/ISessionManager.java | 59 +-
.../openmeetings/db/dao/user/IUserManager.java | 5 +-
.../openmeetings/db/dao/user/IUserService.java | 26 -
.../openmeetings/db/entity/basic/Client.java | 98 ++-
.../db/entity/log/ConferenceLog.java | 2 +-
.../db/entity/room/StreamClient.java | 684 ++++++-------------
openmeetings-flash/src/main/flex/main.mxml | 4 +-
.../flex/org/apache/openmeetings/OmVideo.as | 2 +-
.../apache/openmeetings/screenshare/Core.java | 30 +-
.../src/main/jnlp/templates/template.jnlp | 2 +-
.../openmeetings/service/user/UserManager.java | 74 +-
.../web/admin/connection/ConnectionsPanel.java | 15 +-
.../openmeetings/web/admin/rooms/RoomForm.java | 7 +-
.../openmeetings/web/app/Application.java | 126 ++--
.../apache/openmeetings/web/app/WebSession.java | 27 +-
.../openmeetings/web/common/MainPanel.java | 23 +-
.../openmeetings/web/room/RoomBroadcaster.java | 10 +-
.../apache/openmeetings/web/room/RoomPanel.java | 55 +-
.../openmeetings/web/room/VideoSettings.java | 9 +-
.../web/room/menu/RoomMenuPanel.java | 4 +-
.../web/room/menu/StartSharingButton.java | 6 +-
.../org/apache/openmeetings/web/room/room.js | 32 +-
.../WEB-INF/classes/applicationContext.xml | 1 -
.../webapp/WEB-INF/classes/logback-config.xml | 2 +-
.../test/poll/TestClientListManager.java | 43 --
.../test/session/TestDbSession.java | 109 +--
.../test/session/TestDbSessionGetRoomIds.java | 23 +-
.../test/session/TestHashMapSession.java | 50 +-
.../openmeetings/webservice/RoomWebService.java | 2 +-
.../openmeetings/webservice/UserWebService.java | 53 +-
.../webservice/cluster/UserService.java | 6 +-
44 files changed, 1061 insertions(+), 1900 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/117e8d6b/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/MobileService.java
----------------------------------------------------------------------
diff --git a/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/MobileService.java b/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/MobileService.java
index d6487e0..c3b7dac 100644
--- a/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/MobileService.java
+++ b/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/MobileService.java
@@ -39,7 +39,7 @@ import java.util.UUID;
import org.apache.commons.lang3.time.FastDateFormat;
import org.apache.openmeetings.core.remote.ScopeApplicationAdapter.MessageSender;
-import org.apache.openmeetings.core.remote.util.SessionVariablesUtil;
+import org.apache.openmeetings.core.util.IClientUtil;
import org.apache.openmeetings.core.util.WebSocketHelper;
import org.apache.openmeetings.db.dao.basic.ChatDao;
import org.apache.openmeetings.db.dao.basic.ConfigurationDao;
@@ -216,25 +216,40 @@ public class MobileService {
private Map<String, Object> login(User u, Map<String, Object> result) {
if (u != null) {
IConnection conn = Red5.getConnectionLocal();
- String streamId = conn.getClient().getId();
- StreamClient c = sessionManager.getClientByStreamId(streamId, null);
+ StreamClient c = sessionManager.get(IClientUtil.getId(conn.getClient()));
if (c == null) {
// Failed to create client
result.put("status", -1);
} else {
- Sessiondata sd = sessionDao.check(c.getSecurityCode());
+ Sessiondata sd = sessionDao.check(c.getOwnerSid());
sd.setUserId(u.getId());
sd.setLanguageId(u.getLanguageId());
sessionDao.update(sd);
- SessionVariablesUtil.initClient(conn.getClient(), c.getPublicSID());
c.setUserId(u.getId());
c.setFirstname(u.getFirstname());
c.setLastname(u.getLastname());
- //TODO rights
- sessionManager.updateClientByStreamId(streamId, c, false, null);
+ /*TODO check this
+ rcm.setMobile(true);
+ rcm.setUserId(sd.getUserId());
+ if (rcm.getUserId() != null) {
+ User u = userDao.get(rcm.getUserId());
+ if (u == null) {
+ _log.error("Attempt of unauthorized room enter: USER not found, client is rejected");
+ return rejectClient();
+ }
+ rcm.setUsername(u.getLogin());
+ rcm.setFirstname(u.getFirstname());
+ rcm.setLastname(u.getLastname());
+ rcm.setEmail(u.getAddress() == null ? null : u.getAddress().getEmail());
+ }
+ rcm.setSecurityCode(sd.getSessionId());
+ rcm.setPublicSID(UUID.randomUUID().toString());
+ */
+ sessionManager.update(c);
+ IClientUtil.init(conn.getClient(), c.getId(), false);
add(result, "sid", sd.getSessionId());
- add(result, "publicSid", c.getPublicSID());
+ add(result, "uid", c.getUid());
add(result, "status", 0);
add(result, "userId", u.getId());
add(result, "firstname", u.getFirstname());
@@ -254,21 +269,22 @@ public class MobileService {
IConnection current = Red5.getConnectionLocal();
for (IConnection conn : current.getScope().getClientConnections()) {
if (conn != null && conn instanceof IServiceCapableConnection) {
- StreamClient c = sessionManager.getClientByStreamId(conn.getClient().getId(), null);
- if (!Strings.isEmpty(c.getAvsettings()) && !c.isScreenClient()) {
+ StreamClient c = sessionManager.get(IClientUtil.getId(conn.getClient()));
+ if (!Strings.isEmpty(c.getAvsettings()) && !c.isSharing()) {
+ //TODO duplicates !!!!!!!!!!!!!!
Map<String, Object> map = new HashMap<>();
- add(map, "streamId", c.getStreamid());
+ add(map, "id", c.getId());
add(map, "broadCastId", c.getBroadCastId());
add(map, "userId", c.getUserId());
add(map, "firstname", c.getFirstname());
add(map, "lastname", c.getLastname());
- add(map, "publicSid", c.getPublicSID());
+ add(map, "uid", c.getUid());
add(map, "login", c.getUsername());
add(map, "email", c.getEmail());
add(map, "avsettings", c.getAvsettings());
add(map, "interviewPodId", c.getInterviewPodId());
- add(map, "vWidth", c.getVWidth());
- add(map, "vHeight", c.getVHeight());
+ add(map, "vWidth", c.getWidth());
+ add(map, "vHeight", c.getHeight());
result.add(map);
}
}
@@ -296,7 +312,7 @@ public class MobileService {
List<Map<String, Object>> result = new ArrayList<>();
// FIXME duplicated code
IConnection current = Red5.getConnectionLocal();
- StreamClient c = sessionManager.getClientByStreamId(current.getClient().getId(), null);
+ StreamClient c = sessionManager.get(IClientUtil.getId(current.getClient()));
User u = userDao.get(c.getUserId());
//my rooms
List<Room> myl = new ArrayList<>();
@@ -333,25 +349,25 @@ public class MobileService {
public Map<String, Object> roomConnect(String SID, Long userId) {
// publicSid is changed on mobile room connect
IConnection current = Red5.getConnectionLocal();
- StreamClient c = sessionManager.getClientByStreamId(current.getClient().getId(), null);
+ StreamClient c = sessionManager.get(IClientUtil.getId(current.getClient()));
Map<String, Object> result = new HashMap<>();
- result.put("publicSid", c.getPublicSID());
+ //FIXME TODO result.put("publicSid", c.getPublicSID());
return result;
}
public Map<String, Object> updateAvMode(String avMode, String width, String height, Integer interviewPodId) {
IConnection current = Red5.getConnectionLocal();
- StreamClient c = sessionManager.getClientByStreamId(current.getClient().getId(), null);
+ StreamClient c = sessionManager.get(IClientUtil.getId(current.getClient()));
c.setAvsettings(avMode);
if (!"n".equals(avMode)) {
- c.setIsBroadcasting(true);
+ c.setBroadcasting(true);
}
- c.setVWidth(Double.valueOf(width).intValue());
- c.setVHeight(Double.valueOf(height).intValue());
+ c.setWidth(Double.valueOf(width).intValue());
+ c.setHeight(Double.valueOf(height).intValue());
if (interviewPodId > 0) {
c.setInterviewPodId(interviewPodId);
}
- sessionManager.updateClientByStreamId(c.getStreamid(), c, false, null);
+ sessionManager.update(c);
Map<String, Object> hsm = new HashMap<>();
hsm.put("client", c);
hsm.put("message", new String[]{"avsettings", "0", avMode});
@@ -362,7 +378,7 @@ public class MobileService {
public void sendChatMessage(String msg) {
IConnection current = Red5.getConnectionLocal();
- StreamClient c = sessionManager.getClientByStreamId(current.getClient().getId(), null);
+ StreamClient c = sessionManager.get(IClientUtil.getId(current.getClient()));
ChatMessage m = new ChatMessage();
m.setMessage(msg);
@@ -379,7 +395,7 @@ public class MobileService {
}
public void sendChatMessage(String uid, ChatMessage m, FastDateFormat fmt) {
- sendChatMessage(sessionManager.getClientByPublicSID(uid, null), m, fmt);
+ sendChatMessage(sessionManager.getClientByUid(uid, null), m, fmt);
}
public void sendChatMessage(StreamClient c, ChatMessage m, FastDateFormat fmt) {
@@ -395,15 +411,15 @@ public class MobileService {
new MessageSender(scopeAdapter.getRoomScope("" + roomId), "sendVarsToMessageWithClient", hsm, scopeAdapter) {
@Override
public boolean filter(IConnection conn) {
- StreamClient rcl = sessionManager.getClientByStreamId(conn.getClient().getId(), null);
- return rcl.isScreenClient()
+ StreamClient rcl = sessionManager.get(IClientUtil.getId(current.getClient()));
+ return rcl.isSharing()
|| rcl.getRoomId() == null || !rcl.getRoomId().equals(roomId);
}
}.start();
}
private static boolean isModerator(StreamClient c) {
- return c.getIsMod() || c.getIsSuperModerator();
+ return c.isMod() || c.isSuperMod();
}
private static FastDateFormat getFmt(User u) {
@@ -426,7 +442,7 @@ public class MobileService {
List<Map<String,Object>> myChatList = new ArrayList<>();
try {
IConnection current = Red5.getConnectionLocal();
- StreamClient c = sessionManager.getClientByStreamId(current.getClient().getId(), null);
+ StreamClient c = sessionManager.get(IClientUtil.getId(current.getClient()));
Long roomId = c.getRoomId();
log.debug("GET CHATROOM: " + roomId);
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/117e8d6b/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/RecordingService.java
----------------------------------------------------------------------
diff --git a/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/RecordingService.java b/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/RecordingService.java
index 93ff702..14d584b 100644
--- a/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/RecordingService.java
+++ b/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/RecordingService.java
@@ -29,6 +29,7 @@ import org.apache.openmeetings.core.converter.BaseConverter;
import org.apache.openmeetings.core.data.record.converter.InterviewConverterTask;
import org.apache.openmeetings.core.data.record.converter.RecordingConverterTask;
import org.apache.openmeetings.core.data.record.listener.StreamListener;
+import org.apache.openmeetings.core.util.IClientUtil;
import org.apache.openmeetings.core.util.WebSocketHelper;
import org.apache.openmeetings.db.dao.record.RecordingDao;
import org.apache.openmeetings.db.dao.record.RecordingMetaDataDao;
@@ -46,7 +47,6 @@ import org.apache.openmeetings.util.message.RoomMessage;
import org.apache.openmeetings.util.message.TextRoomMessage;
import org.red5.logging.Red5LoggerFactory;
import org.red5.server.api.IConnection;
-import org.red5.server.api.Red5;
import org.red5.server.api.scope.IScope;
import org.red5.server.api.service.IPendingServiceCall;
import org.red5.server.api.service.IPendingServiceCallback;
@@ -121,8 +121,8 @@ public class RecordingService implements IPendingServiceCallback {
recording.setRoomId(roomId);
recording.setRecordStart(now);
- recording.setWidth(client.getVWidth());
- recording.setHeight(client.getVHeight());
+ recording.setWidth(client.getWidth());
+ recording.setHeight(client.getHeight());
recording.setOwnerId(ownerId);
recording.setStatus(Recording.Status.RECORDING);
@@ -132,35 +132,35 @@ public class RecordingService implements IPendingServiceCallback {
log.debug("##REC:: recording created by USER: " + ownerId);
// Update Client and set Flag
- client.setIsRecording(true);
+ client.setRecordingStarted(true);
client.setRecordingId(recordingId);
- sessionManager.updateClientByStreamId(client.getStreamid(), client, false, null);
+ sessionManager.update(client);
// get all stream and start recording them
for (IConnection conn : current.getScope().getClientConnections()) {
if (conn != null) {
if (conn instanceof IServiceCapableConnection) {
- StreamClient rcl = sessionManager.getClientByStreamId(conn.getClient().getId(), null);
+ StreamClient rcl = sessionManager.get(IClientUtil.getId(conn.getClient()));
// Send every user a notification that the recording did start
- WebSocketHelper.sendRoom(new TextRoomMessage(roomId, ownerId, RoomMessage.Type.recordingStarted, client.getPublicSID()));
+ WebSocketHelper.sendRoom(new TextRoomMessage(roomId, ownerId, RoomMessage.Type.recordingStarted, client.getOwnerSid()));
// If its the recording client we need another type of Meta Data
- if (rcl.isScreenClient()) {
- if (rcl.getRecordingId() != null && rcl.isScreenPublishStarted()) {
- String streamName_Screen = generateFileName(recordingId, rcl.getStreamPublishName().toString());
+ if (rcl.isSharing()) {
+ if (rcl.getRecordingId() != null && rcl.isSharingStarted()) {
+ String streamName_Screen = generateFileName(recordingId, rcl.getBroadCastId());
Long metaDataId = metaDataDao.add(
recordingId, rcl.getFirstname() + " " + rcl.getLastname(), now, false,
false, true, streamName_Screen, rcl.getInterviewPodId());
// Start FLV Recording
- recordShow(conn, rcl.getStreamPublishName(), streamName_Screen, metaDataId, true, isInterview);
+ recordShow(conn, rcl.getBroadCastId(), streamName_Screen, metaDataId, true, isInterview);
// Add Meta Data
- rcl.setRecordingMetaDataId(metaDataId);
+ rcl.setMetaId(metaDataId);
- sessionManager.updateClientByStreamId(rcl.getStreamid(), rcl, false, null);
+ sessionManager.update(rcl);
}
} else if (rcl.getAvsettings().equals("av") || rcl.getAvsettings().equals("a") || rcl.getAvsettings().equals("v")) {
// if the user does publish av, a, v
@@ -183,9 +183,9 @@ public class RecordingService implements IPendingServiceCallback {
rcl.getFirstname() + " " + rcl.getLastname(), now, isAudioOnly, isVideoOnly, false, streamName,
rcl.getInterviewPodId());
- rcl.setRecordingMetaDataId(metaId);
+ rcl.setMetaId(metaId);
- sessionManager.updateClientByStreamId(rcl.getStreamid(), rcl, false, null);
+ sessionManager.update(rcl);
// Start FLV recording
recordShow(conn, broadcastId, streamName, metaId, !isAudioOnly, isInterview);
@@ -212,8 +212,8 @@ public class RecordingService implements IPendingServiceCallback {
*/
private void recordShow(IConnection conn, String broadcastid, String streamName, Long metaId, boolean isScreenData, boolean isInterview) throws Exception {
try {
- log.debug("Recording show for: " + conn.getScope().getContextPath());
- log.debug("Name of CLient and Stream to be recorded: " + broadcastid);
+ log.debug("Recording show for: {}", conn.getScope().getContextPath());
+ log.debug("Name of CLient and Stream to be recorded: {}", broadcastid);
// log.debug("Application.getInstance()"+Application.getInstance());
log.debug("Scope " + conn);
log.debug("Scope " + conn.getScope());
@@ -309,33 +309,32 @@ public class RecordingService implements IPendingServiceCallback {
public void stopRecordAndSave(IScope scope, StreamClient client, Long storedRecordingId) {
try {
log.debug("stopRecordAndSave " + client.getUsername() + "," + client.getUserip());
- WebSocketHelper.sendRoom(new TextRoomMessage(client.getRoomId(), client.getUserId(), RoomMessage.Type.recordingStoped, client.getPublicSID()));
+ WebSocketHelper.sendRoom(new TextRoomMessage(client.getRoomId(), client.getUserId(), RoomMessage.Type.recordingStoped, client.getOwnerSid()));
// get all stream and stop recording them
for (IConnection conn : scope.getClientConnections()) {
if (conn != null) {
if (conn instanceof IServiceCapableConnection) {
- StreamClient rcl = sessionManager.getClientByStreamId(conn.getClient().getId(), null);
+ StreamClient rcl = sessionManager.get(IClientUtil.getId(conn.getClient()));
if (rcl == null) {
continue;
}
log.debug("is this users still alive? stop it :" + rcl);
- if (rcl.isScreenClient()) {
- if (rcl.getRecordingId() != null && rcl.isScreenPublishStarted()) {
+ if (rcl.isSharing()) {
+ if (rcl.getRecordingId() != null && rcl.isSharingStarted()) {
// Stop FLV Recording
- stopRecordingShow(scope, rcl.getStreamPublishName(), rcl.getRecordingMetaDataId());
+ stopRecordingShow(scope, rcl.getBroadCastId(), rcl.getMetaId());
// Update Meta Data
- metaDataDao.updateEndDate(rcl.getRecordingMetaDataId(), new Date());
+ metaDataDao.updateEndDate(rcl.getMetaId(), new Date());
}
} else if (rcl.getAvsettings().equals("av") || rcl.getAvsettings().equals("a") || rcl.getAvsettings().equals("v")) {
-
- stopRecordingShow(scope, rcl.getBroadCastId(), rcl.getRecordingMetaDataId());
+ stopRecordingShow(scope, rcl.getBroadCastId(), rcl.getMetaId());
// Update Meta Data
- metaDataDao.updateEndDate(rcl.getRecordingMetaDataId(), new Date());
+ metaDataDao.updateEndDate(rcl.getMetaId(), new Date());
}
}
}
@@ -354,10 +353,10 @@ public class RecordingService implements IPendingServiceCallback {
// Reset values
client.setRecordingId(null);
- client.setIsRecording(false);
+ client.setRecordingStarted(false);
- sessionManager.updateClientByStreamId(client.getStreamid(), client, false, null);
- log.debug("recordingConverterTask ", recordingConverterTask);
+ sessionManager.update(client);
+ log.debug("recordingConverterTask {}", recordingConverterTask);
Recording recording = recordingDao.get(recordingId);
if (!recording.isInterview()) {
@@ -371,29 +370,7 @@ public class RecordingService implements IPendingServiceCallback {
}
}
- public StreamClient checkLzRecording() {
- try {
- IConnection current = Red5.getConnectionLocal();
- String streamid = current.getClient().getId();
-
- log.debug("getCurrentRoomClient -2- " + streamid);
-
- StreamClient currentClient = sessionManager.getClientByStreamId(streamid, null);
-
- log.debug("getCurrentRoomClient -#########################- " + currentClient.getRoomId());
-
- for (StreamClient rcl : sessionManager.getClientListByRoomAll(currentClient.getRoomId())) {
- if (rcl.getIsRecording()) {
- return rcl;
- }
- }
-
- } catch (Exception err) {
- log.error("[checkLzRecording]", err);
- }
- return null;
- }
-
+ //TODO copy/paste
public void stopRecordingShowForClient(IScope scope, StreamClient rcl) {
try {
// this cannot be handled here, as to stop a stream and to leave a
@@ -403,28 +380,25 @@ public class RecordingService implements IPendingServiceCallback {
// rcl.getUserip(), false);
log.debug("### stopRecordingShowForClient: " + rcl);
- if (rcl.isScreenClient()) {
-
- if (rcl.getRecordingId() != null && rcl.isScreenPublishStarted()) {
+ if (rcl.isSharing()) {
+ if (rcl.getRecordingId() != null && rcl.isSharingStarted()) {
// Stop FLV Recording
// FIXME: Is there really a need to stop it manually if the
// user just
// stops the stream?
- stopRecordingShow(scope, rcl.getStreamPublishName(), rcl.getRecordingMetaDataId());
+ stopRecordingShow(scope, rcl.getBroadCastId(), rcl.getMetaId());
// Update Meta Data
- metaDataDao.updateEndDate(rcl.getRecordingMetaDataId(), new Date());
+ metaDataDao.updateEndDate(rcl.getMetaId(), new Date());
}
-
} else if (rcl.getAvsettings().equals("a") || rcl.getAvsettings().equals("v") || rcl.getAvsettings().equals("av")) {
-
// FIXME: Is there really a need to stop it manually if the user
// just stops the stream?
- stopRecordingShow(scope, rcl.getBroadCastId(), rcl.getRecordingMetaDataId());
+ stopRecordingShow(scope, rcl.getBroadCastId(), rcl.getMetaId());
// Update Meta Data
- metaDataDao.updateEndDate(rcl.getRecordingMetaDataId(), new Date());
+ metaDataDao.updateEndDate(rcl.getMetaId(), new Date());
}
} catch (Exception err) {
@@ -439,22 +413,22 @@ public class RecordingService implements IPendingServiceCallback {
Date now = new Date();
// If its the recording client we need another type of Meta Data
- if (rcl.isScreenClient()) {
- if (rcl.getRecordingId() != null && rcl.isScreenPublishStarted()) {
- String streamName_Screen = generateFileName(recordingId, rcl.getStreamPublishName().toString());
+ if (rcl.isSharing()) {
+ if (rcl.getRecordingId() != null && rcl.isSharingStarted()) {
+ String streamName_Screen = generateFileName(recordingId, rcl.getBroadCastId().toString());
- log.debug("############## ADD SCREEN OF SHARER :: " + rcl.getStreamPublishName());
+ log.debug("############## ADD SCREEN OF SHARER :: {}", rcl.getBroadCastId());
Long metaDataId = metaDataDao.add(recordingId, rcl.getFirstname()
+ " " + rcl.getLastname(), now, false, false, true, streamName_Screen, rcl.getInterviewPodId());
// Start FLV Recording
- recordShow(conn, rcl.getStreamPublishName(), streamName_Screen, metaDataId, true, recording.isInterview());
+ recordShow(conn, rcl.getBroadCastId(), streamName_Screen, metaDataId, true, recording.isInterview());
// Add Meta Data
- rcl.setRecordingMetaDataId(metaDataId);
+ rcl.setMetaId(metaDataId);
- sessionManager.updateClientByStreamId(rcl.getStreamid(), rcl, false, null);
+ sessionManager.update(rcl);
}
} else if (rcl.getAvsettings().equals("av") || rcl.getAvsettings().equals("a") || rcl.getAvsettings().equals("v")) {
// if the user does publish av, a, v
@@ -478,12 +452,10 @@ public class RecordingService implements IPendingServiceCallback {
// Start FLV recording
recordShow(conn, rcl.getBroadCastId(), streamName, metaDataId, false, recording.isInterview());
- rcl.setRecordingMetaDataId(metaDataId);
-
- sessionManager.updateClientByStreamId(rcl.getStreamid(), rcl, false, null);
+ rcl.setMetaId(metaDataId);
+ sessionManager.update(rcl);
}
-
} catch (Exception err) {
log.error("[addRecordingByStreamId]", err);
}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/117e8d6b/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/ScopeApplicationAdapter.java
----------------------------------------------------------------------
diff --git a/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/ScopeApplicationAdapter.java b/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/ScopeApplicationAdapter.java
index 214883d..8a7085b 100644
--- a/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/ScopeApplicationAdapter.java
+++ b/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/ScopeApplicationAdapter.java
@@ -43,7 +43,7 @@ import java.util.Properties;
import java.util.UUID;
import org.apache.openmeetings.IApplication;
-import org.apache.openmeetings.core.remote.util.SessionVariablesUtil;
+import org.apache.openmeetings.core.util.IClientUtil;
import org.apache.openmeetings.core.util.WebSocketHelper;
import org.apache.openmeetings.db.dao.basic.ConfigurationDao;
import org.apache.openmeetings.db.dao.label.LabelDao;
@@ -59,8 +59,6 @@ import org.apache.openmeetings.db.entity.log.ConferenceLog;
import org.apache.openmeetings.db.entity.room.Room;
import org.apache.openmeetings.db.entity.room.StreamClient;
import org.apache.openmeetings.db.entity.server.Server;
-import org.apache.openmeetings.db.entity.server.Sessiondata;
-import org.apache.openmeetings.db.entity.user.User;
import org.apache.openmeetings.util.CalendarPatterns;
import org.apache.openmeetings.util.InitializationContainer;
import org.apache.openmeetings.util.OmFileHelper;
@@ -69,7 +67,6 @@ import org.apache.openmeetings.util.Version;
import org.apache.openmeetings.util.message.RoomMessage;
import org.apache.openmeetings.util.message.TextRoomMessage;
import org.apache.wicket.Application;
-import org.apache.wicket.util.string.StringValue;
import org.apache.wicket.util.string.Strings;
import org.red5.logging.Red5LoggerFactory;
import org.red5.server.adapter.MultiThreadedApplicationAdapter;
@@ -88,7 +85,7 @@ import com.github.openjson.JSONObject;
public class ScopeApplicationAdapter extends MultiThreadedApplicationAdapter implements IPendingServiceCallback {
private static final Logger _log = Red5LoggerFactory.getLogger(ScopeApplicationAdapter.class, webAppRootKey);
- private static final String SECURITY_CODE_PARAM = "securityCode";
+ private static final String OWNER_SID_PARAM = "ownerSid";
private static final String WIDTH_PARAM = "width";
private static final String HEIGHT_PARAM = "height";
public static final String FLASH_SECURE = "secure";
@@ -186,7 +183,7 @@ public class ScopeApplicationAdapter extends MultiThreadedApplicationAdapter imp
IServiceCapableConnection service = (IServiceCapableConnection) conn;
String streamId = conn.getClient().getId();
- _log.debug("### Client connected to OpenMeetings, register Client StreamId: " + streamId + " scope " + conn.getScope().getName());
+ _log.debug("### Client connected to OpenMeetings, register Client StreamId: {} scope {}", streamId, conn.getScope().getName());
// Set StreamId in Client
service.invoke("setId", new Object[] { streamId }, this);
@@ -199,130 +196,40 @@ public class ScopeApplicationAdapter extends MultiThreadedApplicationAdapter imp
if ("noclient".equals(uid)) {
return true;
}
- String securityCode = (String)connParams.get(SECURITY_CODE_PARAM);
- String parentSid = (String)map.get("parentSid");
- if (parentSid == null) {
- parentSid = (String)connParams.get("parentSid");
- }
- StringValue scn = StringValue.valueOf(conn.getScope().getName());
- long roomId = scn.toLong(Long.MIN_VALUE);
- StreamClient rcm = new StreamClient();
- IApplication iapp = (IApplication)Application.get(wicketApplicationName);
- if (!Strings.isEmpty(securityCode)) {
- //this is for external applications like ffmpeg [OPENMEETINGS-1574]
- if (roomId < 0) {
- _log.warn("Trying to enter invalid scope using security code, client is rejected:: " + roomId);
- return rejectClient();
- }
- String _uid = null;
- for (org.apache.openmeetings.db.entity.basic.Client wcl : iapp.getOmRoomClients(roomId)) {
- if (wcl.getSid().equals(securityCode)) {
- _uid = wcl.getUid();
- break;
- }
- }
- if (_uid == null) {
- _log.warn("Client is not found by security id, client is rejected");
- return rejectClient();
- }
- StreamClient parent = sessionManager.getClientByPublicSID(_uid, null);
- if (parent == null || !parent.getScope().equals(scn.toString())) {
- _log.warn("Security code is invalid, client is rejected");
- return rejectClient();
- }
- rcm.setUsername(parent.getUsername());
- rcm.setFirstname(parent.getFirstname());
- rcm.setLastname(parent.getLastname());
- rcm.setUserId(parent.getUserId());
- rcm.setPublicSID(UUID.randomUUID().toString());
- rcm.setSecurityCode(_uid);
- Number width = (Number)connParams.get(WIDTH_PARAM);
- Number height = (Number)connParams.get(HEIGHT_PARAM);
- if (width != null && height != null) {
- rcm.setVWidth(width.intValue());
- rcm.setVHeight(height.intValue());
- }
- }
- if (Strings.isEmpty(uid) && Strings.isEmpty(securityCode) && Strings.isEmpty(parentSid)) {
- _log.warn("No UIDs are provided, client is rejected");
+ String ownerSid = (String)connParams.get(OWNER_SID_PARAM);
+ if (Strings.isEmpty(ownerSid)) {
+ _log.warn("No Owner SID is provided, client is rejected");
return rejectClient();
}
-
- if (map.containsKey("screenClient")) {
- org.apache.openmeetings.db.entity.basic.Client parent = iapp.getOmClient(uid);
- if (parent == null) {
- _log.warn("Bad parent for screen-sharing client, client is rejected");
- return rejectClient();
- }
- SessionVariablesUtil.setIsScreenClient(conn.getClient());
- rcm.setUserId(parent.getUserId());
- rcm.setScreenClient(true);
- rcm.setPublicSID(UUID.randomUUID().toString());
- rcm.setStreamPublishName(uid);
- }
- rcm.setStreamid(conn.getClient().getId());
- rcm.setScope(scn.toString());
- boolean notHibernate = !"hibernate".equals(scn.toString());
- if (Long.MIN_VALUE != roomId) {
- rcm.setRoomId(roomId);
- } else if (notHibernate) {
+ StreamClient rcm = new StreamClient();
+ rcm.setScope(conn.getScope().getName());
+ if (rcm.getRoomId() == null && !"hibernate".equals(rcm.getScope())) {
_log.warn("Bad room specified, client is rejected");
return rejectClient();
}
- if (connParams.containsKey("mobileClient")) {
- Sessiondata sd = sessiondataDao.check(parentSid);
- if (sd.getUserId() == null && notHibernate) {
- _log.warn("Attempt of unauthorized room enter, client is rejected");
- return rejectClient();
- }
- rcm.setMobile(true);
- rcm.setUserId(sd.getUserId());
- if (rcm.getUserId() != null) {
- User u = userDao.get(rcm.getUserId());
- if (u == null) {
- _log.error("Attempt of unauthorized room enter: USER not found, client is rejected");
- return rejectClient();
- }
- rcm.setUsername(u.getLogin());
- rcm.setFirstname(u.getFirstname());
- rcm.setLastname(u.getLastname());
- rcm.setEmail(u.getAddress() == null ? null : u.getAddress().getEmail());
- }
- rcm.setSecurityCode(sd.getSessionId());
- rcm.setPublicSID(UUID.randomUUID().toString());
- }
+ rcm.setUid(Strings.isEmpty(uid) ? UUID.randomUUID().toString() : uid);
+ rcm.setOwnerSid(ownerSid);
rcm.setUserport(conn.getRemotePort());
rcm.setUserip(conn.getRemoteAddress());
rcm.setSwfurl(swfURL);
rcm.setTcUrl(tcUrl);
- if (!Strings.isEmpty(uid)) {
- rcm.setPublicSID(uid);
+ IApplication iapp = (IApplication)Application.get(wicketApplicationName);
+ Number width = (Number)connParams.get(WIDTH_PARAM);
+ Number height = (Number)connParams.get(HEIGHT_PARAM);
+ if (width != null && height != null) {
+ //this is for external applications like ffmpeg [OPENMEETINGS-1574]
+ rcm.setWidth(width.intValue());
+ rcm.setHeight(height.intValue());
+ }
+ if (map.containsKey("screenClient")) {
+ rcm.setSharing(true);
}
rcm = sessionManager.add(iapp.updateClient(rcm, false), null);
if (rcm == null) {
_log.warn("Failed to create Client on room connect");
return false;
}
-
- SessionVariablesUtil.initClient(conn.getClient(), rcm.getPublicSID());
- //TODO add similar code for other connections, merge with above block
- if (map.containsKey("screenClient")) {
- //TODO add check for room rights
- User u = null;
- Long userId = rcm.getUserId();
- SessionVariablesUtil.setUserId(conn.getClient(), userId);
- if (userId != null) {
- long _uid = userId.longValue();
- u = userDao.get(_uid < 0 ? -_uid : _uid);
- }
- if (u != null) {
- rcm.setUsername(u.getLogin());
- rcm.setFirstname(u.getFirstname());
- rcm.setLastname(u.getLastname());
- }
- _log.debug("publishName :: " + rcm.getStreamPublishName());
- sessionManager.updateClientByStreamId(streamId, rcm, false, null);
- }
+ IClientUtil.init(conn.getClient(), rcm.getId(), rcm.isSharing());
// Log the User
conferenceLogDao.add(ConferenceLog.Type.clientConnect,
@@ -337,31 +244,29 @@ public class ScopeApplicationAdapter extends MultiThreadedApplicationAdapter imp
_log.debug("----------- screenSharerAction ENTER");
IConnection current = Red5.getConnectionLocal();
- StreamClient client = sessionManager.getClientByStreamId(current.getClient().getId(), null);
+ StreamClient client = sessionManager.get(IClientUtil.getId(current.getClient()));
if (client != null) {
boolean changed = false;
- if (Boolean.parseBoolean("" + map.get("stopStreaming")) && client.isStartStreaming()) {
+ if (Boolean.parseBoolean("" + map.get("stopStreaming")) && client.isSharingStarted()) {
changed = true;
- client.setStartStreaming(false);
+ client.setSharingStarted(false);
//Send message to all users
sendMessageToCurrentScope("stopScreenSharingMessage", client, false);
- WebSocketHelper.sendRoom(new TextRoomMessage(client.getRoomId(), client.getUserId(), RoomMessage.Type.sharingStoped, client.getStreamPublishName()));
returnMap.put("result", "stopSharingOnly");
}
- if (Boolean.parseBoolean("" + map.get("stopRecording")) && client.getIsRecording()) {
+ if (Boolean.parseBoolean("" + map.get("stopRecording")) && client.isRecordingStarted()) {
changed = true;
- client.setStartRecording(false);
- client.setIsRecording(false);
+ client.setRecordingStarted(false);
returnMap.put("result", "stopRecordingOnly");
recordingService.stopRecordAndSave(current.getScope(), client, null);
}
- if (Boolean.parseBoolean("" + map.get("stopPublishing")) && client.isScreenPublishStarted()) {
+ if (Boolean.parseBoolean("" + map.get("stopPublishing")) && client.isPublishStarted()) {
changed = true;
- client.setScreenPublishStarted(false);
+ client.setPublishStarted(false);
returnMap.put("result", "stopPublishingOnly");
//Send message to all users
@@ -369,9 +274,9 @@ public class ScopeApplicationAdapter extends MultiThreadedApplicationAdapter imp
}
if (changed) {
- sessionManager.updateClientByStreamId(client.getStreamid(), client, false, null);
+ sessionManager.update(client);
- if (!client.isStartStreaming() && !client.isStartRecording() && !client.isStreamPublishStarted()) {
+ if (!client.isSharingStarted() && !client.isRecordingStarted() && !client.isPublishStarted()) {
returnMap.put("result", "stopAll");
}
}
@@ -394,41 +299,34 @@ public class ScopeApplicationAdapter extends MultiThreadedApplicationAdapter imp
_log.debug("----------- setConnectionAsSharingClient");
IConnection current = Red5.getConnectionLocal();
- StreamClient client = sessionManager.getClientByStreamId(current.getClient().getId(), null);
+ StreamClient client = sessionManager.get(IClientUtil.getId(current.getClient()));
if (client != null) {
boolean startRecording = Boolean.parseBoolean("" + map.get("startRecording"));
boolean startStreaming = Boolean.parseBoolean("" + map.get("startStreaming"));
boolean startPublishing = Boolean.parseBoolean("" + map.get("startPublishing")) && (0 == sessionManager.getPublishingCount(client.getRoomId()));
- boolean alreadyStreaming = client.isStartStreaming();
+ boolean alreadyStreaming = client.isSharingStarted();
if (startStreaming) {
- client.setStartStreaming(true);
+ client.setSharingStarted(true);
}
- boolean alreadyRecording = client.isStartRecording();
+ boolean alreadyRecording = client.isRecordingStarted();
if (startRecording) {
- client.setStartRecording(true);
+ client.setRecordingStarted(true);
}
+ boolean alreadyPublishing = client.isPublishStarted();
if (startPublishing) {
- client.setStreamPublishStarted(true);
+ client.setPublishStarted(true);
}
- client.setVX(Double.valueOf("" + map.get("screenX")).intValue());
- client.setVY(Double.valueOf("" + map.get("screenY")).intValue());
- client.setVWidth(Double.valueOf("" + map.get("screenWidth")).intValue());
- client.setVHeight(Double.valueOf("" + map.get("screenHeight")).intValue());
- client.setStreamPublishName("" + map.get("publishName"));
- sessionManager.updateClientByStreamId(current.getClient().getId(), client, false, null);
+ client.setWidth(Double.valueOf("" + map.get("screenWidth")).intValue());
+ client.setHeight(Double.valueOf("" + map.get("screenHeight")).intValue());
+ sessionManager.update(client);
Map<String, Object> returnMap = new HashMap<>();
- returnMap.put("alreadyPublished", false);
+ returnMap.put("alreadyPublished", alreadyPublishing);
- // if is already started screen sharing, then there is no need to start it again
- if (client.isScreenPublishStarted()) {
- returnMap.put("alreadyPublished", true);
- }
-
- _log.debug("screen x,y,width,height {},{},{},{}", client.getVX(), client.getVY(), client.getVWidth(), client.getVHeight());
+ _log.debug("screen width,height {},{}", client.getWidth(), client.getHeight());
if (startStreaming) {
if (!alreadyStreaming) {
@@ -438,9 +336,9 @@ public class ScopeApplicationAdapter extends MultiThreadedApplicationAdapter imp
//Send message to all users
sendMessageToCurrentScope("newScreenSharing", client, false);
- WebSocketHelper.sendRoom(new TextRoomMessage(client.getRoomId(), client.getUserId(), RoomMessage.Type.sharingStarted, client.getStreamPublishName()));
+ WebSocketHelper.sendRoom(new TextRoomMessage(client.getRoomId(), client.getUserId(), RoomMessage.Type.sharingStarted, client.getUid()));
} else {
- _log.warn("Streaming is already started for the client id=" + client.getId() + ". Second request is ignored.");
+ _log.warn("Streaming is already started for the client id={}. Second request is ignored.", client.getId());
}
}
if (startRecording) {
@@ -451,7 +349,7 @@ public class ScopeApplicationAdapter extends MultiThreadedApplicationAdapter imp
recordingService.recordMeetingStream(current, client, recordingName, "", false);
} else {
- _log.warn("Recording is already started for the client id=" + client.getId() + ". Second request is ignored.");
+ _log.warn("Recording is already started for the client id={}. Second request is ignored.", client.getId());
}
}
if (startPublishing) {
@@ -479,7 +377,7 @@ public class ScopeApplicationAdapter extends MultiThreadedApplicationAdapter imp
try {
_log.debug("[roomLeave] {} {} {} {}", client.getId(), room.getClients().size(), room.getContextPath(), room.getName());
- StreamClient rcl = sessionManager.getClientByStreamId(client.getId(), null);
+ StreamClient rcl = sessionManager.get(IClientUtil.getId(client));
// The Room Client can be null if the Client left the room by using
// logicalRoomLeave
@@ -493,7 +391,7 @@ public class ScopeApplicationAdapter extends MultiThreadedApplicationAdapter imp
}
public void roomLeaveByScope(String uid, Long roomId) {
- StreamClient rcl = sessionManager.getClientByPublicSID(uid, null);
+ StreamClient rcl = sessionManager.getClientByUid(uid, null);
IScope scope = getRoomScope("" + roomId);
_log.debug("[roomLeaveByScope] {} {} {} {}", uid, roomId, rcl, scope);
if (rcl != null && scope != null) {
@@ -514,30 +412,24 @@ public class ScopeApplicationAdapter extends MultiThreadedApplicationAdapter imp
public void roomLeaveByScope(StreamClient client, IScope scope) {
try {
_log.debug("[roomLeaveByScope] currentClient " + client);
- if (client.isScreenClient() && client.isStartStreaming()) {
- //TODO check others/find better way
- WebSocketHelper.sendRoom(new TextRoomMessage(client.getRoomId(), client.getUserId(), RoomMessage.Type.sharingStoped, client.getStreamPublishName()));
+ if (client.isSharing() && client.isSharingStarted()) {
+ sendSharingStoped(client);
}
- if (client.getIsBroadcasting()) {
- WebSocketHelper.sendRoom(new TextRoomMessage(client.getRoomId(), client.getUserId(), RoomMessage.Type.closeStream, client.getPublicSID()));
+ if (client.isBroadcasting()) {
+ WebSocketHelper.sendRoom(new TextRoomMessage(client.getRoomId(), client.getUserId(), RoomMessage.Type.closeStream, client.getUid()));
}
- _log.debug("removing Username " + client.getUsername() + " "
- + client.getConnectedSince() + " streamid: "
- + client.getStreamid());
+ _log.debug("removing Username {} {}, streamid: {}", client.getUsername()
+ , client.getConnectedSince(), client.getId());
// stop and save any recordings
- if (client.getIsRecording()) {
+ if (client.isRecordingStarted()) {
_log.debug("*** roomLeave Current Client is Recording - stop that");
if (client.getInterviewPodId() != null) {
//interview, TODO need better check
_stopInterviewRecording(client, scope);
} else {
recordingService.stopRecordAndSave(scope, client, null);
-
- // set to true and overwrite the default one cause otherwise no
- // notification is send
- client.setIsRecording(true);
}
}
recordingService.stopRecordingShowForClient(scope, client);
@@ -546,27 +438,11 @@ public class ScopeApplicationAdapter extends MultiThreadedApplicationAdapter imp
// and room except the current disconnected cause it could throw an exception
_log.debug("currentScope " + scope);
- new MessageSender(scope, "roomDisconnect", client, this) {
- @Override
- public boolean filter(IConnection conn) {
- StreamClient rcl = sessionManager.getClientByStreamId(conn.getClient().getId(), null);
- if (rcl == null) {
- return true;
- }
- boolean isScreen = rcl.isScreenClient();
- if (isScreen && client.getPublicSID().equals(rcl.getStreamPublishName())) {
- //going to terminate screen sharing started by this client
- ((IServiceCapableConnection) conn).invoke("stopStream", new Object[] { }, callback);
- }
- return isScreen;
- }
- }.start();
-
if (client.isMobile()) {
IApplication app = (IApplication)Application.get(wicketApplicationName);
- app.exit(client.getPublicSID());
+ app.exit(client.getUid());
}
- sessionManager.removeClient(client.getStreamid(), null);
+ sessionManager.remove(client.getId());
} catch (Exception err) {
_log.error("[roomLeaveByScope]", err);
}
@@ -585,73 +461,71 @@ public class ScopeApplicationAdapter extends MultiThreadedApplicationAdapter imp
try {
_log.debug("----------- streamPublishStart");
IConnection current = Red5.getConnectionLocal();
- final String streamid = current.getClient().getId();
- final StreamClient c = sessionManager.getClientByStreamId(streamid, null);
-
- //We make a second object the has the reference to the object
- //that we will use to send to all participents
- StreamClient clientObjectSendToSync = c;
+ final StreamClient c = sessionManager.get(IClientUtil.getId(current.getClient()));
// Notify all the clients that the stream had been started
String streamName = stream.getPublishedName();
- _log.debug("start streamPublishStart broadcast start: " + streamName + " CONN " + current);
+ _log.debug("start streamPublishStart broadcast start: {}, CONN {}", streamName, current);
c.setBroadCastId(streamName);
// In case its a screen sharing we start a new Video for that
- if (c.isScreenClient()) {
- c.setScreenPublishStarted(true);
- sessionManager.updateClientByStreamId(streamid, c, false, null);
+ if (c.isSharing()) {
+ c.setSharingStarted(true);
}
- if (!c.isMobile() && !Strings.isEmpty(c.getSecurityCode())) {
+ /* TODO different handling is required for ext video source
+ if (!c.isMobile() && !Strings.isEmpty(c.getOwnerSid())) {
c.setAvsettings("av");
- c.setIsBroadcasting(true);
- if (c.getVWidth() == 0 || c.getVHeight() == 0) {
- c.setVWidth(320);
- c.setVHeight(240);
+ c.setBroadcasting(true);
+ if (c.getWidth() == 0 || c.getHeight() == 0) {
+ c.setWidth(320);
+ c.setHeight(240);
}
- sessionManager.updateClientByStreamId(streamid, c, false, null);
}
+ */
+ sessionManager.update(c);
- _log.debug("newStream SEND: " + c);
+ _log.debug("newStream SEND: {}", c);
// Notify all users of the same Scope
// We need to iterate through the streams to catch if anybody is recording
- new MessageSender(current, "newStream", clientObjectSendToSync, this) {
+ new MessageSender(current, "newStream", c, this) {
@Override
public boolean filter(IConnection conn) {
- StreamClient rcl = sessionManager.getClientByStreamId(conn.getClient().getId(), null);
+ StreamClient rcl = sessionManager.get(IClientUtil.getId(conn.getClient()));
if (rcl == null) {
_log.debug("RCL IS NULL newStream SEND");
return true;
}
- _log.debug("check send to "+rcl);
+ _log.debug("check send to {}", rcl);
- if (Strings.isEmpty(rcl.getPublicSID())) {
+ if (Strings.isEmpty(rcl.getUid())) {
_log.debug("publicSID IS NULL newStream SEND");
return true;
}
- if (rcl.getIsRecording()) {
+ if (rcl.isRecordingStarted()) {
_log.debug("RCL getIsRecording newStream SEND");
recordingService.addRecordingByStreamId(current, c, rcl.getRecordingId());
}
- if (rcl.isScreenClient()) {
- _log.debug("RCL getIsScreenClient newStream SEND");
+ if (rcl.isSharing()) {
+ _log.debug("RCL getisSharing newStream SEND");
return true;
}
- if (rcl.getPublicSID().equals(c.getPublicSID())) {
+ if (rcl.getUid().equals(c.getUid())) {
_log.debug("RCL publicSID is equal newStream SEND");
return true;
}
- _log.debug("RCL SEND is equal newStream SEND "+rcl.getPublicSID()+" || "+rcl.getUserport());
+ _log.debug("RCL SEND is equal newStream SEND {} || {}", rcl.getUid(), rcl.getUserport());
return false;
}
}.start();
JSONObject obj = new JSONObject()
- .put("uid", c.getPublicSID())
- .put("screenShare", c.isScreenClient())
+ .put("ownerSid", c.getOwnerSid())
+ .put("uid", c.getUid())
+ .put("screenShare", c.isSharing())
+ .put("streamClientId", c.getId())
.put("stream", streamName);
WebSocketHelper.sendRoom(new TextRoomMessage(c.getRoomId(), c.getUserId(), RoomMessage.Type.newStream, obj.toString()));
} catch (Exception err) {
@@ -670,11 +544,10 @@ public class ScopeApplicationAdapter extends MultiThreadedApplicationAdapter imp
@Override
public void streamBroadcastClose(IBroadcastStream stream) {
// Notify all the clients that the stream had been closed
- _log.debug("start streamBroadcastClose broadcast close: " + stream.getPublishedName());
+ _log.debug("start streamBroadcastClose broadcast close: {}", stream.getPublishedName());
try {
IConnection current = Red5.getConnectionLocal();
- String streamId = current.getClient().getId();
- StreamClient rcl = sessionManager.getClientByStreamId(streamId, null);
+ StreamClient rcl = sessionManager.get(IClientUtil.getId(current.getClient()));
if (rcl == null) {
@@ -688,36 +561,41 @@ public class ScopeApplicationAdapter extends MultiThreadedApplicationAdapter imp
}
// Notify all the clients that the stream had been started
- _log.debug("streamBroadcastClose : " + rcl + " " + rcl.getStreamid());
+ _log.debug("streamBroadcastClose : {} ", rcl);
// this close stream event, stop the recording of this stream
- if (rcl.getIsRecording()) {
+ if (rcl.isRecordingStarted()) {
_log.debug("*** +++++++ ######## sendClientBroadcastNotifications Any Client is Recording - stop that");
recordingService.stopRecordingShowForClient(current.getScope(), rcl);
}
if (stream.getPublishedName().equals(rcl.getBroadCastId())) {
- rcl.setBroadCastId("-1");
- rcl.setIsBroadcasting(false);
+ rcl.setBroadCastId(null);
+ rcl.setBroadcasting(false);
rcl.setAvsettings("n");
}
- sessionManager.updateClientByStreamId(streamId, rcl, false, null);
+ sessionManager.update(rcl);
// Notify all clients of the same scope (room)
sendMessageToCurrentScope("closeStream", rcl, rcl.isMobile());
- if (rcl.isScreenClient()) {
- WebSocketHelper.sendRoom(new TextRoomMessage(rcl.getRoomId(), rcl.getUserId(), RoomMessage.Type.sharingStoped, rcl.getPublicSID()));
+ if (rcl.isSharing()) {
+ sendSharingStoped(rcl);
}
} catch (Exception e) {
_log.error("[streamBroadcastClose]", e);
}
}
- @SuppressWarnings("unchecked")
- public void setNewCursorPosition(Object item) {
+ private void sendSharingStoped(StreamClient rcl) {
+ JSONObject obj = new JSONObject()
+ .put("ownerSid", rcl.getOwnerSid())
+ .put("uid", rcl.getUid());
+ WebSocketHelper.sendRoom(new TextRoomMessage(rcl.getRoomId(), rcl.getUserId(), RoomMessage.Type.sharingStoped, obj.toString()));
+ }
+
+ /** TODO need to be implemented in Flex
+ public void setNewCursorPosition(Map<String, Object> cursor) {
try {
IConnection current = Red5.getConnectionLocal();
StreamClient c = sessionManager.getClientByStreamId(current.getClient().getId(), null);
- @SuppressWarnings("rawtypes")
- Map cursor = (Map) item;
cursor.put("streamPublishName", c.getStreamPublishName());
sendMessageToCurrentScope("newRed5ScreenCursor", cursor, true, false);
@@ -725,18 +603,19 @@ public class ScopeApplicationAdapter extends MultiThreadedApplicationAdapter imp
_log.error("[setNewCursorPosition]", err);
}
}
+ */
public long switchMicMuted(String publicSID, boolean mute) {
try {
_log.debug("----------- switchMicMuted: " + publicSID);
- StreamClient currentClient = sessionManager.getClientByPublicSID(publicSID, null);
+ StreamClient currentClient = sessionManager.getClientByUid(publicSID, null);
if (currentClient == null) {
return -1L;
}
currentClient.setMicMuted(mute);
- sessionManager.updateClientByStreamId(currentClient.getStreamid(), currentClient, false, null);
+ sessionManager.update(currentClient);
Map<Integer, Object> newMessage = new HashMap<>();
newMessage.put(0, "updateMuteStatus");
@@ -793,8 +672,8 @@ public class ScopeApplicationAdapter extends MultiThreadedApplicationAdapter imp
new MessageSender(getRoomScope("" + roomId), method, obj, this) {
@Override
public boolean filter(IConnection conn) {
- StreamClient rcl = sessionManager.getClientByStreamId(conn.getClient().getId(), null);
- return rcl == null || rcl.isScreenClient()
+ StreamClient rcl = sessionManager.get(IClientUtil.getId(conn.getClient()));
+ return rcl == null || rcl.isSharing()
|| rcl.getRoomId() == null || !rcl.getRoomId().equals(roomId) || userDao.get(rcl.getUserId()) == null;
}
}.start();
@@ -843,7 +722,7 @@ public class ScopeApplicationAdapter extends MultiThreadedApplicationAdapter imp
@Override
public boolean filter(IConnection conn) {
IClient client = conn.getClient();
- return (!sendScreen && SessionVariablesUtil.isScreenClient(client))
+ return (!sendScreen && IClientUtil.isSharing(client))
|| (!sendSelf && current != null && client.getId().equals(current.getClient().getId()));
}
}.start();
@@ -933,7 +812,7 @@ public class ScopeApplicationAdapter extends MultiThreadedApplicationAdapter imp
public int sendMessageWithClientWithSyncObject(Object newMessage, boolean sync) {
try {
IConnection current = Red5.getConnectionLocal();
- StreamClient currentClient = sessionManager.getClientByStreamId(current.getClient().getId(), null);
+ StreamClient currentClient = sessionManager.get(IClientUtil.getId(current.getClient()));
Map<String, Object> hsm = new HashMap<>();
hsm.put("client", currentClient);
@@ -957,9 +836,9 @@ public class ScopeApplicationAdapter extends MultiThreadedApplicationAdapter imp
* @param clientId
* @return 1 in case of success, -1 otherwise
*/
- public int sendMessageById(Object newMessage, String clientId, IScope scope) {
+ public int sendMessageById(Object newMessage, final Long id, IScope scope) {
try {
- _log.debug("### sendMessageById ###" + clientId);
+ _log.debug("### sendMessageById ### {}", id);
Map<String, Object> hsm = new HashMap<>();
hsm.put("message", newMessage);
@@ -968,7 +847,7 @@ public class ScopeApplicationAdapter extends MultiThreadedApplicationAdapter imp
for (IConnection conn : scope.getClientConnections()) {
if (conn != null) {
if (conn instanceof IServiceCapableConnection) {
- if (conn.getClient().getId().equals(clientId)) {
+ if (id.equals(IClientUtil.getId(conn.getClient()))) {
((IServiceCapableConnection) conn).invoke("sendVarsToMessageWithClient", new Object[] { hsm }, this);
}
}
@@ -991,7 +870,7 @@ public class ScopeApplicationAdapter extends MultiThreadedApplicationAdapter imp
public int sendMessageWithClientById(Object newMessage, String clientId) {
try {
IConnection current = Red5.getConnectionLocal();
- StreamClient currentClient = sessionManager.getClientByStreamId(current.getClient().getId(), null);
+ StreamClient currentClient = sessionManager.get(IClientUtil.getId(current.getClient()));
Map<String, Object> hsm = new HashMap<>();
hsm.put("client", currentClient);
@@ -1023,9 +902,9 @@ public class ScopeApplicationAdapter extends MultiThreadedApplicationAdapter imp
for (IConnection conn : current.getScope().getClientConnections()) {
if (conn != null) {
- StreamClient rcl = sessionManager.getClientByStreamId(conn.getClient().getId(), null);
+ StreamClient rcl = sessionManager.get(IClientUtil.getId(conn.getClient()));
- if (rcl.getIsRecording()) {
+ if (rcl != null && rcl.isRecordingStarted()) {
return true;
}
}
@@ -1048,19 +927,18 @@ public class ScopeApplicationAdapter extends MultiThreadedApplicationAdapter imp
for (IConnection conn : current.getScope().getClientConnections()) {
if (conn != null) {
- StreamClient rcl = sessionManager.getClientByStreamId(conn.getClient().getId(), null);
+ StreamClient rcl = sessionManager.get(IClientUtil.getId(conn.getClient()));
- if (rcl != null && rcl.getIsRecording()) {
+ if (rcl != null && rcl.isRecordingStarted()) {
return false;
}
}
}
- StreamClient current_rcl = sessionManager.getClientByStreamId(current.getClient().getId(), null);
+ StreamClient rcl = sessionManager.get(IClientUtil.getId(current.getClient()));
- // Also set the Recording Flag to Record all Participants that enter
- // later
- current_rcl.setIsRecording(true);
- sessionManager.updateClientByStreamId(current.getClient().getId(), current_rcl, false, null);
+ // Also set the Recording Flag to Record all Participants that enter later
+ rcl.setRecordingStarted(true);
+ sessionManager.update(rcl);
Map<String, String> interviewStatus = new HashMap<>();
interviewStatus.put("action", "start");
@@ -1068,7 +946,7 @@ public class ScopeApplicationAdapter extends MultiThreadedApplicationAdapter imp
for (IConnection conn : current.getScope().getClientConnections()) {
if (conn != null) {
IClient client = conn.getClient();
- if (SessionVariablesUtil.isScreenClient(client)) {
+ if (IClientUtil.isSharing(client)) {
// screen sharing clients do not receive events
continue;
}
@@ -1079,7 +957,7 @@ public class ScopeApplicationAdapter extends MultiThreadedApplicationAdapter imp
}
String recordingName = "Interview " + CalendarPatterns.getDateWithTimeByMiliSeconds(new Date());
- recordingService.recordMeetingStream(current, current_rcl, recordingName, "", true);
+ recordingService.recordMeetingStream(current, rcl, recordingName, "", true);
return true;
} catch (Exception err) {
@@ -1095,29 +973,12 @@ public class ScopeApplicationAdapter extends MultiThreadedApplicationAdapter imp
@Override
public boolean filter(IConnection conn) {
IClient client = conn.getClient();
- return !SessionVariablesUtil.isScreenClient(client) || !conn.getClient().getId().equals(streamid);
+ return !IClientUtil.isSharing(client) || !conn.getClient().getId().equals(streamid);
}
}.start();
return true;
}
- private Long checkRecordingClient(IConnection conn) {
- Long recordingId = null;
- if (conn != null) {
- StreamClient rcl = sessionManager.getClientByStreamId(conn.getClient().getId(), null);
- if (rcl != null && rcl.getIsRecording()) {
- rcl.setIsRecording(false);
- recordingId = rcl.getRecordingId();
- rcl.setRecordingId(null);
-
- // Reset the Recording Flag to Record all
- // Participants that enter later
- sessionManager.updateClientByStreamId(conn.getClient().getId(), rcl, false, null);
- }
- }
- return recordingId;
- }
-
/**
* Stop the recording of the streams and send event to connected users of scope
*
@@ -1125,7 +986,7 @@ public class ScopeApplicationAdapter extends MultiThreadedApplicationAdapter imp
*/
public boolean stopInterviewRecording() {
IConnection current = Red5.getConnectionLocal();
- StreamClient currentClient = sessionManager.getClientByStreamId(current.getClient().getId(), null);
+ StreamClient currentClient = sessionManager.get(IClientUtil.getId(current.getClient()));
return _stopInterviewRecording(currentClient, current.getScope());
}
@@ -1140,7 +1001,19 @@ public class ScopeApplicationAdapter extends MultiThreadedApplicationAdapter imp
Long clientRecordingId = currentClient.getRecordingId();
for (IConnection conn : currentScope.getClientConnections()) {
- Long recordingId = checkRecordingClient(conn);
+ Long recordingId = null;
+ if (conn != null) {
+ StreamClient rcl = sessionManager.get(IClientUtil.getId(conn.getClient()));
+ if (rcl != null && rcl.isRecordingStarted()) {
+ rcl.setRecordingStarted(false);
+ recordingId = rcl.getRecordingId();
+ rcl.setRecordingId(null);
+
+ // Reset the Recording Flag to Record all
+ // Participants that enter later
+ sessionManager.update(rcl);
+ }
+ }
if (recordingId != null) {
clientRecordingId = recordingId;
}
@@ -1221,16 +1094,15 @@ public class ScopeApplicationAdapter extends MultiThreadedApplicationAdapter imp
public synchronized int updateSipTransport() {
_log.debug("----------- updateSipTransport");
IConnection current = Red5.getConnectionLocal();
- String streamid = current.getClient().getId();
- StreamClient client = sessionManager.getClientByStreamId(streamid, null);
+ StreamClient client = sessionManager.get(IClientUtil.getId(current.getClient()));
Long roomId = client.getRoomId();
Integer count = getSipConferenceMembersNumber(roomId);
String newNumber = getSipTransportLastname(count);
_log.debug("getSipConferenceMembersNumber: " + newNumber);
if (!newNumber.equals(client.getLastname())) {
client.setLastname(newNumber);
- sessionManager.updateClientByStreamId(streamid, client, false, null);
- _log.debug("updateSipTransport: {}, {}, {}, {}, {}", new Object[] { client.getPublicSID(), client.getRoomId(),
+ sessionManager.update(client);
+ _log.debug("updateSipTransport: {}, {}, {}, {}, {}", new Object[] { client.getUid(), client.getRoomId(),
client.getFirstname(), client.getLastname(), client.getAvsettings() });
sendMessageWithClient(new String[] { "personal", client.getFirstname(), client.getLastname() });
}
@@ -1241,22 +1113,21 @@ public class ScopeApplicationAdapter extends MultiThreadedApplicationAdapter imp
_log.debug("----------- setSipTransport");
IConnection current = Red5.getConnectionLocal();
IClient c = current.getClient();
- String streamid = c.getId();
// Notify all clients of the same scope (room)
- StreamClient currentClient = sessionManager.getClientByStreamId(streamid, null);
+ StreamClient currentClient = sessionManager.get(IClientUtil.getId(c));
currentClient.setSipTransport(true);
- currentClient.setRoomId(roomId);
+ currentClient.setScope("" + roomId);
currentClient.setRoomEnter(new Date());
currentClient.setFirstname("SIP Transport");
currentClient.setLastname(getSipTransportLastname(roomId));
currentClient.setBroadCastId(broadCastId);
- currentClient.setIsBroadcasting(true);
- currentClient.setPublicSID(publicSID);
- currentClient.setVWidth(120);
- currentClient.setVHeight(90);
+ currentClient.setBroadcasting(true);
+ currentClient.setUid(publicSID);
+ currentClient.setWidth(120);
+ currentClient.setHeight(90);
currentClient.setPicture_uri("phone.png");
- sessionManager.updateClientByStreamId(streamid, currentClient, false, null);
- SessionVariablesUtil.initClient(c, publicSID);
+ sessionManager.update(currentClient);
+ IClientUtil.init(c, currentClient.getId(), false);
sendMessageToCurrentScope("addNewUser", currentClient, false);
}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/117e8d6b/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/UserService.java
----------------------------------------------------------------------
diff --git a/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/UserService.java b/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/UserService.java
deleted file mode 100644
index 6df8b37..0000000
--- a/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/UserService.java
+++ /dev/null
@@ -1,225 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License") + you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.openmeetings.core.remote;
-
-import static org.apache.openmeetings.util.OpenmeetingsVariables.webAppRootKey;
-import static org.apache.openmeetings.util.OpenmeetingsVariables.wicketApplicationName;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.openmeetings.IApplication;
-import org.apache.openmeetings.db.dao.server.ISessionManager;
-import org.apache.openmeetings.db.dao.server.ServerDao;
-import org.apache.openmeetings.db.dao.server.SessiondataDao;
-import org.apache.openmeetings.db.dao.user.IUserService;
-import org.apache.openmeetings.db.dao.user.UserDao;
-import org.apache.openmeetings.db.entity.room.StreamClient;
-import org.apache.openmeetings.db.entity.server.Server;
-import org.apache.openmeetings.db.entity.server.Sessiondata;
-import org.apache.openmeetings.db.entity.user.User;
-import org.apache.openmeetings.db.util.AuthLevelUtil;
-import org.apache.wicket.Application;
-import org.red5.logging.Red5LoggerFactory;
-import org.red5.server.api.scope.IScope;
-import org.slf4j.Logger;
-import org.springframework.beans.factory.annotation.Autowired;
-
-/**
- * Provides method to manipulate {@link User}
- *
- * @author sebawagner
- *
- */
-public class UserService implements IUserService {
- private static final Logger log = Red5LoggerFactory.getLogger(UserService.class, webAppRootKey);
-
- @Autowired
- private ISessionManager sessionManager;
- @Autowired
- private ScopeApplicationAdapter scopeApplicationAdapter;
- @Autowired
- private SessiondataDao sessionDao;
- @Autowired
- private UserDao userDao;
- @Autowired
- private ServerDao serverDao;
- @Autowired
- private ISlaveHTTPConnectionManager slaveHTTPConnectionManager;
-
- /**
- * get user by id, admin only
- *
- * @param sid
- * @param userId
- * @return User with the id given
- */
- public User getUserById(String sid, long userId) {
- Sessiondata sd = sessionDao.check(sid);
- if (AuthLevelUtil.hasUserLevel(userDao.getRights(sd.getUserId()))) {
- return userDao.get(userId);
- }
- return null;
- }
-
- /**
- * refreshes the current SID
- *
- * @param SID
- * @return "ok" string in case of success, "error" string in case of the error
- */
- public String refreshSession(String SID) {
- try {
- sessionDao.check(SID);
- return "ok";
- } catch (Exception err) {
- log.error("[refreshSession]", err);
- }
- return "error";
- }
-
- /**
- * gets a whole user-list(admin-role only)
- *
- * @param sid
- * @param start
- * @param max
- * @param orderby
- * @return whole user-list
- */
- public List<User> getUserList(String sid, int start, int max, String orderby, boolean asc) {
- Sessiondata sd = sessionDao.check(sid);
- if (AuthLevelUtil.hasAdminLevel(userDao.getRights(sd.getUserId()))) {
- return userDao.get("", start, max, orderby + (asc ? " ASC" : " DESC"));
- }
- return null;
- }
-
- /**
- * kicks a user from the server, also from slaves if needed, this method is
- * only invoked by the connection administration UI
- *
- * @param sid
- * @param streamid
- * @param serverId
- * 0 means the session is locally, otherwise we have to perform a
- * REST call
- * @return - true if user has sufficient permissions, false otherwise
- */
- @Override
- public boolean kickUserByStreamId(String sid, String streamid, long serverId) {
- try {
- Sessiondata sd = sessionDao.check(sid);
- // admins only
- if (AuthLevelUtil.hasAdminLevel(userDao.getRights(sd.getUserId()))) {
- if (serverId == 0) {
- StreamClient rcl = sessionManager.getClientByStreamId(streamid, null);
-
- if (rcl == null) {
- return true;
- }
- String scopeName = "hibernate";
- if (rcl.getRoomId() != null) {
- scopeName = rcl.getRoomId().toString();
- }
- IScope currentScope = scopeApplicationAdapter.getRoomScope(scopeName);
-
- Map<Integer, String> messageObj = new HashMap<>();
- messageObj.put(0, "kick");
- scopeApplicationAdapter.sendMessageById(messageObj, streamid, currentScope);
-
- scopeApplicationAdapter.roomLeaveByScope(rcl, currentScope);
-
- return true;
- } else {
- Server server = serverDao.get(serverId);
- StreamClient rcl = sessionManager.getClientByStreamId(
- streamid, server);
- slaveHTTPConnectionManager.kickSlaveUser(server, rcl.getPublicSID());
-
- // true means only the REST call is performed, it is no
- // confirmation that the user is really kicked from the
- // slave
- return true;
- }
- }
- } catch (Exception err) {
- log.error("[kickUserByStreamId]", err);
- }
- return false;
- }
-
- /**
- * Kick a user by its publicSID.<br/>
- * <br/>
- * <i>Note:</i>
- * This method will not perform a call to the slave, cause this call can only be
- * invoked from inside the conference room, that means all clients are on the
- * same server, no matter if clustered or not.
- *
- * @param sid
- * @param publicSID
- * @return - true in case user have sufficient permissions, null otherwise
- */
- public boolean kickUserByPublicSID(String sid, String publicSID) {
- try {
- Sessiondata sd = sessionDao.check(sid);
- // users only
- if (AuthLevelUtil.hasUserLevel(userDao.getRights(sd.getUserId()))) {
- StreamClient rcl = sessionManager.getClientByPublicSID(publicSID, null);
-
- if (rcl == null) {
- return true;
- }
- String scopeName = "hibernate";
- if (rcl.getRoomId() != null) {
- scopeName = rcl.getRoomId().toString();
- }
- IScope currentScope = scopeApplicationAdapter.getRoomScope(scopeName);
-
- Map<Integer, String> messageObj = new HashMap<>();
- messageObj.put(0, "kick");
-
- scopeApplicationAdapter.sendMessageById(messageObj, rcl.getStreamid(), currentScope);
- scopeApplicationAdapter.roomLeaveByScope(rcl, currentScope);
-
- return true;
- }
- } catch (Exception err) {
- log.error("[kickUserByPublicSID]", err);
- }
- return false;
- }
-
- @Override
- public boolean kickUserBySessionId(String sid, long userId, String sessionId) {
- try {
- Sessiondata sd = sessionDao.check(sid);
- // admin only
- if (AuthLevelUtil.hasAdminLevel(userDao.getRights(sd.getUserId()))) {
- ((IApplication)Application.get(wicketApplicationName)).invalidateClient(userId, sessionId);
- return true;
- }
- } catch (Exception err) {
- log.error("[kickUserBySessionId]", err);
- }
- return false;
- }
-}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/117e8d6b/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/util/SessionVariablesUtil.java
----------------------------------------------------------------------
diff --git a/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/util/SessionVariablesUtil.java b/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/util/SessionVariablesUtil.java
deleted file mode 100644
index 41502dd..0000000
--- a/openmeetings-core/src/main/java/org/apache/openmeetings/core/remote/util/SessionVariablesUtil.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License") + you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.openmeetings.core.remote.util;
-
-import static org.apache.openmeetings.util.OpenmeetingsVariables.webAppRootKey;
-
-import org.red5.logging.Red5LoggerFactory;
-import org.red5.server.api.IClient;
-import org.slf4j.Logger;
-
-public class SessionVariablesUtil {
- private static final Logger log = Red5LoggerFactory.getLogger(SessionVariablesUtil.class, webAppRootKey);
-
- private enum SESSION_VARIABLES {
- isScreenClient, // if the client connection is from a Java Web-Start application
- PUBLIC_SID, // the public SID of the client
- USER_ID, // the userId of the user that is using this connection (if there is any)
- }
-
- public static void initClient(IClient client, String publicSID) {
- client.setAttribute(SESSION_VARIABLES.PUBLIC_SID.toString(), publicSID);
- }
-
- public static String getPublicSID(IClient client) {
- try {
- if (client.getAttribute(SESSION_VARIABLES.PUBLIC_SID.toString()) == null) {
- throw new Exception("Connection has no publicSID client: " + client);
- }
- return (String) client.getAttribute(SESSION_VARIABLES.PUBLIC_SID.toString());
- } catch (Exception err) {
- log.error("[getPublicSID]", err);
- }
- return null;
- }
-
- public static void setIsScreenClient(IClient client) {
- client.setAttribute(SESSION_VARIABLES.isScreenClient.toString(), true);
- }
-
- public static boolean isScreenClient(IClient client) {
- try {
- if (client.getAttribute(SESSION_VARIABLES.isScreenClient.toString()) == null) {
- return false;
- }
- if ((Boolean) client.getAttribute(SESSION_VARIABLES.isScreenClient.toString())) {
- return true;
- }
- } catch (Exception err) {
- log.error("[isScreenClient]", err);
- }
- return false;
- }
-
- public static void setUserId(IClient client, Long userId) {
- client.setAttribute(SESSION_VARIABLES.USER_ID.toString(), userId);
- }
-
- /**
- * if there is no user id set, it will return Long.MIN_VALUE
- *
- * @param client
- * @return - user id set or Long.MIN_VALUE or null if any exception happens
- */
- public static Long getUserId(IClient client) {
- try {
- if (client.getAttribute(SESSION_VARIABLES.USER_ID.toString()) == null) {
- return Long.MIN_VALUE;
- }
- return (Long) client.getAttribute(SESSION_VARIABLES.USER_ID.toString());
- } catch (Exception err) {
- log.error("[getUserId]", err);
- }
- return null;
- }
-}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/117e8d6b/openmeetings-core/src/main/java/org/apache/openmeetings/core/session/SessionManager.java
----------------------------------------------------------------------
diff --git a/openmeetings-core/src/main/java/org/apache/openmeetings/core/session/SessionManager.java b/openmeetings-core/src/main/java/org/apache/openmeetings/core/session/SessionManager.java
index 8e937d5..ef53bfb 100644
--- a/openmeetings-core/src/main/java/org/apache/openmeetings/core/session/SessionManager.java
+++ b/openmeetings-core/src/main/java/org/apache/openmeetings/core/session/SessionManager.java
@@ -24,10 +24,8 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Date;
-import java.util.LinkedList;
import java.util.List;
import java.util.Map.Entry;
-import java.util.UUID;
import org.apache.openmeetings.core.session.store.IClientPersistenceStore;
import org.apache.openmeetings.db.dao.server.ISessionManager;
@@ -35,7 +33,6 @@ import org.apache.openmeetings.db.dto.basic.SearchResult;
import org.apache.openmeetings.db.dto.server.ClientSessionInfo;
import org.apache.openmeetings.db.entity.room.StreamClient;
import org.apache.openmeetings.db.entity.server.Server;
-import org.apache.wicket.util.string.Strings;
import org.red5.logging.Red5LoggerFactory;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
@@ -84,53 +81,9 @@ public class SessionManager implements ISessionManager {
}
c.setConnectedSince(new Date());
c.setRoomEnter(new Date());
- if (Strings.isEmpty(c.getPublicSID())) {
- c.setPublicSID(UUID.randomUUID().toString());
- }
c.setServer(server);
- if (cache.containsKey(null, c.getStreamid())) {
- log.error("Tried to add an existing Client " + c.getStreamid());
- return null;
- }
-
- cache.put(c.getStreamid(), c);
- return c;
- }
-
- @Override
- public StreamClient addClientListItem(String streamId, String scopeName,
- int remotePort, String remoteAddress, String swfUrl, Server server) {
- if (server == null) {
- server = serverUtil.getCurrentServer();
- }
- try {
-
- // Store the Connection into a bean and add it to the HashMap
- StreamClient rcm = new StreamClient();
- rcm.setConnectedSince(new Date());
- rcm.setStreamid(streamId);
- rcm.setScope(scopeName);
- rcm.setPublicSID(UUID.randomUUID().toString());
- rcm.setServer(server);
- rcm.setUserport(remotePort);
- rcm.setUserip(remoteAddress);
- rcm.setSwfurl(swfUrl);
- rcm.setIsMod(false);
- rcm.setCanDraw(false);
-
- if (cache.containsKey(null, streamId)) {
- log.error("Tried to add an existing Client " + streamId);
- return null;
- }
-
- cache.put(rcm.getStreamid(), rcm);
-
- return rcm;
- } catch (Exception err) {
- log.error("[addClientListItem]", err);
- }
- return null;
+ return cache.put(c);
}
@Override
@@ -144,16 +97,13 @@ public class SessionManager implements ISessionManager {
}
@Override
- public StreamClient getClientByStreamId(String streamId, Server server) {
- if (server == null) {
- server = serverUtil.getCurrentServer();
- }
+ public StreamClient get(Long id) {
try {
- if (!cache.containsKey(server, streamId)) {
- log.debug("Tried to get a non existing Client " + streamId + " server " + server);
+ if (!cache.containsKey(id)) {
+ log.debug("Tried to get a non existing Client {}", id);
return null;
}
- return cache.get(server, streamId);
+ return cache.get(id);
} catch (Exception err) {
log.error("[getClientByStreamId]", err);
}
@@ -161,12 +111,12 @@ public class SessionManager implements ISessionManager {
}
@Override
- public StreamClient getClientByPublicSID(String publicSID, Server server) {
+ public StreamClient getClientByUid(String publicSID, Server server) {
if (server == null) {
server = serverUtil.getCurrentServer();
}
try {
- List<StreamClient> list = cache.getClientsByPublicSID(server, publicSID);
+ List<StreamClient> list = cache.getClientsByUid(server, publicSID);
return list == null || list.isEmpty() ? null : list.get(0);
} catch (Exception err) {
log.error("[getClientByPublicSID]", err);
@@ -175,9 +125,9 @@ public class SessionManager implements ISessionManager {
}
@Override
- public ClientSessionInfo getClientByPublicSIDAnyServer(String publicSID) {
+ public ClientSessionInfo getClientByUidAnyServer(String publicSID) {
try {
- for (Entry<Long,List<StreamClient>> entry : cache.getClientsByPublicSID(publicSID).entrySet()) {
+ for (Entry<Long,List<StreamClient>> entry : cache.getClientsByUid(publicSID).entrySet()) {
for (StreamClient rcl : entry.getValue()) {
return new ClientSessionInfo(rcl, entry.getKey());
}
@@ -189,83 +139,51 @@ public class SessionManager implements ISessionManager {
}
@Override
- public StreamClient getClientByUserId(Long userId) {
- try {
- for (StreamClient rcl : cache.getClientsByUserId(null, userId)) {
- if (rcl.isScreenClient()) {
- continue;
- }
-
- return rcl;
- }
- } catch (Exception err) {
- log.error("[getClientByUserId]", err);
- }
- return null;
- }
-
- @Override
- public boolean updateAVClientByStreamId(String streamId, StreamClient rcm, Server server) {
- if (server == null) {
- server = serverUtil.getCurrentServer();
- }
+ public boolean updateAVClient(StreamClient rcm) {
try {
// get the corresponding user session object and update the settings
- StreamClient rclUsual = getClientByPublicSID(rcm.getPublicSID(), server);
+ StreamClient rclUsual = get(rcm.getId());
if (rclUsual != null) {
rclUsual.setBroadCastId(rcm.getBroadCastId());
rclUsual.setAvsettings(rcm.getAvsettings());
- rclUsual.setVHeight(rcm.getVHeight());
- rclUsual.setVWidth(rcm.getVWidth());
- rclUsual.setVX(rcm.getVX());
- rclUsual.setVY(rcm.getVY());
- StreamClient rclSaved = cache.get(server, rclUsual.getStreamid());
- if (rclSaved != null) {
- cache.put(rclUsual.getStreamid(), rclUsual);
- } else {
- log.debug("Tried to update a non existing Client " + rclUsual.getStreamid());
- }
+ rclUsual.setHeight(rcm.getHeight());
+ rclUsual.setWidth(rcm.getWidth());
+ cache.put(rclUsual);
+ } else {
+ log.debug("Tried to update a non existing Client {}", rclUsual);
}
- updateClientByStreamId(streamId, rcm, false, server);
+ update(rcm);
return true;
} catch (Exception err) {
- log.error("[updateAVClientByStreamId]", err);
+ log.error("[updateAVClient]", err);
}
return false;
}
@Override
- public boolean updateClientByStreamId(String streamId, StreamClient rcm, boolean updateRoomCount, Server server) {
- if (server == null) {
- server = serverUtil.getCurrentServer();
- }
+ public boolean update(StreamClient rcm) {
try {
- StreamClient rclSaved = cache.get(server, streamId);
-
- if (rclSaved != null) {
- cache.put(streamId, rcm);
+ if (cache.containsKey(rcm.getId())) {
+ cache.put(rcm);
return true;
} else {
- log.debug("Tried to update a non existing Client " + streamId);
+ log.debug("Tried to update a non existing Client {}", rcm.getId());
}
} catch (Exception err) {
- log.error("[updateClientByStreamId]", err);
+ log.error("[updateClient]", err);
}
return false;
}
@Override
- public boolean removeClient(String streamId, Server server) {
- if (server == null) {
- server = serverUtil.getCurrentServer();
- }
+ public boolean remove(Long id) {
try {
- if (cache.containsKey(server,streamId)) {
- cache.remove(server,streamId);
+ if (cache.containsKey(id)) {
+ cache.remove(id);
return true;
} else {
- log.debug("Tried to remove a non existing Client " + streamId);
+ log.debug("Tried to remove a non existing Client {}", id);
}
} catch (Exception err) {
log.error("[removeClient]", err);
@@ -278,7 +196,7 @@ public class SessionManager implements ISessionManager {
List<StreamClient> roomClientList = new ArrayList<>();
try {
for (StreamClient rcl : cache.getClientsByRoomId(roomId)) {
- if (rcl.isScreenClient()) {
+ if (rcl.isSharing()) {
continue;
}
@@ -304,18 +222,6 @@ public class SessionManager implements ISessionManager {
}
@Override
- public List<StreamClient> getCurrentModeratorByRoom(Long roomId) {
- List<StreamClient> rclList = new LinkedList<>();
- List<StreamClient> currentClients = this.getClientListByRoom(roomId);
- for (StreamClient rcl : currentClients) {
- if (rcl.getIsMod()) {
- rclList.add(rcl);
- }
- }
- return rclList;
- }
-
- @Override
public SearchResult<StreamClient> getListByStartAndMax(int start, int max, String orderby, boolean asc) {
SearchResult<StreamClient> sResult = new SearchResult<>();
sResult.setObjectName(StreamClient.class.getName());
@@ -329,7 +235,7 @@ public class SessionManager implements ISessionManager {
List<StreamClient> currentClients = this.getClientListByRoom(roomId);
int numberOfRecordingUsers = 0;
for (StreamClient rcl : currentClients) {
- if (rcl.isStartRecording()) {
+ if (rcl.isRecordingStarted()) {
numberOfRecordingUsers++;
}
}
@@ -341,7 +247,7 @@ public class SessionManager implements ISessionManager {
List<StreamClient> currentClients = this.getClientListByRoom(roomId);
int numberOfPublishingUsers = 0;
for (StreamClient rcl : currentClients) {
- if (rcl.isStreamPublishStarted()) {
+ if (rcl.isPublishStarted()) {
numberOfPublishingUsers++;
}
}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/117e8d6b/openmeetings-core/src/main/java/org/apache/openmeetings/core/session/store/DatabaseStore.java
----------------------------------------------------------------------
diff --git a/openmeetings-core/src/main/java/org/apache/openmeetings/core/session/store/DatabaseStore.java b/openmeetings-core/src/main/java/org/apache/openmeetings/core/session/store/DatabaseStore.java
index 84ce5b2..7319ecf 100644
--- a/openmeetings-core/src/main/java/org/apache/openmeetings/core/session/store/DatabaseStore.java
+++ b/openmeetings-core/src/main/java/org/apache/openmeetings/core/session/store/DatabaseStore.java
@@ -40,33 +40,29 @@ public class DatabaseStore implements IClientPersistenceStore {
}
@Override
- public void put(String streamId, StreamClient rcl) {
- if (rcl.getId() != null) {
- clientDao.update(rcl);
- } else {
- clientDao.add(rcl);
- }
+ public StreamClient put(StreamClient rcl) {
+ return rcl.getId() == null ? clientDao.add(rcl) : clientDao.update(rcl);
}
@Override
- public boolean containsKey(Server server, String streamId) {
- return clientDao.countClientsByServerAndStreamId(server, streamId) > 0;
+ public boolean containsKey(Long id) {
+ return clientDao.get(id) != null;
}
@Override
- public StreamClient get(Server server, String streamId) {
- return clientDao.getClientByServerAndStreamId(server, streamId);
+ public StreamClient get(Long id) {
+ return clientDao.get(id);
}
@Override
- public List<StreamClient> getClientsByPublicSID(Server server, String publicSID) {
- return clientDao.getClientsByPublicSIDAndServer(server, publicSID);
+ public List<StreamClient> getClientsByUid(Server server, String publicSID) {
+ return clientDao.getClientsByUidAndServer(server, publicSID);
}
@Override
- public Map<Long, List<StreamClient>> getClientsByPublicSID(String publicSID) {
+ public Map<Long, List<StreamClient>> getClientsByUid(String publicSID) {
Map<Long, List<StreamClient>> returnMap = new HashMap<>();
- List<StreamClient> clientList = clientDao.getClientsByPublicSID(publicSID);
+ List<StreamClient> clientList = clientDao.getClientsByUid(publicSID);
for (StreamClient cl : clientList) {
if (cl.getServer() == null) {
List<StreamClient> clList = returnMap.get(null);
@@ -113,8 +109,8 @@ public class DatabaseStore implements IClientPersistenceStore {
}
@Override
- public void remove(Server server, String streamId) {
- clientDao.removeClientByServerAndStreamId(server, streamId);
+ public void remove(Long id) {
+ clientDao.remove(id);
}
@Override
[2/3] openmeetings git commit: [OPENMEETINGS-1646] work with streams
refactored (incomplete)
Posted by so...@apache.org.
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/117e8d6b/openmeetings-core/src/main/java/org/apache/openmeetings/core/session/store/HashMapStore.java
----------------------------------------------------------------------
diff --git a/openmeetings-core/src/main/java/org/apache/openmeetings/core/session/store/HashMapStore.java b/openmeetings-core/src/main/java/org/apache/openmeetings/core/session/store/HashMapStore.java
index 57a0c25..0ab5c10 100644
--- a/openmeetings-core/src/main/java/org/apache/openmeetings/core/session/store/HashMapStore.java
+++ b/openmeetings-core/src/main/java/org/apache/openmeetings/core/session/store/HashMapStore.java
@@ -28,6 +28,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.atomic.AtomicLong;
import org.apache.openmeetings.db.entity.room.StreamClient;
import org.apache.openmeetings.db.entity.server.Server;
@@ -52,34 +53,46 @@ import org.slf4j.Logger;
public class HashMapStore implements IClientPersistenceStore {
protected static final Logger log = Red5LoggerFactory.getLogger(HashMapStore.class, webAppRootKey);
- private Map<String, StreamClient> clientsByStreamId = new ConcurrentHashMap<>();
+ private volatile AtomicLong nextId = new AtomicLong(1);
+ private Map<Long, StreamClient> clientsById = new ConcurrentHashMap<>();
@Override
public void clear() {
- clientsByStreamId = new ConcurrentHashMap<>();
+ clientsById = new ConcurrentHashMap<>();
}
@Override
- public void put(String streamId, StreamClient rcl) {
- clientsByStreamId.put(rcl.getStreamid(), rcl);
+ public StreamClient put(StreamClient rcl) {
+ if (rcl.getId() != null) {
+ log.error("Tried to add Client with not NULL ID {}", rcl.getId());
+ return null;
+ } else {
+ rcl.setId(nextId.getAndIncrement());
+ }
+ if (clientsById.containsKey(rcl.getId())) {
+ log.error("Tried to add an existing Client {}", rcl.getId());
+ return null;
+ }
+ clientsById.put(rcl.getId(), rcl);
+ return rcl;
}
@Override
- public boolean containsKey(Server server, String streamId) {
- return clientsByStreamId.containsKey(streamId);
+ public boolean containsKey(Long id) {
+ return id != null && clientsById.containsKey(id);
}
@Override
- public StreamClient get(Server server, String streamId) {
- return clientsByStreamId.get(streamId);
+ public StreamClient get(Long id) {
+ return id == null ? null : clientsById.get(id);
}
@Override
- public List<StreamClient> getClientsByPublicSID(Server server, String publicSID) {
+ public List<StreamClient> getClientsByUid(Server server, String uid) {
List<StreamClient> clientList = new ArrayList<>();
- for (Map.Entry<String, StreamClient> e: clientsByStreamId.entrySet()) {
+ for (Map.Entry<Long, StreamClient> e: clientsById.entrySet()) {
StreamClient cl = e.getValue();
- if (cl.getPublicSID().equals(publicSID)) {
+ if (cl.getUid().equals(uid)) {
clientList.add(cl);
}
}
@@ -87,12 +100,12 @@ public class HashMapStore implements IClientPersistenceStore {
}
@Override
- public Map<Long,List<StreamClient>> getClientsByPublicSID(String publicSID) {
+ public Map<Long,List<StreamClient>> getClientsByUid(String uid) {
Map<Long,List<StreamClient>> clientMapList = new HashMap<>();
List<StreamClient> clientList = new ArrayList<>();
- for (Map.Entry<String, StreamClient> e: clientsByStreamId.entrySet()) {
+ for (Map.Entry<Long, StreamClient> e: clientsById.entrySet()) {
StreamClient cl = e.getValue();
- if (cl.getPublicSID().equals(publicSID)) {
+ if (cl.getUid().equals(uid)) {
clientList.add(cl);
}
}
@@ -102,7 +115,7 @@ public class HashMapStore implements IClientPersistenceStore {
@Override
public Collection<StreamClient> getClients() {
- return clientsByStreamId.values();
+ return clientsById.values();
}
@Override
@@ -114,13 +127,13 @@ public class HashMapStore implements IClientPersistenceStore {
@Override
public Collection<StreamClient> getClientsByServer(Server server) {
- return clientsByStreamId.values();
+ return clientsById.values();
}
@Override
public List<StreamClient> getClientsByUserId(Server server, Long userId) {
List<StreamClient> clientList = new ArrayList<>();
- for (Map.Entry<String, StreamClient> e: clientsByStreamId.entrySet()) {
+ for (Map.Entry<Long, StreamClient> e: clientsById.entrySet()) {
StreamClient cl = e.getValue();
if (cl.getUserId().equals(userId)) {
clientList.add(cl);
@@ -132,7 +145,7 @@ public class HashMapStore implements IClientPersistenceStore {
@Override
public List<StreamClient> getClientsByRoomId(Long roomId) {
List<StreamClient> clientList = new ArrayList<>();
- for (Map.Entry<String, StreamClient> e: clientsByStreamId.entrySet()) {
+ for (Map.Entry<Long, StreamClient> e: clientsById.entrySet()) {
StreamClient cl = e.getValue();
if (cl.getRoomId() != null && cl.getRoomId().equals(roomId)) {
clientList.add(cl);
@@ -142,27 +155,27 @@ public class HashMapStore implements IClientPersistenceStore {
}
@Override
- public void remove(Server server, String streamId) {
- clientsByStreamId.remove(streamId);
+ public void remove(Long id) {
+ clientsById.remove(id);
}
@Override
public int size() {
- return clientsByStreamId.size();
+ return clientsById.size();
}
@Override
public int sizeByServer(Server server) {
- return clientsByStreamId.size();
+ return clientsById.size();
}
@Override
public Collection<StreamClient> values() {
- return clientsByStreamId.values();
+ return clientsById.values();
}
public int getTotalNumberOfSessions() {
- return clientsByStreamId.size();
+ return clientsById.size();
}
/**
@@ -194,7 +207,7 @@ public class HashMapStore implements IClientPersistenceStore {
@Override
public List<Long> getRoomsIdsByServer(Server server) {
Set<Long> rooms = new HashSet<>();
- for (Map.Entry<String, StreamClient> e: clientsByStreamId.entrySet()) {
+ for (Map.Entry<Long, StreamClient> e: clientsById.entrySet()) {
StreamClient cl = e.getValue();
Long roomId = cl.getRoomId();
if (roomId != null && roomId.longValue() > 0 && !rooms.contains(roomId)) {
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/117e8d6b/openmeetings-core/src/main/java/org/apache/openmeetings/core/session/store/IClientPersistenceStore.java
----------------------------------------------------------------------
diff --git a/openmeetings-core/src/main/java/org/apache/openmeetings/core/session/store/IClientPersistenceStore.java b/openmeetings-core/src/main/java/org/apache/openmeetings/core/session/store/IClientPersistenceStore.java
index 5ca0634..329c578 100644
--- a/openmeetings-core/src/main/java/org/apache/openmeetings/core/session/store/IClientPersistenceStore.java
+++ b/openmeetings-core/src/main/java/org/apache/openmeetings/core/session/store/IClientPersistenceStore.java
@@ -30,64 +30,61 @@ public interface IClientPersistenceStore {
public enum DEBUG_DETAILS {
SIZE
}
-
+
/**
* called upon start of the session cache
*/
void clear();
/**
- *
- * @param streamId
+ *
* @param rcl
*/
- void put(String streamId, StreamClient rcl);
-
+ StreamClient put(StreamClient rcl);
+
/**
- *
- * @param server
- * @param streamId
+ *
+ * @param id
* @return
*/
- boolean containsKey(Server server, String streamId);
+ boolean containsKey(Long id);
/**
* by server and publicSID
- *
- * @param server
- * @param streamId
+ *
+ * @param id
* @return will return null if the client does not exist in the list
*/
- StreamClient get(Server server, String streamId);
+ StreamClient get(Long id);
/**
- *
+ *
* @param server
- * @param publicSID
+ * @param uid
* @return will return an empty list if nothing available
*/
- List<StreamClient> getClientsByPublicSID(Server server, String publicSID);
+ List<StreamClient> getClientsByUid(Server server, String uid);
/**
* Searches for the publicSID across all servers
- *
- * @param publicSID
+ *
+ * @param uid
* @return will return a map with the serverId as key and the RoomClients as list in the value
*/
- Map<Long, List<StreamClient>> getClientsByPublicSID(String publicSID);
+ Map<Long, List<StreamClient>> getClientsByUid(String uid);
Collection<StreamClient> getClients();
-
+
/**
* get all clients by a specific {@link Server}
- *
+ *
* @param server
* @return will return an empty map if nothing available
*/
Collection<StreamClient> getClientsByServer(Server server);
/**
- *
+ *
* @param server
* @param userId
* @return will return an empty list if nothing available
@@ -95,25 +92,25 @@ public interface IClientPersistenceStore {
Collection<StreamClient> getClientsByUserId(Server server, Long userId);
/**
- *
+ *
* We ignore the server here, cause ONE room can only be on ONE server and often we don't know where.
- *
+ *
* @param roomId
* @return will return an empty map if nothing available
*/
List<StreamClient> getClientsByRoomId(Long roomId);
- void remove(Server server, String streamId);
+ void remove(Long id);
int size();
int sizeByServer(Server server);
Collection<StreamClient> values();
-
+
/**
* Get some session statistics
- *
+ *
* @param detailLevel
* @return
*/
@@ -121,18 +118,18 @@ public interface IClientPersistenceStore {
/**
* returns a list of roomIds (unique) that are currently active on the given server
- * In case the session is stored in the memory (no-cluster setup) it will always
+ * In case the session is stored in the memory (no-cluster setup) it will always
* return simply all active roomIds
- *
+ *
* @param server
* @return
*/
List<Long> getRoomsIdsByServer(Server server);
/**
- * if database cache + cluster is enabled, the server object will be loaded
+ * if database cache + cluster is enabled, the server object will be loaded
* into the client
- *
+ *
* @return
*/
Collection<StreamClient> getClientsWithServer();
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/117e8d6b/openmeetings-core/src/main/java/org/apache/openmeetings/core/util/IClientUtil.java
----------------------------------------------------------------------
diff --git a/openmeetings-core/src/main/java/org/apache/openmeetings/core/util/IClientUtil.java b/openmeetings-core/src/main/java/org/apache/openmeetings/core/util/IClientUtil.java
new file mode 100644
index 0000000..ebc670e
--- /dev/null
+++ b/openmeetings-core/src/main/java/org/apache/openmeetings/core/util/IClientUtil.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License") + you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.openmeetings.core.util;
+
+import static org.apache.openmeetings.util.OpenmeetingsVariables.webAppRootKey;
+
+import org.apache.openmeetings.db.entity.room.StreamClient;
+import org.red5.logging.Red5LoggerFactory;
+import org.red5.server.api.IClient;
+import org.slf4j.Logger;
+
+public class IClientUtil {
+ private static final Logger log = Red5LoggerFactory.getLogger(IClientUtil.class, webAppRootKey);
+
+ private enum ConAttrs {
+ omId
+ , sharing
+ }
+
+ public static void init(IClient client, Long id, boolean sharing) {
+ client.setAttribute(ConAttrs.omId.name(), id);
+ client.setAttribute(ConAttrs.sharing.name(), sharing);
+ }
+
+ /**
+ * Id of {@link StreamClient} for this IConnection
+ *
+ * @param conn
+ * @return - Id of {@link StreamClient} for this IConnection, or <code>null</code>
+ */
+ public static Long getId(IClient client) {
+ Object o = client.getAttribute(ConAttrs.omId.name());
+ return o instanceof Long ? (Long)o : null;
+ }
+
+ public static boolean isSharing(IClient client) {
+ return Boolean.TRUE.equals(client.getAttribute(ConAttrs.sharing.name()));
+ }
+}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/117e8d6b/openmeetings-core/src/main/java/org/apache/openmeetings/core/util/RoomHelper.java
----------------------------------------------------------------------
diff --git a/openmeetings-core/src/main/java/org/apache/openmeetings/core/util/RoomHelper.java b/openmeetings-core/src/main/java/org/apache/openmeetings/core/util/RoomHelper.java
index e74ce34..734b53a 100644
--- a/openmeetings-core/src/main/java/org/apache/openmeetings/core/util/RoomHelper.java
+++ b/openmeetings-core/src/main/java/org/apache/openmeetings/core/util/RoomHelper.java
@@ -25,17 +25,21 @@ import org.apache.openmeetings.db.entity.room.StreamClient;
import com.github.openjson.JSONObject;
public class RoomHelper {
+ public static JSONObject videoJson(Client c, boolean self, String sid, ISessionManager mgr, Long streamClientId, boolean share) {
+ return videoJson(c, c.getUid(), self, sid, mgr, streamClientId, share);
+ }
- public static JSONObject videoJson(Client c, boolean self, String sid, ISessionManager mgr, boolean share) {
+ public static JSONObject videoJson(Client c, String uid, boolean self, String sid, ISessionManager mgr, Long streamClientId, boolean share) {
JSONObject json = c.toJson(self).put("sid", sid);
if (share) {
- StreamClient sc = mgr.getClientByPublicSID(c.getUid(), null); //TODO check server
+ StreamClient sc = mgr.get(streamClientId);
json.put("screenShare", true)
- .put("uid", sc.getPublicSID()) // unique screen-sharing ID
+ .put("sid", sid)
+ .put("uid", sc.getUid())
.put("broadcastId", sc.getBroadCastId())
- .put("width", sc.getVWidth())
- .put("height", sc.getVHeight());
+ .put("width", sc.getWidth())
+ .put("height", sc.getHeight());
}
return json;
}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/117e8d6b/openmeetings-db/src/main/java/org/apache/openmeetings/IApplication.java
----------------------------------------------------------------------
diff --git a/openmeetings-db/src/main/java/org/apache/openmeetings/IApplication.java b/openmeetings-db/src/main/java/org/apache/openmeetings/IApplication.java
index 7cd5c29..e0cd5e8 100644
--- a/openmeetings-db/src/main/java/org/apache/openmeetings/IApplication.java
+++ b/openmeetings-db/src/main/java/org/apache/openmeetings/IApplication.java
@@ -24,8 +24,9 @@ import java.util.function.Supplier;
import javax.servlet.ServletContext;
-import org.apache.openmeetings.db.entity.room.StreamClient;
+import org.apache.openmeetings.db.entity.basic.Client;
import org.apache.openmeetings.db.entity.room.Invitation;
+import org.apache.openmeetings.db.entity.room.StreamClient;
import org.apache.wicket.request.IExceptionMapper;
import org.apache.wicket.request.IRequestMapper;
import org.apache.wicket.request.mapper.parameter.PageParameters;
@@ -39,10 +40,11 @@ public interface IApplication {
String getOmString(long id, long languageId);
String getOmString(String key, long languageId);
String getOmString(String key, final Locale loc, String... params);
- org.apache.openmeetings.db.entity.basic.Client getOmClient(String uid);
+ Client getOmClient(String uid);
+ Client getOmClientBySid(String sid);
StreamClient updateClient(StreamClient rcl, boolean forceSize);
- List<org.apache.openmeetings.db.entity.basic.Client> getOmRoomClients(Long roomId);
- List<org.apache.openmeetings.db.entity.basic.Client> getOmClients(Long userId);
+ List<Client> getOmRoomClients(Long roomId);
+ List<Client> getOmClients(Long userId);
String getOmContactsLink();
String getOmInvitationLink(Invitation i);
String urlForActivatePage(PageParameters pp);
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/117e8d6b/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/room/ClientDao.java
----------------------------------------------------------------------
diff --git a/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/room/ClientDao.java b/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/room/ClientDao.java
index 99af2cb..8ba572d 100644
--- a/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/room/ClientDao.java
+++ b/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/room/ClientDao.java
@@ -45,7 +45,7 @@ public class ClientDao {
private static List<Long> EMPTY_LIST = new ArrayList<>(0);
public void cleanAllClients() {
- em.createNamedQuery("deleteAll").executeUpdate();
+ em.createNamedQuery("deleteClientAll").executeUpdate();
}
public void cleanClientsByServer(Server server) {
@@ -54,6 +54,13 @@ public class ClientDao {
executeUpdate();
}
+ public StreamClient get(Long id) {
+ List<StreamClient> list = em.createNamedQuery("getClientById", StreamClient.class)
+ .setParameter("id", id)
+ .getResultList();
+ return list == null || list.isEmpty() ? null : list.get(0);
+ }
+
public StreamClient add(StreamClient entity) {
em.persist(entity);
return entity;
@@ -65,15 +72,12 @@ public class ClientDao {
}
public void delete(StreamClient entity) {
- Query q = em.createNamedQuery("deletedById");
- q.setParameter("id", entity.getId());
- q.executeUpdate();
+ remove(entity.getId());
}
- public void removeClientByServerAndStreamId(Server server, String streamId) {
- Query q = em.createNamedQuery("deletedByServerAndStreamId");
- q.setParameter("server", server);
- q.setParameter("streamid", streamId);
+ public void remove(Long id) {
+ Query q = em.createNamedQuery("deletedClientById");
+ q.setParameter("id", id);
q.executeUpdate();
}
@@ -87,44 +91,16 @@ public class ClientDao {
return q.getSingleResult().intValue();
}
- public long countClientsByServerAndStreamId(Server server, String streamId) {
- TypedQuery<Long> q = em.createNamedQuery("countClientsByServerAndStreamId", Long.class);
- q.setParameter("streamid", streamId);
- q.setParameter("server", server);
- return q.getSingleResult();
- }
-
- /**
- * Query.getSingleResult would throw an error if result is null,
- * see: http://stackoverflow.com/questions/2002993/jpa-getsingleresult-or-null
- *
- * @param server
- * @param streamId
- * @return
- */
- public StreamClient getClientByServerAndStreamId(Server server, String streamId) {
- TypedQuery<StreamClient> q = em.createNamedQuery("getClientByServerAndStreamId", StreamClient.class);
- q.setParameter("streamid", streamId);
- q.setParameter("server", server);
- List<StreamClient> ll = q.getResultList();
- if (ll.size() == 1) {
- return ll.get(0);
- } else if (ll.size() == 0) {
- return null;
- }
- throw new RuntimeException("more then one client was found streamId "+ streamId + " server "+server);
- }
-
- public List<StreamClient> getClientsByPublicSIDAndServer(Server server, String publicSID) {
- TypedQuery<StreamClient> q = em.createNamedQuery("getClientsByPublicSIDAndServer", StreamClient.class);
+ public List<StreamClient> getClientsByUidAndServer(Server server, String uid) {
+ TypedQuery<StreamClient> q = em.createNamedQuery("getClientsByUidAndServer", StreamClient.class);
q.setParameter("server", server);
- q.setParameter("publicSID", publicSID);
+ q.setParameter("uid", uid);
return q.getResultList();
}
- public List<StreamClient> getClientsByPublicSID(String publicSID) {
- TypedQuery<StreamClient> q = em.createNamedQuery("getClientsByPublicSID", StreamClient.class);
- q.setParameter("publicSID", publicSID);
+ public List<StreamClient> getClientsByUid(String uid) {
+ TypedQuery<StreamClient> q = em.createNamedQuery("getClientsByUid", StreamClient.class);
+ q.setParameter("uid", uid);
return q.getResultList();
}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/117e8d6b/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/server/ISessionManager.java
----------------------------------------------------------------------
diff --git a/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/server/ISessionManager.java b/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/server/ISessionManager.java
index 3ebd6fb..ce9efb1 100644
--- a/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/server/ISessionManager.java
+++ b/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/server/ISessionManager.java
@@ -43,18 +43,6 @@ public interface ISessionManager {
void sessionStart();
StreamClient add(StreamClient c, Server server);
- /**
- * add a new client item
- *
- * @param streamId
- * @param scopeName
- * @param remotePort
- * @param remoteAddress
- * @param swfUrl
- * @param server
- * @return
- */
- StreamClient addClientListItem(String streamId, String scopeName, int remotePort, String remoteAddress, String swfUrl, Server server);
Collection<StreamClient> getClients();
@@ -66,22 +54,21 @@ public interface ISessionManager {
Collection<StreamClient> getClientsWithServer();
/**
- * Get a client by its streamId
+ * Get a client by its id
*
- * @param streamId
- * @param server
+ * @param id
* @return
*/
- StreamClient getClientByStreamId(String streamId, Server server);
+ StreamClient get(Long id);
/**
* get a client by its publicSID and the server,
*
- * @param publicSID
+ * @param uid
* @param server
* @return
*/
- StreamClient getClientByPublicSID(String publicSID, Server server);
+ StreamClient getClientByUid(String uid, Server server);
/**
* same as {@link #getClientByPublicSID(String, boolean, Server)} but it ignores
@@ -91,32 +78,20 @@ public interface ISessionManager {
* This method requires more time to find the user, so under normal circumstances
* you should use {@link #getClientByPublicSID(String, boolean, Server)}!
*
- * @param publicSID
+ * @param uid
* @return
*/
- ClientSessionInfo getClientByPublicSIDAnyServer(String publicSID);
-
- /**
- *
- * @param userId
- * @return
- *
- * @deprecated There could be multiple users logged in with the same userid,
- * then this call would return a list not a single user
- */
- @Deprecated
- StreamClient getClientByUserId(Long userId);
+ ClientSessionInfo getClientByUidAnyServer(String uid);
/**
* Update the session object of the audio/video-connection and additionally
* swap the values to the session object of the user that holds the full
* session object
*
- * @param streamId
- * @param rcm
+ * @param id
* @return
*/
- boolean updateAVClientByStreamId(String streamId, StreamClient rcm, Server server);
+ boolean updateAVClient(StreamClient rcm);
/**
* Update the session object
@@ -125,21 +100,21 @@ public interface ISessionManager {
* ScopeApplicationAdapter#setRoomValues(Long, Boolean, Boolean, String)
* .
*
- * @param streamId
* @param rcm
* @param updateRoomCount
* true means the count for the room has to be updated
+ * @param server
* @return
*/
- boolean updateClientByStreamId(String streamId, StreamClient rcm, boolean updateRoomCount, Server server);
+ boolean update(StreamClient rcm);
/**
* Remove a client from the session store
*
- * @param streamId
+ * @param id
* @return
*/
- boolean removeClient(String streamId, Server server);
+ boolean remove(Long id);
/**
* Get all ClientList Objects of that room and domain This Function is
@@ -154,14 +129,6 @@ public interface ISessionManager {
Collection<StreamClient> getClientListByRoomAll(Long roomId);
/**
- * get the current Moderator in this room
- *
- * @param roomname
- * @return
- */
- List<StreamClient> getCurrentModeratorByRoom(Long roomId);
-
- /**
* Get list of current client sessions
*
* @param start
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/117e8d6b/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/user/IUserManager.java
----------------------------------------------------------------------
diff --git a/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/user/IUserManager.java b/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/user/IUserManager.java
index 9a6e641..a9f76e8 100644
--- a/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/user/IUserManager.java
+++ b/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/user/IUserManager.java
@@ -52,10 +52,9 @@ public interface IUserManager {
Long getLanguage(Locale loc);
User loginOAuth(Map<String, String> params, long serverId) throws IOException, NoSuchAlgorithmException;
- /** TODO FIXME seems to be unused **/
- boolean kickUserByStreamId(String SID, Long roomId);
+ boolean kickUsersByRoomId(Long roomId);
- boolean kickUserByPublicSID(String SID, String publicSID);
+ boolean kickById(Long id);
List<Userdata> getUserdataDashBoard(Long userId);
}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/117e8d6b/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/user/IUserService.java
----------------------------------------------------------------------
diff --git a/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/user/IUserService.java b/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/user/IUserService.java
deleted file mode 100644
index 677a56d..0000000
--- a/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/user/IUserService.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License") + you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.openmeetings.db.dao.user;
-
-//FIXME HACK to bypass cross project compilation
-public interface IUserService {
- boolean kickUserByStreamId(String sid, String streamid, long serverId);
-
- boolean kickUserBySessionId(String sid, long userId, String sessionId);
-}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/117e8d6b/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/basic/Client.java
----------------------------------------------------------------------
diff --git a/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/basic/Client.java b/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/basic/Client.java
index ca93a2a..f9e966f 100644
--- a/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/basic/Client.java
+++ b/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/basic/Client.java
@@ -18,9 +18,11 @@
*/
package org.apache.openmeetings.db.entity.basic;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashSet;
+import java.util.List;
import java.util.Set;
import java.util.UUID;
@@ -55,6 +57,66 @@ public class Client implements IClient {
public enum Pod {
none, left, right;
}
+ public static class Stream {
+ private Long streamClientId = null;
+ private String broadcastId = null;
+ private boolean sharing;
+
+ public Stream(Long streamClientId, String broadcastId, boolean sharing) {
+ this.streamClientId = streamClientId;
+ this.broadcastId = broadcastId;
+ this.sharing= sharing;
+ }
+
+ public Long getStreamClientId() {
+ return streamClientId;
+ }
+
+ public void setStreamClientId(Long streamClientId) {
+ this.streamClientId = streamClientId;
+ }
+
+ public String getBroadcastId() {
+ return broadcastId;
+ }
+
+ public void setBroadcastId(String broadcastId) {
+ this.broadcastId = broadcastId;
+ }
+
+ public boolean isSharing() {
+ return sharing;
+ }
+
+ public void setSharing(boolean sharing) {
+ this.sharing = sharing;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((broadcastId == null) ? 0 : broadcastId.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ Stream other = (Stream) obj;
+ if (broadcastId == null) {
+ if (other.broadcastId != null)
+ return false;
+ } else if (!broadcastId.equals(other.broadcastId))
+ return false;
+ return true;
+ }
+ }
private final String sessionId;
private int pageId;
private User user;
@@ -64,13 +126,13 @@ public class Client implements IClient {
private String remoteAddress;
private final Set<Right> rights = new HashSet<>();
private final Set<Activity> activities = new HashSet<>();
+ private final Set<Stream> streams = new HashSet<>();
private final Date connectedSince;
private Pod pod;
private int cam = -1;
private int mic = -1;
private int width = 0;
private int height = 0;
- private String broadcastId = null;
public Client(String sessionId, int pageId, Long userId, UserDao dao) {
this.sessionId = sessionId;
@@ -86,8 +148,8 @@ public class Client implements IClient {
this.pageId = 0;
this.user = dao.get(rcl.getUserId());
this.connectedSince = new Date();
- uid = rcl.getPublicSID();
- sid = UUID.randomUUID().toString();
+ uid = rcl.getUid();
+ sid = rcl.getOwnerSid();
this.roomId = rcl.getRoomId();
this.remoteAddress = rcl.getUserip();
}
@@ -129,8 +191,10 @@ public class Client implements IClient {
return sid;
}
- public void clearRights() {
+ public void clear() {
+ activities.clear();
rights.clear();
+ streams.clear();
}
public boolean hasRight(Right right) {
@@ -213,10 +277,26 @@ public class Client implements IClient {
activities.remove(Activity.broadcastA);
activities.remove(Activity.broadcastV);
break;
+ case share:
+ for (Stream s : streams) {
+ if (s.isSharing()) {
+ streams.remove(s);
+ break;
+ }
+ }
+ break;
default:
}
}
+ public void addStream(Long streamClientId, String broadcastId, boolean sharing) {
+ streams.add(new Stream(streamClientId, broadcastId, sharing));
+ }
+
+ public List<Stream> getStreams() {
+ return new ArrayList<>(streams);
+ }
+
public Date getConnectedSince() {
return connectedSince;
}
@@ -304,15 +384,6 @@ public class Client implements IClient {
return this;
}
- public String getBroadcastId() {
- return broadcastId;
- }
-
- public Client setBroadcastId(String broadcastId) {
- this.broadcastId = broadcastId;
- return this;
- }
-
@Override
public int hashCode() {
final int prime = 31;
@@ -363,7 +434,6 @@ public class Client implements IClient {
.put("rights", new JSONArray(rights))
.put("activities", new JSONArray(activities))
.put("pod", pod)
- .put("broadcastId", broadcastId)
.put("width", width)
.put("height", height)
.put("self", self);
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/117e8d6b/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/log/ConferenceLog.java
----------------------------------------------------------------------
diff --git a/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/log/ConferenceLog.java b/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/log/ConferenceLog.java
index 06612c9..1557d61 100644
--- a/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/log/ConferenceLog.java
+++ b/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/log/ConferenceLog.java
@@ -116,7 +116,7 @@ public class ConferenceLog implements IDataProviderEntity {
this.userId = userId;
}
- public String getStreamid() {
+ public String getStreamId() {
return streamid;
}
public void setStreamid(String streamid) {
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/117e8d6b/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/room/StreamClient.java
----------------------------------------------------------------------
diff --git a/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/room/StreamClient.java b/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/room/StreamClient.java
index aba737a..dbdef46 100644
--- a/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/room/StreamClient.java
+++ b/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/room/StreamClient.java
@@ -31,13 +31,15 @@ import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
+import javax.persistence.Transient;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
+import org.apache.openmeetings.db.entity.basic.Client;
import org.apache.openmeetings.db.entity.basic.IClient;
import org.apache.openmeetings.db.entity.server.Server;
-import org.apache.openmeetings.util.CalendarPatterns;
+import org.apache.wicket.util.string.StringValue;
/**
* Can be configured to be stored in memory or in database
@@ -46,22 +48,20 @@ import org.apache.openmeetings.util.CalendarPatterns;
*/
@Entity
@NamedQueries({
- @NamedQuery(name = "deleteAll", query = "DELETE FROM StreamClient"),
- @NamedQuery(name = "deletedById", query = "DELETE FROM StreamClient c WHERE c.id = :id"),
+ @NamedQuery(name = "deleteClientAll", query = "DELETE FROM StreamClient"),
+ @NamedQuery(name = "deleteClientById", query = "DELETE FROM StreamClient c WHERE c.id = :id"),
+ @NamedQuery(name = "getClientById", query = "SELECT c FROM StreamClient c WHERE c.id = :id"),
@NamedQuery(name = "deleteClientsByServer", query = "DELETE FROM StreamClient c WHERE c.server = :server"),
- @NamedQuery(name = "deletedByServerAndStreamId", query = "DELETE FROM StreamClient c WHERE c.server = :server AND c.streamid LIKE :streamid"),
- @NamedQuery(name = "countClients", query = "SELECT count(c.id) FROM StreamClient c"),
- @NamedQuery(name = "countClientsByServer", query = "SELECT count(c.id) FROM StreamClient c WHERE c.server = :server"),
- @NamedQuery(name = "countClientsByServerAndStreamId", query = "SELECT count(c.id) FROM StreamClient c WHERE c.streamid LIKE :streamid AND c.server = :server"),
- @NamedQuery(name = "getClientByServerAndStreamId", query = "SELECT c FROM StreamClient c WHERE c.streamid LIKE :streamid AND c.server = :server"),
- @NamedQuery(name = "getClientsByPublicSIDAndServer", query = "SELECT c FROM StreamClient c WHERE c.publicSID LIKE :publicSID AND c.server = :server"),
- @NamedQuery(name = "getClientsByPublicSID", query = "SELECT c FROM StreamClient c WHERE c.publicSID LIKE :publicSID"),
+ @NamedQuery(name = "countClients", query = "SELECT count(c) FROM StreamClient c"),
+ @NamedQuery(name = "countClientsByServer", query = "SELECT count(c) FROM StreamClient c WHERE c.server = :server"),
+ @NamedQuery(name = "getClientsByUidAndServer", query = "SELECT c FROM StreamClient c WHERE c.uid = :uid AND c.server = :server"),
+ @NamedQuery(name = "getClientsByUid", query = "SELECT c FROM StreamClient c WHERE c.uid = :uid"),
@NamedQuery(name = "getClientsByServer", query = "SELECT c FROM StreamClient c WHERE c.server = :server"),
@NamedQuery(name = "getClients", query = "SELECT c FROM StreamClient c"),
@NamedQuery(name = "getClientsWithServer", query = "SELECT c FROM StreamClient c LEFT JOIN FETCH c.server"),
@NamedQuery(name = "getClientsByUserId", query = "SELECT c FROM StreamClient c WHERE c.server = :server AND c.userId = :userId"),
- @NamedQuery(name = "getClientsByRoomId", query = "SELECT c FROM StreamClient c WHERE c.roomId = :roomId"),
- @NamedQuery(name = "getRoomsIdsByServer", query = "SELECT c.roomId FROM StreamClient c WHERE c.server = :server GROUP BY c.roomId")
+ @NamedQuery(name = "getClientsByRoomId", query = "SELECT c FROM StreamClient c WHERE c.scope = :roomId"),
+ @NamedQuery(name = "getRoomsIdsByServer", query = "SELECT c.roomId FROM StreamClient c WHERE c.server = :server GROUP BY c.scope")
})
@Table(name = "client")
@XmlRootElement
@@ -75,88 +75,47 @@ public class StreamClient implements IClient {
private Long id;
/**
- * @see StreamClient#getUsername()
- */
- @Column(name = "username")
- private String username = "";
-
- /**
- * @see StreamClient#getStreamid()
- */
- @Column(name = "streamid")
- private String streamid = "";
-
- /**
- * @see StreamClient#getScope()
+ * Red5 scope, can be roomId or 'hibernate'
*/
@Column(name = "scope")
private String scope = "";
/**
- * @see StreamClient#getVWidth()
- */
- @Column(name = "vwidth")
- private int vWidth = 0;
-
- /**
- * @see StreamClient#getVHeight()
+ * The width of the video
*/
- @Column(name = "vheight")
- private int vHeight = 0;
+ @Column(name = "width")
+ private int width = 0;
/**
- * @see StreamClient#getVX()
+ * The height of the video
*/
- @Column(name = "vx")
- private int vX = 0;
+ @Column(name = "height")
+ private int height = 0;
/**
- * @see StreamClient#getVY()
+ * {@link Client#getUid()} of the client this stream is originated from
+ *
*/
- @Column(name = "vy")
- private int vY = 0;
+ @Column(name = "uid")
+ private String uid = null;
/**
- * @see StreamClient#getStreamPublishName()
+ * {@link Client#getSid()} of the client who initiated the connection
*/
- @Column(name = "stream_publish_name")
- private String streamPublishName = "";
+ @Column(name = "owner_sid")
+ private String ownerSid = null;
/**
- * @see StreamClient#getPublicSID()
- */
- @Column(name = "public_sid")
- private String publicSID = "";
-
- /**
- * @see StreamClient#getIsMod()
+ * Is this user moderator
*/
@Column(name = "is_mod", nullable = false)
- private boolean isMod = false;
-
- /**
- * @see StreamClient#getIsSuperModerator()
- */
- @Column(name = "is_supermoderator", nullable = false)
- private boolean isSuperModerator = false;
-
- /**
- * @see StreamClient#getCanDraw()
- */
- @Column(name = "can_draw", nullable = false)
- private boolean canDraw = false;
-
- /**
- * @see StreamClient#getCanShare()
- */
- @Column(name = "can_share", nullable = false)
- private boolean canShare = false;
+ private boolean mod = false;
/**
- * @see StreamClient#getCanRemote()
+ * Is this user "super moderator"
*/
- @Column(name = "can_remote", nullable = false)
- private boolean canRemote = false;
+ @Column(name = "super_mod", nullable = false)
+ private boolean superMod = false;
/**
* @see StreamClient#getCanGiveAudio()
@@ -174,30 +133,6 @@ public class StreamClient implements IClient {
private Date connectedSince;
/**
- * @see StreamClient#getFormatedDate()
- */
- @Column(name = "formated_date")
- private String formatedDate;
-
- /**
- * @see StreamClient#isScreenClient()
- */
- @Column(name = "is_screenclient", nullable = false)
- private boolean screenClient;
-
- /**
- * @see StreamClient#getUsercolor()
- */
- @Column(name = "usercolor")
- private String usercolor;
-
- /**
- * @see StreamClient#getUserpos()
- */
- @Column(name = "userpos")
- private Integer userpos;
-
- /**
* @see StreamClient#getUserip()
*/
@Column(name = "userip")
@@ -210,12 +145,6 @@ public class StreamClient implements IClient {
private int userport;
/**
- * @see StreamClient#getRoomId()
- */
- @Column(name = "room_id")
- private Long roomId;
-
- /**
* @see StreamClient#getRoomEnter()
*/
@Column(name = "room_enter")
@@ -225,66 +154,35 @@ public class StreamClient implements IClient {
* @see StreamClient#getBroadCastID()
*/
@Column(name = "broadcast_id")
- private String broadCastId = "-2";
+ private String broadCastId = null;
+
+ @Column(name = "username")
+ private String username = "";
- /**
- * @see StreamClient#getUserId()
- */
@Column(name = "user_id")
private Long userId = null;
- /**
- * @see StreamClient#getFirstname()
- */
@Column(name = "firstname")
private String firstname = "";
- /**
- * @see StreamClient#getLastname()
- */
@Column(name = "lastname")
private String lastname = "";
- /**
- * @see StreamClient#getMail()
- */
@Column(name = "email")
private String email;
- /**
- * @see StreamClient#getLastLogin()
- */
@Column(name = "last_login")
private String lastLogin;
- /**
- * @see StreamClient#getSecurityCode()
- */
- @Column(name = "security_code")
- private String securityCode;
-
- /**
- * @see StreamClient#getPicture_uri()
- */
@Column(name = "picture_uri")
private String picture_uri;
- /**
- * @see StreamClient#getLanguage()
- */
@Column(name = "language")
private String language = "";
- /**
- * @see StreamClient#getAvsettings()
- */
@Column(name = "avsettings")
private String avsettings = "";
- /**
- * @see StreamClient#getSwfurl()
- */
- // FIXME: Move to {@link ClientSession}
@Column(name = "swfurl", length=2048)
private String swfurl;
@@ -295,68 +193,38 @@ public class StreamClient implements IClient {
private boolean nativeSsl = false;
/**
- * @see StreamClient#getIsRecording()
- */
- @Column(name = "is_recording", nullable = false)
- private boolean isRecording = false;
-
- /**
- * @see StreamClient#getRoomRecordingName()
+ * Is this client connect via mobile application
*/
- @Column(name = "room_recording_name")
- private String roomRecordingName;
+ @Column(name = "mobile", nullable = false)
+ private boolean mobile = false;
/**
- * @see StreamClient#getRecordingId()
+ * Is this client performs screen sharing
*/
- @Column(name = "recording_id")
- private Long recordingId;
+ @Column(name = "sharing", nullable = false)
+ private boolean sharing = false;
- /**
- * @see StreamClient#getRecordingMetaDataId()
- */
- @Column(name = "recording_metadata_id")
- private Long recordingMetaDataId;
+ @Column(name = "recording_started", nullable = false)
+ private boolean recordingStarted = false;
- /**
- * @see StreamClient#isStartRecording()
- */
- @Column(name = "start_recording", nullable = false)
- private boolean startRecording = false;
+ @Column(name = "sharing_started", nullable = false)
+ private boolean sharingStarted = false;
- /**
- * @see StreamClient#isStartStreaming()
- */
- @Column(name = "start_streaming", nullable = false)
- private boolean startStreaming = false;
+ @Column(name = "publish_started", nullable = false)
+ private boolean publishStarted = false;
- /**
- * @see StreamClient#isScreenPublishStarted()
- */
- @Column(name = "screen_publish_started", nullable = false)
- private boolean screenPublishStarted = false;
+ @Column(name = "broadcasting", nullable = false)
+ private boolean broadcasting = false;
- /**
- * @see StreamClient#isStreamPublishStarted()
- */
- @Column(name = "stream_publish_started", nullable = false)
- private boolean streamPublishStarted = false;
+ @Column(name = "recording_id")
+ private Long recordingId;
- /**
- * @see StreamClient#getIsBroadcasting()
- */
- @Column(name = "is_broadcasting", nullable = false)
- private boolean isBroadcasting = false;
+ @Column(name = "meta_id")
+ private Long metaId;
- /**
- * @see StreamClient#getExternalUserId()
- */
@Column(name = "external_user_id")
private String externalUserId;
- /**
- * @see StreamClient#getExternalUserType()
- */
@Column(name = "external_user_type")
private String externalUserType;
@@ -373,12 +241,6 @@ public class StreamClient implements IClient {
private boolean allowRecording = true;
/**
- * @see StreamClient#getZombieCheckFlag()
- */
- @Column(name = "zombie_check_flag", nullable = false)
- private boolean zombieCheckFlag = false;
-
- /**
* @see StreamClient#getMicMuted()
*/
@Column(name = "mic_muted", nullable = false)
@@ -390,42 +252,14 @@ public class StreamClient implements IClient {
@Column(name = "sip_transport", nullable = false)
private boolean sipTransport = false;
- @Column(name = "mobile", nullable = false)
- private boolean mobile = false;
-
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "server_id")
private Server server;
- public StreamClient() {}
-
- public StreamClient(String streamid, String publicSID, Long roomId,
- Long userId, String firstname, String lastname,
- String username, String connectedSince, String scope) {
- super();
- this.streamid = streamid;
- this.publicSID = publicSID;
- this.roomId = roomId;
- this.userId = userId;
- this.firstname = firstname;
- this.lastname = lastname;
- this.username = username;
- this.connectedSince = CalendarPatterns.parseDateWithHour(connectedSince);
- this.scope = scope;
- }
-
- public void setUserObject(Long userId, String username, String firstname, String lastname) {
- this.userId = userId;
- this.username = username;
- this.firstname = firstname;
- this.lastname = lastname;
- }
+ @Transient
+ private Long roomId;
- public void setUserObject(String username, String firstname, String lastname) {
- this.username = username;
- this.firstname = firstname;
- this.lastname = lastname;
- }
+ public StreamClient() {}
@Override
public Long getId() {
@@ -437,164 +271,105 @@ public class StreamClient implements IClient {
this.id = id;
}
- public Date getConnectedSince() {
- return connectedSince;
- }
-
- public void setConnectedSince(Date connectedSince) {
- this.connectedSince = connectedSince;
- }
-
- public boolean getIsMod() {
- return isMod;
- }
-
- public void setIsMod(boolean isMod) {
- this.isMod = isMod;
- }
-
- public String getUsername() {
- return username;
- }
-
- public void setUsername(String username) {
- this.username = username;
- }
-
- public String getStreamid() {
- return streamid;
- }
-
- public void setStreamid(String streamid) {
- this.streamid = streamid;
- }
-
public String getScope() {
return scope;
}
public void setScope(String scope) {
this.scope = scope;
+ StringValue scn = StringValue.valueOf(scope);
+ long roomId = scn.toLong(Long.MIN_VALUE);
+ if (roomId > 0) {
+ this.roomId = roomId;
+ }
}
- public String getFormatedDate() {
- return formatedDate;
- }
-
- public void setFormatedDate(String formatedDate) {
- this.formatedDate = formatedDate;
+ public int getWidth() {
+ return width;
}
- public String getUsercolor() {
- return usercolor;
+ public void setWidth(int width) {
+ this.width = width;
}
- public void setUsercolor(String usercolor) {
- this.usercolor = usercolor;
+ public int getHeight() {
+ return height;
}
- public Integer getUserpos() {
- return userpos;
+ public void setHeight(int height) {
+ this.height = height;
}
- public void setUserpos(Integer userpos) {
- this.userpos = userpos;
+ public String getUid() {
+ return uid;
}
- public String getUserip() {
- return userip;
+ public void setUid(String uid) {
+ this.uid = uid;
}
- public void setUserip(String userip) {
- this.userip = userip;
+ public String getOwnerSid() {
+ return ownerSid;
}
- public String getSwfurl() {
- return swfurl;
+ public void setOwnerSid(String ownerSid) {
+ this.ownerSid = ownerSid;
}
- public void setSwfurl(String swfurl) {
- this.swfurl = swfurl;
+ public boolean isMod() {
+ return mod;
}
- public int getUserport() {
- return userport;
+ public void setMod(boolean mod) {
+ this.mod = mod;
}
- public void setUserport(int userport) {
- this.userport = userport;
+ public boolean isSuperMod() {
+ return superMod;
}
- public String getFirstname() {
- return firstname;
- }
-
- public void setFirstname(String firstname) {
- this.firstname = firstname;
- }
-
- public String getLanguage() {
- return language;
- }
-
- public void setLanguage(String language) {
- this.language = language;
- }
-
- public String getLastLogin() {
- return lastLogin;
- }
-
- public void setLastLogin(String lastLogin) {
- this.lastLogin = lastLogin;
+ public void setSuperMod(boolean superMod) {
+ this.superMod = superMod;
}
- public String getLastname() {
- return lastname;
- }
-
- public void setLastname(String lastname) {
- this.lastname = lastname;
- }
-
- public String getEmail() {
- return email;
+ public boolean isCanGiveAudio() {
+ return canGiveAudio;
}
- public void setEmail(String email) {
- this.email = email;
+ public void setCanGiveAudio(boolean canGiveAudio) {
+ this.canGiveAudio = canGiveAudio;
}
- public String getSecurityCode() {
- return securityCode;
+ public boolean isCanVideo() {
+ return canVideo;
}
- public void setSecurityCode(String securityCode) {
- this.securityCode = securityCode;
+ public void setCanVideo(boolean canVideo) {
+ this.canVideo = canVideo;
}
- public String getPicture_uri() {
- return picture_uri;
+ public Date getConnectedSince() {
+ return connectedSince;
}
- public void setPicture_uri(String picture_uri) {
- this.picture_uri = picture_uri;
+ public void setConnectedSince(Date connectedSince) {
+ this.connectedSince = connectedSince;
}
- public Long getUserId() {
- return userId;
+ public String getUserip() {
+ return userip;
}
- public void setUserId(Long userId) {
- this.userId = userId;
+ public void setUserip(String userip) {
+ this.userip = userip;
}
- public Long getRoomId() {
- return roomId;
+ public int getUserport() {
+ return userport;
}
- public void setRoomId(Long roomId) {
- this.roomId = roomId;
+ public void setUserport(int userport) {
+ this.userport = userport;
}
public Date getRoomEnter() {
@@ -605,156 +380,156 @@ public class StreamClient implements IClient {
this.roomEnter = roomEnter;
}
- public boolean getIsRecording() {
- return isRecording;
+ public String getBroadCastId() {
+ return broadCastId;
}
- public void setIsRecording(boolean isRecording) {
- this.isRecording = isRecording;
+ public void setBroadCastId(String broadCastId) {
+ this.broadCastId = broadCastId;
}
- public String getRoomRecordingName() {
- return roomRecordingName;
+ public String getUsername() {
+ return username;
}
- public void setRoomRecordingName(String roomRecordingName) {
- this.roomRecordingName = roomRecordingName;
+ public void setUsername(String username) {
+ this.username = username;
}
- public String getAvsettings() {
- return avsettings;
+ public Long getUserId() {
+ return userId;
}
- public void setAvsettings(String avsettings) {
- this.avsettings = avsettings;
+ public void setUserId(Long userId) {
+ this.userId = userId;
}
- public String getBroadCastId() {
- return broadCastId;
+ public String getFirstname() {
+ return firstname;
}
- public void setBroadCastId(String broadCastId) {
- this.broadCastId = broadCastId;
+ public void setFirstname(String firstname) {
+ this.firstname = firstname;
}
- public String getPublicSID() {
- return publicSID;
+ public String getLastname() {
+ return lastname;
}
- public void setPublicSID(String publicSID) {
- this.publicSID = publicSID;
+ public void setLastname(String lastname) {
+ this.lastname = lastname;
}
- public boolean getZombieCheckFlag() {
- return zombieCheckFlag;
+ public String getEmail() {
+ return email;
}
- public void setZombieCheckFlag(boolean zombieCheckFlag) {
- this.zombieCheckFlag = zombieCheckFlag;
+ public void setEmail(String email) {
+ this.email = email;
}
- public boolean getMicMuted() {
- return micMuted;
+ public String getLastLogin() {
+ return lastLogin;
}
- public void setMicMuted(boolean micMuted) {
- this.micMuted = micMuted;
+ public void setLastLogin(String lastLogin) {
+ this.lastLogin = lastLogin;
}
- public boolean getCanDraw() {
- return canDraw;
+ public String getPicture_uri() {
+ return picture_uri;
}
- public void setCanDraw(boolean canDraw) {
- this.canDraw = canDraw;
+ public void setPicture_uri(String picture_uri) {
+ this.picture_uri = picture_uri;
}
- public boolean getIsBroadcasting() {
- return isBroadcasting;
+ public String getLanguage() {
+ return language;
}
- public void setIsBroadcasting(boolean isBroadcasting) {
- this.isBroadcasting = isBroadcasting;
+ public void setLanguage(String language) {
+ this.language = language;
}
- public boolean getCanShare() {
- return canShare;
+ public String getAvsettings() {
+ return avsettings;
}
- public void setCanShare(boolean canShare) {
- this.canShare = canShare;
+ public void setAvsettings(String avsettings) {
+ this.avsettings = avsettings;
}
- public String getExternalUserId() {
- return externalUserId;
+ public String getSwfurl() {
+ return swfurl;
}
- public void setExternalUserId(String externalUserId) {
- this.externalUserId = externalUserId;
+ public void setSwfurl(String swfurl) {
+ this.swfurl = swfurl;
}
- public String getExternalUserType() {
- return externalUserType;
+ public String getTcUrl() {
+ return tcUrl;
}
- public void setExternalUserType(String externalUserType) {
- this.externalUserType = externalUserType;
+ public void setTcUrl(String tcUrl) {
+ this.tcUrl = tcUrl;
}
- public boolean getIsSuperModerator() {
- return isSuperModerator;
+ public boolean isNativeSsl() {
+ return nativeSsl;
}
- public void setIsSuperModerator(boolean isSuperModerator) {
- this.isSuperModerator = isSuperModerator;
+ public void setNativeSsl(boolean nativeSsl) {
+ this.nativeSsl = nativeSsl;
}
- public boolean isScreenClient() {
- return screenClient;
+ public boolean isMobile() {
+ return mobile;
}
- public void setScreenClient(boolean screenClient) {
- this.screenClient = screenClient;
+ public void setMobile(boolean mobile) {
+ this.mobile = mobile;
}
- public int getVWidth() {
- return vWidth;
+ public boolean isSharing() {
+ return sharing;
}
- public void setVWidth(int width) {
- vWidth = width;
+ public void setSharing(boolean sharing) {
+ this.sharing = sharing;
}
- public int getVHeight() {
- return vHeight;
+ public boolean isRecordingStarted() {
+ return recordingStarted;
}
- public void setVHeight(int height) {
- vHeight = height;
+ public void setRecordingStarted(boolean recordingStarted) {
+ this.recordingStarted = recordingStarted;
}
- public int getVX() {
- return vX;
+ public boolean isSharingStarted() {
+ return sharingStarted;
}
- public void setVX(int vx) {
- vX = vx;
+ public void setSharingStarted(boolean sharingStarted) {
+ this.sharingStarted = sharingStarted;
}
- public int getVY() {
- return vY;
+ public boolean isPublishStarted() {
+ return publishStarted;
}
- public void setVY(int vy) {
- vY = vy;
+ public void setPublishStarted(boolean publishStarted) {
+ this.publishStarted = publishStarted;
}
- public String getStreamPublishName() {
- return streamPublishName;
+ public boolean isBroadcasting() {
+ return broadcasting;
}
- public void setStreamPublishName(String streamPublishName) {
- this.streamPublishName = streamPublishName;
+ public void setBroadcasting(boolean isBroadcasting) {
+ this.broadcasting = isBroadcasting;
}
public Long getRecordingId() {
@@ -765,36 +540,28 @@ public class StreamClient implements IClient {
this.recordingId = recordingId;
}
- public Long getRecordingMetaDataId() {
- return recordingMetaDataId;
+ public Long getMetaId() {
+ return metaId;
}
- public void setRecordingMetaDataId(Long recordingMetaDataId) {
- this.recordingMetaDataId = recordingMetaDataId;
+ public void setMetaId(Long metaId) {
+ this.metaId = metaId;
}
- public boolean isScreenPublishStarted() {
- return screenPublishStarted;
- }
-
- public void setScreenPublishStarted(boolean screenPublishStarted) {
- this.screenPublishStarted = screenPublishStarted;
- }
-
- public boolean isStartRecording() {
- return startRecording;
+ public String getExternalUserId() {
+ return externalUserId;
}
- public void setStartRecording(boolean startRecording) {
- this.startRecording = startRecording;
+ public void setExternalUserId(String externalUserId) {
+ this.externalUserId = externalUserId;
}
- public boolean isStartStreaming() {
- return startStreaming;
+ public String getExternalUserType() {
+ return externalUserType;
}
- public void setStartStreaming(boolean startStreaming) {
- this.startStreaming = startStreaming;
+ public void setExternalUserType(String externalUserType) {
+ this.externalUserType = externalUserType;
}
public Integer getInterviewPodId() {
@@ -805,30 +572,6 @@ public class StreamClient implements IClient {
this.interviewPodId = interviewPodId;
}
- public boolean getCanRemote() {
- return canRemote;
- }
-
- public void setCanRemote(boolean canRemote) {
- this.canRemote = canRemote;
- }
-
- public boolean getCanGiveAudio() {
- return canGiveAudio;
- }
-
- public void setCanGiveAudio(boolean canGiveAudio) {
- this.canGiveAudio = canGiveAudio;
- }
-
- public boolean getCanVideo() {
- return canVideo;
- }
-
- public void setCanVideo(boolean canVideo) {
- this.canVideo = canVideo;
- }
-
public boolean isAllowRecording() {
return allowRecording;
}
@@ -837,12 +580,12 @@ public class StreamClient implements IClient {
this.allowRecording = allowRecording;
}
- public boolean isStreamPublishStarted() {
- return streamPublishStarted;
+ public boolean isMicMuted() {
+ return micMuted;
}
- public void setStreamPublishStarted(boolean streamPublishStarted) {
- this.streamPublishStarted = streamPublishStarted;
+ public void setMicMuted(boolean micMuted) {
+ this.micMuted = micMuted;
}
public boolean isSipTransport() {
@@ -861,36 +604,15 @@ public class StreamClient implements IClient {
this.server = server;
}
- public boolean isMobile() {
- return mobile;
- }
-
- public void setMobile(boolean mobile) {
- this.mobile = mobile;
- }
-
- public String getTcUrl() {
- return tcUrl;
- }
-
- public void setTcUrl(String tcUrl) {
- this.tcUrl = tcUrl;
- }
-
- public boolean isNativeSsl() {
- return nativeSsl;
- }
-
- public void setNativeSsl(boolean nativeSsl) {
- this.nativeSsl = nativeSsl;
+ public Long getRoomId() {
+ return roomId;
}
@Override
public String toString() {
- return "Client [streamid=" + streamid + ", publicSID=" + publicSID + ", isScreenClient=" + screenClient
- + ", isMobile = " + mobile + ", roomId=" + roomId + ", broadCastID=" + broadCastId + ", userId="
- + userId + ", avsettings=" + avsettings + ", isRecording=" + isRecording + ", recordingId="
- + recordingId + ", recordingMetaDataId=" + recordingMetaDataId + ", screenPublishStarted="
- + screenPublishStarted + ", interviewPodId=" + interviewPodId + ", server=" + server + "]";
+ return "StreamClient [scope=" + scope + ", uid=" + uid + ", ownerSid=" + ownerSid + ", broadCastId="
+ + broadCastId + ", username=" + username + ", userId=" + userId + ", avsettings=" + avsettings + ", sharing=" + sharing
+ + ", isBroadcasting=" + broadcasting + "]";
}
+
}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/117e8d6b/openmeetings-flash/src/main/flex/main.mxml
----------------------------------------------------------------------
diff --git a/openmeetings-flash/src/main/flex/main.mxml b/openmeetings-flash/src/main/flex/main.mxml
index 585773d..429bdb2 100644
--- a/openmeetings-flash/src/main/flex/main.mxml
+++ b/openmeetings-flash/src/main/flex/main.mxml
@@ -115,7 +115,9 @@
video.reset();
var cam:Camera = getCam();
video.attachCamera(cam);
- video.broadcast(UIDUtil.createUID(), cam, getMic());
+ var broadcastId:String = UIDUtil.createUID();
+ debug("BroadcastId = " + broadcastId);
+ video.broadcast(broadcastId, cam, getMic());
ExternalInterface.call("VideoManager.resetSize", params.uid);
});
}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/117e8d6b/openmeetings-flash/src/main/flex/org/apache/openmeetings/OmVideo.as
----------------------------------------------------------------------
diff --git a/openmeetings-flash/src/main/flex/org/apache/openmeetings/OmVideo.as b/openmeetings-flash/src/main/flex/org/apache/openmeetings/OmVideo.as
index b2a743e..86f5f12 100644
--- a/openmeetings-flash/src/main/flex/org/apache/openmeetings/OmVideo.as
+++ b/openmeetings-flash/src/main/flex/org/apache/openmeetings/OmVideo.as
@@ -169,7 +169,7 @@ public class OmVideo {
private function _connect(url:String):void {
nc.connect(url, {
uid: params.uid
- , sid: params.sid
+ , ownerSid: params.sid
, nativeSsl: 'best' == params.proxyType
});
}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/117e8d6b/openmeetings-screenshare/src/main/java/org/apache/openmeetings/screenshare/Core.java
----------------------------------------------------------------------
diff --git a/openmeetings-screenshare/src/main/java/org/apache/openmeetings/screenshare/Core.java b/openmeetings-screenshare/src/main/java/org/apache/openmeetings/screenshare/Core.java
index 65831ab..738b158 100644
--- a/openmeetings-screenshare/src/main/java/org/apache/openmeetings/screenshare/Core.java
+++ b/openmeetings-screenshare/src/main/java/org/apache/openmeetings/screenshare/Core.java
@@ -35,6 +35,7 @@ import java.net.ConnectException;
import java.net.URI;
import java.util.HashMap;
import java.util.Map;
+import java.util.UUID;
import java.util.concurrent.LinkedBlockingQueue;
import org.apache.openmeetings.screenshare.gui.ScreenSharerFrame;
@@ -82,7 +83,7 @@ public class Core implements IPendingServiceCallback, INetStreamEventHandler {
private String app;
private int port;
- public String publishName;
+ public String sid;
private CaptureScreen _capture = null;
private RTMPClientPublish publishClient = null;
@@ -129,7 +130,7 @@ public class Core implements IPendingServiceCallback, INetStreamEventHandler {
if (args.length > 8) {
url = new URI(args[0]);
fallback = new URI(args[1]);
- publishName = args[2];
+ sid = args[2];
String labelTexts = args[3];
defaultQuality = Integer.parseInt(args[4]);
defaultFPS = Integer.parseInt(args[5]);
@@ -193,7 +194,7 @@ public class Core implements IPendingServiceCallback, INetStreamEventHandler {
throw new RuntimeException("Unsupported protocol");
}
instance.setServiceProvider(this);
- log.debug(String.format("host: %s, port: %s, app: %s, publish: %s", host, port, app, publishName));
+ log.debug(String.format("host: %s, port: %s, app: %s, publish: %s", host, port, app, sid));
}
public static void main(String[] args) {
@@ -228,7 +229,6 @@ public class Core implements IPendingServiceCallback, INetStreamEventHandler {
int y = (int)(Ampl_factor * (mouseP.getY() - spinnerY) * scaleFactor);
Map<String, Object> cursorPosition = new HashMap<>();
- cursorPosition.put("publicSID", publishName);
cursorPosition.put("cursor_x", x);
cursorPosition.put("cursor_y", y);
@@ -259,15 +259,12 @@ public class Core implements IPendingServiceCallback, INetStreamEventHandler {
Red5.setConnectionLocal(instance.getConnection());
}
Map<String, Object> map = new HashMap<>();
- map.put("screenX", spinnerX);
- map.put("screenY", spinnerY);
int scaledWidth = (int)(Ampl_factor * resizeX);
int scaledHeight = (int)(Ampl_factor * resizeY);
map.put("screenWidth", scaledWidth);
map.put("screenHeight", scaledHeight);
- map.put("publishName", publishName);
map.put("startRecording", startRecording);
map.put("startStreaming", startSharing);
map.put("startPublishing", startPublishing);
@@ -304,12 +301,12 @@ public class Core implements IPendingServiceCallback, INetStreamEventHandler {
captureScreenStart();
}
- private void connect(String parentSid) {
+ private void connect(String sid) {
setInstance(fallbackUsed ? fallback : url);
Map<String, Object> map = instance.makeDefaultConnectionParams(host, port, app);
map.put("screenClient", true);
Map<String, Object> params = new HashMap<>();
- params.put("uid", parentSid);
+ params.put("ownerSid", sid);
instance.connect(host, port, map, this, new Object[]{params});
}
@@ -317,7 +314,7 @@ public class Core implements IPendingServiceCallback, INetStreamEventHandler {
frame.setStatus("Exception: " + e);
if (e instanceof ConnectException) {
fallbackUsed = true;
- connect(publishName);
+ connect(sid);
}
}
@@ -326,7 +323,7 @@ public class Core implements IPendingServiceCallback, INetStreamEventHandler {
log.debug("captureScreenStart");
if (!isConnected) {
- connect(publishName);
+ connect(sid);
} else {
setConnectionAsSharingClient();
}
@@ -447,7 +444,9 @@ public class Core implements IPendingServiceCallback, INetStreamEventHandler {
stopPublishing();
isConnected = false;
- instance.disconnect();
+ if (instance != null) {
+ instance.disconnect();
+ }
setReadyToRecord(false);
getCapture().setStartPublish(false);
getCapture().release();
@@ -510,7 +509,7 @@ public class Core implements IPendingServiceCallback, INetStreamEventHandler {
Object code = returnMap.get("code");
if (CONNECT_FAILED.equals(code) && !fallbackUsed) {
fallbackUsed = true;
- connect(publishName);
+ connect(sid);
frame.setStatus("Re-connecting using fallback");
return;
}
@@ -553,8 +552,9 @@ public class Core implements IPendingServiceCallback, INetStreamEventHandler {
if (o != null && o instanceof Number) {
getCapture().setStreamId((Number)o);
}
- log.debug("createPublishStream result stream id: {}; name: {}", getCapture().getStreamId(), publishName);
- instance.publish(getCapture().getStreamId(), publishName, "live", this);
+ final String broadcastId = UUID.randomUUID().toString();
+ log.debug("createPublishStream result stream id: {}; name: {}", getCapture().getStreamId(), broadcastId);
+ instance.publish(getCapture().getStreamId(), broadcastId, "live", this);
log.debug("setup capture thread spinnerWidth = {}; spinnerHeight = {};", spinnerWidth, spinnerHeight);
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/117e8d6b/openmeetings-screenshare/src/main/jnlp/templates/template.jnlp
----------------------------------------------------------------------
diff --git a/openmeetings-screenshare/src/main/jnlp/templates/template.jnlp b/openmeetings-screenshare/src/main/jnlp/templates/template.jnlp
index 2e1c9f8..e6ba15c 100644
--- a/openmeetings-screenshare/src/main/jnlp/templates/template.jnlp
+++ b/openmeetings-screenshare/src/main/jnlp/templates/template.jnlp
@@ -39,7 +39,7 @@
<application-desc main-class='org.apache.openmeetings.screenshare.Core'>
<argument>$url</argument>
<argument>$fallback</argument>
- <argument>$publicSid</argument>
+ <argument>$sid</argument>
<argument>$labels</argument>
<argument>$defaultQuality</argument>
<argument>$defaultFps</argument>
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/117e8d6b/openmeetings-service/src/main/java/org/apache/openmeetings/service/user/UserManager.java
----------------------------------------------------------------------
diff --git a/openmeetings-service/src/main/java/org/apache/openmeetings/service/user/UserManager.java b/openmeetings-service/src/main/java/org/apache/openmeetings/service/user/UserManager.java
index 4ede92b..d8e604d 100644
--- a/openmeetings-service/src/main/java/org/apache/openmeetings/service/user/UserManager.java
+++ b/openmeetings-service/src/main/java/org/apache/openmeetings/service/user/UserManager.java
@@ -60,7 +60,6 @@ import org.apache.openmeetings.db.entity.user.User;
import org.apache.openmeetings.db.entity.user.User.Right;
import org.apache.openmeetings.db.entity.user.User.Type;
import org.apache.openmeetings.db.entity.user.Userdata;
-import org.apache.openmeetings.db.util.AuthLevelUtil;
import org.apache.openmeetings.db.util.TimezoneUtil;
import org.apache.openmeetings.service.mail.EmailManager;
import org.apache.openmeetings.util.DaoHelper;
@@ -410,65 +409,56 @@ public class UserManager implements IUserManager {
* @return
*/
@Override
- public boolean kickUserByStreamId(String sid, Long room_id) {
+ public boolean kickUsersByRoomId(Long roomId) {
try {
- Sessiondata sd = sessionDao.check(sid);
- // admins only
- if (AuthLevelUtil.hasAdminLevel(userDao.getRights(sd.getUserId()))) {
-
- sessionDao.clearSessionByRoomId(room_id);
-
- for (StreamClient rcl : sessionManager.getClientListByRoom(room_id)) {
- if (rcl == null) {
- return true;
- }
- String scopeName = "hibernate";
- if (rcl.getRoomId() != null) {
- scopeName = rcl.getRoomId().toString();
- }
- IScope currentScope = scopeApplicationAdapter.getRoomScope(scopeName);
- scopeApplicationAdapter.roomLeaveByScope(rcl, currentScope);
-
- Map<Integer, String> messageObj = new HashMap<>();
- messageObj.put(0, "kick");
- scopeApplicationAdapter.sendMessageById(messageObj, rcl.getStreamid(), currentScope);
- }
- return true;
- }
- } catch (Exception err) {
- log.error("[kickUserByStreamId]", err);
- }
- return false;
- }
-
- @Override
- public boolean kickUserByPublicSID(String sid, String publicSID) {
- try {
- Sessiondata sd = sessionDao.check(sid);
- // admins only
- if (AuthLevelUtil.hasWebServiceLevel(userDao.getRights(sd.getUserId()))) {
- StreamClient rcl = sessionManager.getClientByPublicSID(publicSID, null);
+ sessionDao.clearSessionByRoomId(roomId);
+ for (StreamClient rcl : sessionManager.getClientListByRoom(roomId)) {
if (rcl == null) {
return true;
}
-
String scopeName = "hibernate";
if (rcl.getRoomId() != null) {
scopeName = rcl.getRoomId().toString();
}
IScope currentScope = scopeApplicationAdapter.getRoomScope(scopeName);
+ scopeApplicationAdapter.roomLeaveByScope(rcl, currentScope);
Map<Integer, String> messageObj = new HashMap<>();
messageObj.put(0, "kick");
- scopeApplicationAdapter.sendMessageById(messageObj, rcl.getStreamid(), currentScope);
+ scopeApplicationAdapter.sendMessageById(messageObj, rcl.getId(), currentScope);
+ }
+ return true;
+ } catch (Exception err) {
+ log.error("[kickUsersByRoomId]", err);
+ }
+ return false;
+ }
- scopeApplicationAdapter.roomLeaveByScope(rcl, currentScope);
+ @Override
+ public boolean kickById(Long id) {
+ try {
+ StreamClient rcl = sessionManager.get(id);
+ if (rcl == null) {
return true;
}
+
+ String scopeName = "hibernate";
+ if (rcl.getRoomId() != null) {
+ scopeName = rcl.getRoomId().toString();
+ }
+ IScope currentScope = scopeApplicationAdapter.getRoomScope(scopeName);
+
+ Map<Integer, String> messageObj = new HashMap<>();
+ messageObj.put(0, "kick");
+ scopeApplicationAdapter.sendMessageById(messageObj, rcl.getId(), currentScope);
+
+ scopeApplicationAdapter.roomLeaveByScope(rcl, currentScope);
+
+ return true;
} catch (Exception err) {
- log.error("[kickUserByStreamId]", err);
+ log.error("[kickById]", err);
}
return false;
}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/117e8d6b/openmeetings-web/src/main/java/org/apache/openmeetings/web/admin/connection/ConnectionsPanel.java
----------------------------------------------------------------------
diff --git a/openmeetings-web/src/main/java/org/apache/openmeetings/web/admin/connection/ConnectionsPanel.java b/openmeetings-web/src/main/java/org/apache/openmeetings/web/admin/connection/ConnectionsPanel.java
index 0d8e37d..ad1c752 100644
--- a/openmeetings-web/src/main/java/org/apache/openmeetings/web/admin/connection/ConnectionsPanel.java
+++ b/openmeetings-web/src/main/java/org/apache/openmeetings/web/admin/connection/ConnectionsPanel.java
@@ -19,7 +19,6 @@
package org.apache.openmeetings.web.admin.connection;
import static org.apache.openmeetings.web.app.Application.getBean;
-import static org.apache.openmeetings.web.app.WebSession.getSid;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
@@ -28,9 +27,10 @@ import java.util.Iterator;
import java.util.List;
import org.apache.openmeetings.db.dao.server.ISessionManager;
-import org.apache.openmeetings.db.dao.user.IUserService;
+import org.apache.openmeetings.db.entity.basic.Client;
import org.apache.openmeetings.db.entity.basic.IClient;
import org.apache.openmeetings.db.entity.room.StreamClient;
+import org.apache.openmeetings.service.user.UserManager;
import org.apache.openmeetings.web.admin.AdminPanel;
import org.apache.openmeetings.web.admin.SearchableDataView;
import org.apache.openmeetings.web.app.Application;
@@ -91,11 +91,10 @@ public class ConnectionsPanel extends AdminPanel {
IClient _c = item.getModelObject();
if (_c instanceof StreamClient) {
StreamClient c = (StreamClient)_c;
- getBean(IUserService.class).kickUserByStreamId(getSid(), c.getStreamid()
- , c.getServer() == null ? 0 : c.getServer().getId());
+ getBean(UserManager.class).kickById(c.getId());
} else {
- org.apache.openmeetings.db.entity.basic.Client c = (org.apache.openmeetings.db.entity.basic.Client)_c;
- getBean(IUserService.class).kickUserBySessionId(getSid(), c.getUserId(), c.getSessionId());
+ Client c = (Client)_c;
+ Application.get().invalidateClient(c.getUserId(), c.getSessionId());
}
target.add(container, details.setVisible(false));
}
@@ -107,9 +106,9 @@ public class ConnectionsPanel extends AdminPanel {
item.add(new Label("since", c.getConnectedSince()));
item.add(new Label("scope"));
item.add(new Label("server", c.getServer() == null ? "no cluster" : c.getServer().getAddress())); //FIXME localization
- confirm.setEnabled(!c.isScreenClient());
+ confirm.setEnabled(!c.isSharing());
} else {
- org.apache.openmeetings.db.entity.basic.Client c = (org.apache.openmeetings.db.entity.basic.Client)_c;
+ Client c = (Client)_c;
item.add(new Label("streamid", ""));
item.add(new Label("login", c.getUser().getLogin()));
item.add(new Label("since", c.getConnectedSince()));
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/117e8d6b/openmeetings-web/src/main/java/org/apache/openmeetings/web/admin/rooms/RoomForm.java
----------------------------------------------------------------------
diff --git a/openmeetings-web/src/main/java/org/apache/openmeetings/web/admin/rooms/RoomForm.java b/openmeetings-web/src/main/java/org/apache/openmeetings/web/admin/rooms/RoomForm.java
index e8ffa21..869b36d 100644
--- a/openmeetings-web/src/main/java/org/apache/openmeetings/web/admin/rooms/RoomForm.java
+++ b/openmeetings-web/src/main/java/org/apache/openmeetings/web/admin/rooms/RoomForm.java
@@ -21,7 +21,6 @@ package org.apache.openmeetings.web.admin.rooms;
import static org.apache.openmeetings.db.util.AuthLevelUtil.hasGroupAdminLevel;
import static org.apache.openmeetings.web.app.Application.getBean;
import static org.apache.openmeetings.web.app.WebSession.getRights;
-import static org.apache.openmeetings.web.app.WebSession.getSid;
import static org.apache.openmeetings.web.app.WebSession.getUserId;
import java.util.ArrayList;
@@ -32,7 +31,6 @@ import java.util.List;
import org.apache.openmeetings.db.dao.room.RoomDao;
import org.apache.openmeetings.db.dao.server.ISessionManager;
import org.apache.openmeetings.db.dao.user.GroupDao;
-import org.apache.openmeetings.db.dao.user.IUserService;
import org.apache.openmeetings.db.dao.user.UserDao;
import org.apache.openmeetings.db.entity.room.Room;
import org.apache.openmeetings.db.entity.room.Room.RoomElement;
@@ -42,6 +40,7 @@ import org.apache.openmeetings.db.entity.room.StreamClient;
import org.apache.openmeetings.db.entity.user.Address;
import org.apache.openmeetings.db.entity.user.Group;
import org.apache.openmeetings.db.entity.user.User;
+import org.apache.openmeetings.service.user.UserManager;
import org.apache.openmeetings.web.admin.AdminBaseForm;
import org.apache.openmeetings.web.admin.AdminUserChoiceProvider;
import org.apache.openmeetings.web.app.Application;
@@ -97,9 +96,7 @@ public class RoomForm extends AdminBaseForm<Room> {
@Override
protected void onSubmit(AjaxRequestTarget target) {
StreamClient c = item.getModelObject();
- getBean(IUserService.class).kickUserByStreamId(getSid(), c.getStreamid()
- , c.getServer() == null ? 0 : c.getServer().getId());
-
+ getBean(UserManager.class).kickById(c.getId());
updateClients(target);
}
});
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/117e8d6b/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/Application.java
----------------------------------------------------------------------
diff --git a/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/Application.java b/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/Application.java
index 7b68bf9..f6330a9 100644
--- a/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/Application.java
+++ b/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/Application.java
@@ -122,6 +122,7 @@ public class Application extends AuthenticatedWebApplication implements IApplica
private static final Logger log = getLogger(Application.class, webAppRootKey);
private static boolean isInstalled;
private static ConcurrentHashMap<String, Client> ONLINE_USERS = new ConcurrentHashMap<>();
+ private static ConcurrentHashMap<String, String> UID_BY_SID = new ConcurrentHashMap<>();
private static ConcurrentHashMap<String, Client> INVALID_SESSIONS = new ConcurrentHashMap<>();
private static ConcurrentHashMap<Long, Set<String>> ROOMS = new ConcurrentHashMap<>();
//additional maps for faster searching should be created
@@ -257,6 +258,7 @@ public class Application extends AuthenticatedWebApplication implements IApplica
public static void addOnlineUser(Client c) {
log.debug("Adding online client: {}, room: {}", c.getUid(), c.getRoomId());
ONLINE_USERS.put(c.getUid(), c);
+ UID_BY_SID.put(c.getSid(), c.getUid());
}
public static void exitRoom(Client c) {
@@ -279,13 +281,14 @@ public class Application extends AuthenticatedWebApplication implements IApplica
}
}
- public static void exit(Client c) {
+ private static void exit(Client c) {
if (c != null) {
if (c.getRoomId() != null) {
exitRoom(c);
}
log.debug("Removing online client: {}, room: {}", c.getUid(), c.getRoomId());
ONLINE_USERS.remove(c.getUid());
+ UID_BY_SID.remove(c.getSid());
}
}
@@ -302,66 +305,61 @@ public class Application extends AuthenticatedWebApplication implements IApplica
if (rcl == null) {
return null;
}
- if (!rcl.isScreenClient() && (!rcl.isMobile() || (rcl.isMobile() && rcl.getUserId() != null))) {
- Client client = getOnlineClient(rcl.getPublicSID());
- if (client == null) {
- if (!Strings.isEmpty(rcl.getSecurityCode())) {
- client = getOnlineClient(rcl.getSecurityCode());
- }
- if (client == null && rcl.isMobile()) {
- //Mobile client enters the room
- client = new Client(rcl, getBean(UserDao.class));
- addOnlineUser(client);
- if (rcl.getRoomId() != null) {
- client.setCam(0);
- client.setMic(0);
- addUserToRoom(client);
- //FIXME TODO unify this
- WebSocketHelper.sendRoom(new RoomMessage(client.getRoomId(), client.getUserId(), RoomMessage.Type.roomEnter));
- }
- //FIXME TODO rights
- } else if (client == null) {
- return null;
- } else if (!client.hasRight(Right.audio) && !client.hasRight(Right.video)) {
- log.warn("Parent client has no AV rights, going reject client");
- return null;
+ Client client = getClientBySid(rcl.getOwnerSid());
+ if (client == null) {
+ if (rcl.isMobile()) {
+ //Mobile client enters the room
+ client = new Client(rcl, getBean(UserDao.class));
+ addOnlineUser(client);
+ if (rcl.getRoomId() != null) {
+ client.setCam(0);
+ client.setMic(0);
+ addUserToRoom(client);
+ //FIXME TODO unify this
+ WebSocketHelper.sendRoom(new RoomMessage(client.getRoomId(), client.getUserId(), RoomMessage.Type.roomEnter));
}
+ //FIXME TODO rights
+ } else {
+ return null;
}
- rcl.setFirstname(client.getUser().getFirstname());
- rcl.setLastname(client.getUser().getLastname());
- rcl.setIsSuperModerator(client.hasRight(Right.superModerator));
- rcl.setIsMod(client.hasRight(Right.moderator));
- rcl.setCanVideo(client.hasRight(Right.video) && client.isCamEnabled() && client.hasActivity(Activity.broadcastV));
- rcl.setCanDraw(client.hasRight(Right.whiteBoard));
- if (client.hasActivity(Activity.broadcastA) && client.getMic() < 0) {
- client.remove(Activity.broadcastA);
+ }
+ if (rcl.getRoomId() == null || !rcl.getRoomId().equals(client.getRoomId())) {
+ //TODO mobile
+ return null;
+ }
+ rcl.setFirstname(client.getUser().getFirstname());
+ rcl.setLastname(client.getUser().getLastname());
+ rcl.setSuperMod(client.hasRight(Right.superModerator));
+ rcl.setMod(client.hasRight(Right.moderator));
+ rcl.setCanVideo(client.hasRight(Right.video) && client.isCamEnabled() && client.hasActivity(Activity.broadcastV));
+ if (client.hasActivity(Activity.broadcastA) && client.getMic() < 0) {
+ client.remove(Activity.broadcastA);
+ }
+ if (client.hasActivity(Activity.broadcastV) && client.getCam() < 0) {
+ client.remove(Activity.broadcastV);
+ }
+ if (client.hasActivity(Activity.broadcastA) || client.hasActivity(Activity.broadcastV)) {
+ if (forceSize || rcl.getWidth() == 0 || rcl.getHeight() == 0) {
+ rcl.setWidth(client.getWidth());
+ rcl.setHeight(client.getHeight());
}
- if (client.hasActivity(Activity.broadcastV) && client.getCam() < 0) {
- client.remove(Activity.broadcastV);
+ if (client.getPod() != Pod.none) {
+ rcl.setInterviewPodId(client.getPod() == Pod.left ? 1 : 2);
}
- if (client.hasActivity(Activity.broadcastA) || client.hasActivity(Activity.broadcastV)) {
- if (forceSize || rcl.getVWidth() == 0 || rcl.getVHeight() == 0) {
- rcl.setVWidth(client.getWidth());
- rcl.setVHeight(client.getHeight());
- }
- if (client.getPod() != Pod.none) {
- rcl.setInterviewPodId(client.getPod() == Pod.left ? 1 : 2);
- }
- StringBuilder sb = new StringBuilder();
- if (client.hasActivity(Activity.broadcastA)) {
- sb.append('a');
- }
- if (client.hasActivity(Activity.broadcastV)) {
- sb.append('v');
- }
- if (!rcl.getIsBroadcasting() || hasVideo(rcl) != hasVideo(client)) {
- rcl.setIsBroadcasting(true);
- }
- rcl.setAvsettings(sb.toString());
- } else {
- rcl.setAvsettings("n");
- rcl.setIsBroadcasting(false);
+ StringBuilder sb = new StringBuilder();
+ if (client.hasActivity(Activity.broadcastA)) {
+ sb.append('a');
+ }
+ if (client.hasActivity(Activity.broadcastV)) {
+ sb.append('v');
+ }
+ if (!rcl.isBroadcasting() || hasVideo(rcl) != hasVideo(client)) {
+ rcl.setBroadcasting(true);
}
+ rcl.setAvsettings(sb.toString());
+ } else {
+ rcl.setAvsettings("n");
+ rcl.setBroadcasting(false);
}
return rcl;
}
@@ -370,6 +368,19 @@ public class Application extends AuthenticatedWebApplication implements IApplica
return uid == null ? null : ONLINE_USERS.get(uid);
}
+ @Override
+ public Client getOmClientBySid(String sid) {
+ return getClientBySid(sid);
+ }
+
+ public static Client getClientBySid(String sid) {
+ if (sid == null) {
+ return null;
+ }
+ String uid = UID_BY_SID.get(sid);
+ return uid == null ? null : ONLINE_USERS.get(uid);
+ }
+
public static boolean isUserOnline(Long userId) {
boolean isUserOnline = false;
for (Map.Entry<String, Client> e : ONLINE_USERS.entrySet()) {
@@ -446,8 +457,7 @@ public class Application extends AuthenticatedWebApplication implements IApplica
c.setRoomId(null);
}
getBean(ScopeApplicationAdapter.class).roomLeaveByScope(c.getUid(), roomId);
- c.getActivities().clear();
- c.clearRights();
+ c.clear();
}
return c;
}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/117e8d6b/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/WebSession.java
----------------------------------------------------------------------
diff --git a/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/WebSession.java b/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/WebSession.java
index 72939d8..c624e36 100644
--- a/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/WebSession.java
+++ b/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/WebSession.java
@@ -24,10 +24,8 @@ import static org.apache.openmeetings.util.OpenmeetingsVariables.CONFIG_DASHBOAR
import static org.apache.openmeetings.util.OpenmeetingsVariables.CONFIG_DASHBOARD_SHOW_RSS_KEY;
import static org.apache.openmeetings.util.OpenmeetingsVariables.CONFIG_DEFAULT_LANG_KEY;
import static org.apache.openmeetings.util.OpenmeetingsVariables.webAppRootKey;
-import static org.apache.openmeetings.web.app.Application.exit;
import static org.apache.openmeetings.web.app.Application.getAuthenticationStrategy;
import static org.apache.openmeetings.web.app.Application.getBean;
-import static org.apache.openmeetings.web.app.Application.getClientByKeys;
import static org.apache.openmeetings.web.app.Application.getDashboardContext;
import static org.apache.openmeetings.web.app.Application.isInvaldSession;
import static org.apache.openmeetings.web.app.Application.removeInvalidSession;
@@ -100,7 +98,6 @@ public class WebSession extends AbstractAuthenticatedWebSession implements IWebS
private Long userId = null;
private Set<Right> rights = new HashSet<>(); //TODO renew somehow on user edit !!!!
private long languageId = -1; //TODO renew somehow on user edit !!!!
- private String SID = null;
private OmUrlFragment area = null;
private TimeZone tz;
private TimeZone browserTz;
@@ -123,11 +120,10 @@ public class WebSession extends AbstractAuthenticatedWebSession implements IWebS
@Override
public void invalidate() {
- exit(getClientByKeys(userId, getId()));
+ Application.get().invalidateClient(userId, getId());
super.invalidate();
userId = null;
rights = Collections.unmodifiableSet(Collections.<Right>emptySet());
- SID = null;
ISO8601FORMAT = null;
sdf = null;
languageId = -1;
@@ -273,7 +269,6 @@ public class WebSession extends AbstractAuthenticatedWebSession implements IWebS
}
private void setUser(User u, Set<Right> rights) {
- String _sid = SID;
Long _recordingId = recordingId;
Long _roomId = roomId;
Invitation _i = i;
@@ -281,9 +276,6 @@ public class WebSession extends AbstractAuthenticatedWebSession implements IWebS
ClientInfo _info = clientInfo;
ExtendedClientProperties _extProps = extProps;
replaceSession(); // required to prevent session fixation
- if (_sid != null) {
- SID = _sid;
- }
if (_recordingId != null) {
recordingId = _recordingId;
}
@@ -379,23 +371,6 @@ public class WebSession extends AbstractAuthenticatedWebSession implements IWebS
return session.languageId;
}
- public String getValidatedSid() {
- SessiondataDao sessionDao = getBean(SessiondataDao.class);
- Sessiondata sd = sessionDao.check(SID);
- //TODO need to check roomId equality
- if (sd.getUserId() == null || !sd.getUserId().equals(userId)) {
- if (sd.getId() == null) {
- sd = sessionDao.create(userId, roomId, languageId);
- }
- SID = sd.getSessionId();
- }
- return SID;
- }
-
- public static String getSid() {
- return get().getValidatedSid();
- }
-
public static Long getUserId() {
checkIsInvalid();
return get().userId;