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 2018/03/11 11:49:54 UTC

[openmeetings] branch 4.0.x updated: [OPENMEETINGS-1836] file drop seems to be fixed

This is an automated email from the ASF dual-hosted git repository.

solomax pushed a commit to branch 4.0.x
in repository https://gitbox.apache.org/repos/asf/openmeetings.git


The following commit(s) were added to refs/heads/4.0.x by this push:
     new 67ffe5a  [OPENMEETINGS-1836] file drop seems to be fixed
67ffe5a is described below

commit 67ffe5a9e818e80851bc9ff50349e319e32ba7e6
Author: Maxim Solodovnik <so...@gmail.com>
AuthorDate: Sun Mar 11 18:49:45 2018 +0700

    [OPENMEETINGS-1836] file drop seems to be fixed
---
 .../openmeetings/core/util/WebSocketHelper.java    | 36 ++++++++++++++--------
 1 file changed, 23 insertions(+), 13 deletions(-)

diff --git a/openmeetings-core/src/main/java/org/apache/openmeetings/core/util/WebSocketHelper.java b/openmeetings-core/src/main/java/org/apache/openmeetings/core/util/WebSocketHelper.java
index d15fb17..5daa231 100644
--- a/openmeetings-core/src/main/java/org/apache/openmeetings/core/util/WebSocketHelper.java
+++ b/openmeetings-core/src/main/java/org/apache/openmeetings/core/util/WebSocketHelper.java
@@ -47,11 +47,13 @@ import org.apache.openmeetings.db.util.ws.RoomMessage;
 import org.apache.openmeetings.db.util.ws.TextRoomMessage;
 import org.apache.openmeetings.util.ws.IClusterWsMessage;
 import org.apache.wicket.Application;
+import org.apache.wicket.ThreadContext;
 import org.apache.wicket.protocol.ws.WebSocketSettings;
 import org.apache.wicket.protocol.ws.api.IWebSocketConnection;
 import org.apache.wicket.protocol.ws.api.registry.IWebSocketConnectionRegistry;
 import org.apache.wicket.protocol.ws.api.registry.PageIdKey;
 import org.apache.wicket.protocol.ws.concurrent.Executor;
+import org.apache.wicket.request.cycle.RequestCycle;
 import org.red5.logging.Red5LoggerFactory;
 import org.slf4j.Logger;
 
@@ -200,19 +202,24 @@ public class WebSocketHelper {
 		if (publish) {
 			publish(new WsMessageAll(m));
 		}
-		Application app = (Application)getApp();
-		WebSocketSettings settings = WebSocketSettings.Holder.get(app);
-		IWebSocketConnectionRegistry reg = settings.getConnectionRegistry();
-		Executor executor = settings.getWebSocketPushMessageExecutor();
-		for (IWebSocketConnection c : reg.getConnections(app)) {
-			executor.run(() -> {
-				try {
-					c.sendMessage(m);
-				} catch (IOException e) {
-					log.error("Error while sending message to ALL", e);
-				}
-			});
-		}
+		final RequestCycle requestCycle = ThreadContext.getRequestCycle();
+		new Thread(() -> {
+			Application app = (Application)getApp();
+			ThreadContext.setRequestCycle(requestCycle);
+			ThreadContext.setApplication(app);
+			WebSocketSettings settings = WebSocketSettings.Holder.get(app);
+			IWebSocketConnectionRegistry reg = settings.getConnectionRegistry();
+			Executor executor = settings.getWebSocketPushMessageExecutor();
+			for (IWebSocketConnection c : reg.getConnections(app)) {
+				executor.run(() -> {
+					try {
+						c.sendMessage(m);
+					} catch (IOException e) {
+						log.error("Error while sending message to ALL", e);
+					}
+				});
+			}
+		}).start();
 	}
 
 	protected static void publish(IClusterWsMessage m) {
@@ -239,8 +246,11 @@ public class WebSocketHelper {
 			, BiConsumer<IWebSocketConnection, Client> consumer
 			, Predicate<Client> check)
 	{
+		final RequestCycle requestCycle = ThreadContext.getRequestCycle();
 		new Thread(() -> {
 			Application app = (Application)getApp();
+			ThreadContext.setRequestCycle(requestCycle);
+			ThreadContext.setApplication(app);
 			WebSocketSettings settings = WebSocketSettings.Holder.get(app);
 			IWebSocketConnectionRegistry reg = settings.getConnectionRegistry();
 			Executor executor = settings.getWebSocketPushMessageExecutor();

-- 
To stop receiving notification emails like this one, please contact
solomax@apache.org.