@@ -119,6 +119,8 @@ public class SimplePipeRequest extends SimpleRPCRequest {
119119
120120 static Object pipeQueryMap = new Object ();
121121
122+ private static boolean escKeyAbortingDisabled = false ;
123+
122124 public static int getPipeMode () {
123125 return pipeMode ;
124126 }
@@ -271,7 +273,36 @@ public void run() {
271273 thread .start ();
272274 }
273275
276+ /**
277+ * Press <ESC> key in browser will abort comet connection. Here try to
278+ * disable such key being detected by browser.
279+ *
280+ * @j2sNative
281+ Clazz.addEvent (document, "keydown", function (e) {
282+ var ie = false;
283+ if (e == null) {
284+ e = window.event;
285+ ie = true;
286+ }
287+ var key = e.keyCode || e.charCode;
288+ if (key == 27) {
289+ if (ie) {
290+ e.returnValue = false;
291+ } else {
292+ e.preventDefault();
293+ }
294+ return false;
295+ }
296+ });
297+ */
298+ private static void disableESCKeyConnectionAbsorting () {
299+ }
300+
274301 private static void pipeRequest (final SimplePipeRunnable runnable ) {
302+ if (!escKeyAbortingDisabled ) {
303+ escKeyAbortingDisabled = true ;
304+ disableESCKeyConnectionAbsorting ();
305+ }
275306 String url = runnable .getHttpURL ();
276307 String method = runnable .getHttpMethod ();
277308 String serialize = runnable .serialize ();
@@ -708,7 +739,7 @@ public void onLoaded() {
708739 var spr = net.sf.j2s.ajax.SimplePipeRequest;
709740 var now = new Date ().getTime ();
710741 var last = runnable.lastPipeDataReceived;
711- if (last == -1 ) {
742+ if (last <= 0 ) {
712743 last = created;
713744 }
714745 if (now - last > 3 * spr.pipeLiveNotifyInterval) {
@@ -1027,7 +1058,7 @@ public void run() {
10271058 var spr = net.sf.j2s.ajax.SimplePipeRequest;
10281059 var now = new Date ().getTime ();
10291060 var last = runnable.lastPipeDataReceived;
1030- if (last == -1 ) {
1061+ if (last <= 0 ) {
10311062 last = created;
10321063 }
10331064 if ((runnable.queryEnded || (now - last >= spr.pipeLiveNotifyInterval
@@ -1067,7 +1098,7 @@ public void run() {
10671098
10681099 long now = System .currentTimeMillis ();
10691100 long last = runnable .lastPipeDataReceived ;
1070- if (last == - 1 ) {
1101+ if (last <= 0 ) {
10711102 last = created ;
10721103 }
10731104 if (runnable .queryFailedRetries >= 3
@@ -1199,7 +1230,7 @@ public void run() {
11991230};
12001231p.pipeXHRQuery = function (request, method, url, data) {
12011232 if ("GET" == method.toUpperCase ()) {
1202- request.open (method, url + (url.indexOf ('?') != -1 ? "&" : "?") + data, true, null, null);
1233+ request.open (method, url + (data != null ? (( url.indexOf ('?') != -1 ? "&" : "?") + data) : "") , true, null, null);
12031234 data = null;
12041235 } else {
12051236 request.open (method, url, true, null, null);
@@ -1246,7 +1277,7 @@ public void run() {
12461277 }
12471278 var now = new Date ().getTime ();
12481279 var last = runnable.lastPipeDataReceived;
1249- if (last == -1 ) {
1280+ if (last <= 0 ) {
12501281 last = created;
12511282 }
12521283 if ((runnable.queryEnded || (now - last >= p.pipeLiveNotifyInterval
@@ -1269,6 +1300,17 @@ public void run() {
12691300 try {
12701301 document.domain = p.originalDomain;
12711302 } catch (e) {};
1303+ if (data == null) { // make sure that data is not null
1304+ with (window.parent) {
1305+ try {
1306+ method = runnable.getPipeMethod ();
1307+ url = runnable.getPipeURL ();
1308+ var spr = net.sf.j2s.ajax.SimplePipeRequest;
1309+ data = spr.constructRequest(key, spr.PIPE_TYPE_QUERY, true);
1310+ } catch (e) {
1311+ }
1312+ }
1313+ }
12721314 try {
12731315 p.initHttpRequest ();
12741316 } catch (e) {};
0 commit comments