HowTo cancel a RPC call?

44 views
Skip to first unread message

alex.d

unread,
Feb 26, 2009, 11:56:07 AM2/26/09
to Google Web Toolkit
Hi folks,

Recently i've found myself in a situation where i have to cancel a RPC
call. I've found out that RequestBuilder.send() method returns a
Request object that provides a cancel() method. But is it possible to
get Request object without using RequestBuilder? I'm currently very
comfortable with RPC (except for the above matter) and i'm reluctant
to switch to RequestBuilder.

Thx in advance for your help

Ian Petersen

unread,
Feb 26, 2009, 12:11:45 PM2/26/09
to Google-We...@googlegroups.com

There's a way to get your async methods to return an object that you
can use to cancel an in-flight RPC. I can never remember the name of
the type, but you just change your async method to return
RequestBuilder (I think) instead of void. It leaves the invocation of
send() up to you, but the request is pre-built so it's not much extra
work, and it gives you the opportunity to play with headers and invoke
cancel(). If you search the history of this list, you might find a
definitive answer on the type you need and, if not, try the history of
the contributor's list.

Ian

Jason Essington

unread,
Feb 26, 2009, 12:12:16 PM2/26/09
to Google-We...@googlegroups.com
sure, just return Request (or RequestBuilder, your option) from your
async interface rather than void, and you are good to go.

-jason

Jason Essington

unread,
Feb 26, 2009, 1:48:09 PM2/26/09
to Google-We...@googlegroups.com
right, return RequestBuilder and you have to handle the sending of the
RPC yourself, but it does allow you to muck about with headers and such.
Return Request and you don't get the opportunity to molest the request
before it is sent, but you also don't have to manually send it either.

Either way, you are given the ability to call cancel() on an active
request. all depends upon what your needs are.

-jason

alex.d

unread,
Feb 27, 2009, 3:31:35 AM2/27/09
to Google Web Toolkit
Exactly what i was looking for. Thx guys.
Another thing: i've tried this in FF with Firebug. What i can see is
that when i cancel the request, firebug still shows it as "waiting for
response". But though i had no problem with starting 10 of them
simultaneously which shouldn't be possible because of the limit of
concurrent XMLHttpRequests in browser, that's probably just a Firebug
bug.

Thx again

Arthur Kalmenson

unread,
Feb 27, 2009, 9:07:56 AM2/27/09
to Google-We...@googlegroups.com
Depends on the browser you're using, but if Firebug shows that it's
waiting for 10 requests, that's probably a bug.

--
Arthur Kalmenson
Reply all
Reply to author
Forward
0 new messages