diff --git a/org.adempiere.ui.zk/WEB-INF/src/fi/jawsy/jawwa/zk/atmosphere/AtmosphereServerPush.java b/org.adempiere.ui.zk/WEB-INF/src/fi/jawsy/jawwa/zk/atmosphere/AtmosphereServerPush.java index e9d79628d9..4f38055916 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/fi/jawsy/jawwa/zk/atmosphere/AtmosphereServerPush.java +++ b/org.adempiere.ui.zk/WEB-INF/src/fi/jawsy/jawwa/zk/atmosphere/AtmosphereServerPush.java @@ -48,7 +48,9 @@ import org.zkoss.zk.ui.util.Clients; */ public class AtmosphereServerPush implements ServerPush { - private static final String ON_ACTIVATE_DESKTOP = "onActivateDesktop"; + private static final String ATMOSPHERE_SERVER_PUSH_ECHO = "AtmosphereServerPush.Echo"; + + private static final String ON_ACTIVATE_DESKTOP = "onActivateDesktop"; public static final int DEFAULT_TIMEOUT = 1000 * 60 * 2; @@ -161,7 +163,12 @@ public class AtmosphereServerPush implements ServerPush { @SuppressWarnings("unchecked") @Override - public void onPiggyback() { + public void onPiggyback() { + if (Executions.getCurrent() != null && Executions.getCurrent().getAttribute(ATMOSPHERE_SERVER_PUSH_ECHO) != null) { + //has pending serverpush echo, wait for next execution piggyback trigger by the pending serverpush echo + return; + } + Schedule[] pendings = null; synchronized (schedules) { if (!schedules.isEmpty()) { @@ -195,8 +202,8 @@ public class AtmosphereServerPush implements ServerPush { synchronized (schedules) { schedules.add(new Schedule(task, event, scheduler)); } - if (Executions.getCurrent().getAttribute("AtmosphereServerPush.Echo") == null) { - Executions.getCurrent().setAttribute("AtmosphereServerPush.Echo", Boolean.TRUE); + if (Executions.getCurrent().getAttribute(ATMOSPHERE_SERVER_PUSH_ECHO) == null) { + Executions.getCurrent().setAttribute(ATMOSPHERE_SERVER_PUSH_ECHO, Boolean.TRUE); Clients.response(new AuEcho()); } } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/idempiere/ui/zk/websocket/WebSocketServerPush.java b/org.adempiere.ui.zk/WEB-INF/src/org/idempiere/ui/zk/websocket/WebSocketServerPush.java index e0107e7542..1d4f9bb483 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/idempiere/ui/zk/websocket/WebSocketServerPush.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/idempiere/ui/zk/websocket/WebSocketServerPush.java @@ -52,7 +52,9 @@ import org.zkoss.zk.ui.util.Clients; */ public class WebSocketServerPush implements ServerPush { - private static final String ON_ACTIVATE_DESKTOP = "onActivateDesktop"; + private static final String ATMOSPHERE_SERVER_PUSH_ECHO = "AtmosphereServerPush.Echo"; + + private static final String ON_ACTIVATE_DESKTOP = "onActivateDesktop"; private final AtomicReference desktop = new AtomicReference(); @@ -168,6 +170,11 @@ public class WebSocketServerPush implements ServerPush { @SuppressWarnings("unchecked") @Override public void onPiggyback() { + if (Executions.getCurrent() != null && Executions.getCurrent().getAttribute(ATMOSPHERE_SERVER_PUSH_ECHO) != null) { + //has pending serverpush echo, wait for next execution piggyback trigger by the pending serverpush echo + return; + } + Schedule[] pendings = null; synchronized (schedules) { if (!schedules.isEmpty()) { @@ -208,8 +215,8 @@ public class WebSocketServerPush implements ServerPush { synchronized (schedules) { schedules.add(new Schedule(task, event, scheduler)); } - if (Executions.getCurrent().getAttribute("AtmosphereServerPush.Echo") == null) { - Executions.getCurrent().setAttribute("AtmosphereServerPush.Echo", Boolean.TRUE); + if (Executions.getCurrent().getAttribute(ATMOSPHERE_SERVER_PUSH_ECHO) == null) { + Executions.getCurrent().setAttribute(ATMOSPHERE_SERVER_PUSH_ECHO, Boolean.TRUE); Clients.response(new AuEcho()); } }