3 <meta http-equiv=
"Content-Type" content=
"text/html; charset=utf-8" />
4 <title>qooxdoo
» Demo
</title>
5 <link type=
"text/css" rel=
"stylesheet" href=
"../../resource/css/layout.css"/>
7 <link type="text/css" rel="stylesheet" href="../../resource/css/layout_ie.css"/>
9 <script type=
"text/javascript" src=
"../../script/qx.js"></script>
10 <script type=
"text/javascript" src=
".qxrpc"></script>
11 <!-- With the above script, the service URL for a J2EE application can be
12 automatically determined, no matter on what path it's deployed. -->
15 <script type=
"text/javascript" src=
"../../script/layout.js"></script>
17 <div id=
"demoDescription">
18 <p>Test for RPC functionality.
</p>
20 This tests the ability to issue multiple asynchronous RPC calls to the
21 same service/method, and determine from which request we have received a
22 response. We issue multiple 'sleep' calls, for decreasing amounts of
23 time, and ensure that we can associate the resonses from the
24 later-issued requests to the earlier-received responses.
28 <script type=
"text/javascript">
29 // qx.Settings.setCustomOfClass("qx.io.remote.RemoteExchange", "enableDebug", true);
30 qx
.Settings
.setCustomOfClass("qx.io.Json", "enableDebug", true);
32 qx
.core
.Init
.getInstance().defineMain(function() {
33 var layout1
= new qx
.ui
.layout
.VerticalBoxLayout();
36 layout1
.setSpacing(4);
39 * Sigh. Both IE and Firefox follow (too strictly) RFC2616 and limit
40 * the number of simultaneous asyncronous HTTP requests to 2. We'll
41 * allow testing just 2 simultaneous requests or issuing 6 simultaneous
42 * requests. In the former case, we'll get expected results. In the
43 * latter, we'll see two at a time being processed.
45 * Note that this applies to both XmlHTTPTransport and IframeTransport.
46 * It is an HTTP limitation, not a limitation of a particular method of
49 var tooMany
= new qx
.ui
.form
.CheckBox("Issue more requests than IE's and Firefox's implementations of HTTP will process simultaneously");
52 var crossDomain
= new qx
.ui
.form
.CheckBox("Cross Domain");
53 layout1
.add(crossDomain
);
55 layout1
.add(new qx
.ui
.basic
.Label("URL:"));
56 var defaultURL
= qx
.io
.remote
.Rpc
.makeServerURL();
57 if (defaultURL
== null) {
58 defaultURL
= "/services/";
60 var url
= new qx
.ui
.form
.TextField(defaultURL
);
63 layout1
.add(new qx
.ui
.basic
.Label("Service:"));
64 var service
= new qx
.ui
.form
.TextField("qooxdoo.test");
67 var layout2
= new qx
.ui
.layout
.HorizontalBoxLayout();
68 layout2
.setHeight("auto");
69 layout2
.setVerticalChildrenAlign("middle");
70 layout2
.setSpacing(4);
71 var start
= new qx
.ui
.form
.Button("Start Test");
73 var abort
= new qx
.ui
.form
.Button("Abort");
77 // ensure there's room in the queue for all of our requests
78 qx
.io
.remote
.RemoteRequestQueue
.getInstance().setMaxConcurrentRequests(8);
80 // We'll be setting url and service upon execute; no need to do it now.
81 var rpc
= new qx
.io
.remote
.Rpc();
82 rpc
.setTimeout(60000);
86 start
.addEventListener("execute", function() {
87 t0
= new Date().getTime();
89 rpc
.setCrossDomain(crossDomain
.isChecked());
91 rpc
.setUrl(url
.getValue());
92 rpc
.setServiceName(service
.getValue());
95 for (i
=(tooMany
.isChecked() ? 30 : 10); i
> 0; i
-=5) {
97 * Always issue an asynchronous request! Issuing a synchronous
98 * request can lock up the entire browser until a response is
99 * received. Bad browser developers! Bad!
101 mycall
= rpc
.callAsync(function(result
, ex
, seqnum
) {
102 mycalls
[seqnum
] = null;
103 t
= new Date().getTime() - t0
;
105 layout1
.warn(t
+ ": response " + seqnum
+ ": " + result
);
107 layout1
.warn(t
+ ": exception " + seqnum
+ ": " + ex
);
109 }, "sleep", i
.toString()); // FIXME: Why is this sent as a string?
111 t
= new Date().getTime() - t0
;
112 seqnum
= mycall
.getSequenceNumber();
113 mycalls
[seqnum
] = mycall
;
114 layout1
.warn(t
+ ": request " + seqnum
+ " = " + i
.toString());
118 abort
.addEventListener("execute", function() {
119 for (seqnum
in mycalls
) {
120 if (mycalls
[seqnum
] !== null) {
121 rpc
.abort(mycalls
[seqnum
]);
122 mycalls
[seqnum
] = null;
128 var d
= qx
.ui
.core
.ClientDocument
.getInstance();