IDEMPIERE-4154 ServerPush Adjustments. Further refinement of the long polling serverpush implmentation. Add back zk-websocket-serverpush.xml
This commit is contained in:
parent
4a81373e9d
commit
1080b5a654
|
@ -184,11 +184,27 @@ public class AtmosphereServerPush implements ServerPush {
|
||||||
synchronized (schedules) {
|
synchronized (schedules) {
|
||||||
schedules.add(new Schedule(task, event, scheduler));
|
schedules.add(new Schedule(task, event, scheduler));
|
||||||
}
|
}
|
||||||
|
boolean ok = false;
|
||||||
try {
|
try {
|
||||||
commitResponse();
|
ok = commitResponse();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
log.error(e.getMessage(), e);
|
log.error(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
if (!ok) {
|
||||||
|
try {
|
||||||
|
Thread.sleep(500);
|
||||||
|
} catch (InterruptedException e1) {}
|
||||||
|
if (schedules.size() > 0) {
|
||||||
|
try {
|
||||||
|
ok = commitResponse();
|
||||||
|
} catch (IOException e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
}
|
||||||
|
if (!ok) {
|
||||||
|
log.warn("Failed to resume long polling resource");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
//in event listener thread, can schedule immediately
|
//in event listener thread, can schedule immediately
|
||||||
scheduler.schedule(task, event);
|
scheduler.schedule(task, event);
|
||||||
|
@ -204,11 +220,16 @@ public class AtmosphereServerPush implements ServerPush {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
log.debug("Starting server push for " + desktop);
|
if (log.isDebugEnabled())
|
||||||
Clients.response("jawwa.atmosphere.serverpush", new AuScript(null, "jawwa.atmosphere.startServerPush('" + desktop.getId() + "', " + timeout
|
log.debug("Starting server push for " + desktop);
|
||||||
+ ");"));
|
startClientPush(desktop);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void startClientPush(Desktop desktop) {
|
||||||
|
Clients.response("jawwa.atmosphere.serverpush", new AuScript(null, "jawwa.atmosphere.startServerPush('" + desktop.getId() + "', " + timeout
|
||||||
|
+ ");"));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void stop() {
|
public void stop() {
|
||||||
Desktop desktop = this.desktop.getAndSet(null);
|
Desktop desktop = this.desktop.getAndSet(null);
|
||||||
|
@ -217,7 +238,8 @@ public class AtmosphereServerPush implements ServerPush {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
log.debug("Stopping server push for " + desktop);
|
if (log.isDebugEnabled())
|
||||||
|
log.debug("Stopping server push for " + desktop);
|
||||||
Clients.response("jawwa.atmosphere.serverpush", new AuScript(null, "jawwa.atmosphere.stopServerPush('" + desktop.getId() + "');"));
|
Clients.response("jawwa.atmosphere.serverpush", new AuScript(null, "jawwa.atmosphere.stopServerPush('" + desktop.getId() + "');"));
|
||||||
try {
|
try {
|
||||||
commitResponse();
|
commitResponse();
|
||||||
|
@ -263,6 +285,11 @@ public class AtmosphereServerPush implements ServerPush {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resume() {
|
public void resume() {
|
||||||
|
if (desktop == null || desktop.get() == null) {
|
||||||
|
throw new IllegalStateException(
|
||||||
|
"ServerPush cannot be resumed without desktop, or has been stopped!call #start(desktop)} instead");
|
||||||
|
}
|
||||||
|
startClientPush(desktop.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
private class Schedule<T extends Event> {
|
private class Schedule<T extends Event> {
|
||||||
|
|
|
@ -64,6 +64,7 @@
|
||||||
|
|
||||||
var jqxhr = $.ajax(this.ajaxOptions);
|
var jqxhr = $.ajax(this.ajaxOptions);
|
||||||
this._req = jqxhr;
|
this._req = jqxhr;
|
||||||
|
zAu.cmd0.echo(this.desktop);
|
||||||
},
|
},
|
||||||
start: function() {
|
start: function() {
|
||||||
this.desktop._serverpush = this;
|
this.desktop._serverpush = this;
|
||||||
|
@ -79,4 +80,4 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
})();
|
})();
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE zk>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
zk.xml Copyright (C) 2006 Potix Corporation. All Rights Reserved.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<zk>
|
||||||
|
<device-config>
|
||||||
|
<device-type>ajax</device-type>
|
||||||
|
<server-push-class>org.idempiere.ui.zk.websocket.WebSocketServerPush</server-push-class>
|
||||||
|
</device-config>
|
||||||
|
</zk>
|
Loading…
Reference in New Issue