RPC cancellation

5 views
Skip to first unread message

Rosa Lisin

unread,
May 30, 2019, 1:53:25 PM5/30/19
to CppWAMP
Hi Emile,

Could you please provide some guidance on remote procedure call cancellation usage?  How can the following call be cancelled:
auto result= session->call(Rpc("some_long_call"), yield);

It seems that in order to cancel an RPC one needs to know the request Id, but request id seems to be available only when that call returns since it is a member of the Result class.

Thanks a lot,

Rosa Lisin

Emile Cormier

unread,
May 31, 2019, 3:08:04 PM5/31/19
to CppWAMP
Hi Rosa,

You need to use the Session::call overload, which is asynchronous and immediately returns a RequestId: https://github.com/ecorm/cppwamp/blob/310278b74c3413c8cc44c60adc6feb777d651dca/cppwamp/include/cppwamp/session.hpp#L207

CoroSession derives from Session, so you have access to the async API if you need it from a CoroSession instance.

You'll need to provide an asynchronous handler routine, within which you can spawn a new coroutine if needed.


I'm sorry that there's no tutorial example of call cancellation at this point. Hopefully you can figure it out from the unit test example.

Cheers,
Emile

Rosa Lisin

unread,
Jun 3, 2019, 8:07:58 AM6/3/19
to CppWAMP
Thanks, Emille,
I will try to figure it out. 

Best regards,
Rosa
Reply all
Reply to author
Forward
0 new messages