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

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


The following commit(s) were added to refs/heads/master by this push:
     new 57f3873  [OPENMEETINGS-1836] file drop seems to be fixed
57f3873 is described below

commit 57f3873fb2326ef68fc9f9b041f1e9b2df2dbf1f
Author: Maxim Solodovnik <[email protected]>
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 7e47050..1a4579c 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
@@ -46,11 +46,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.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -211,19 +213,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) {
@@ -250,8 +257,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
[email protected].

Reply via email to