Re: [Cppcms-users] JSON-RPC dispatching together with Normal Web Page
Brought to you by:
artyom-beilis
From: Jon F. <jon...@jf...> - 2020-11-08 22:11:53
|
I feel like I'm missing a piece of the picture but I'll give it a go: Typically to mount an application in the URL space you do something like this in the program's main(): cppcms::service srv(argc,argv); srv.applications_pool().mount( cppcms::create_pool<rpc_app_class>(), cppcms::mount_point("/rpc") ); Or you can mount it in another applications URL space with attach() like this inside a cppcms::application constructor: attach( new rpc_app_class(s), "rpc", "/rpc{1}", "/rpc((/.*)?)",1); And technically you can use dispatcher() and mapper() directly to dispatch from one app class to another. Just create the additional app object in the constructor of a parent app object. Then map/dispatch in the traditional way, but supply the child object to dispatcher. Something like this in the parent's (app1) constructor: mapper().assign("rpc", "/rpc"); dispatcher().assign("/rpc", &app2_child::handler, app2); Obviously the app2 object has to be constructed as a member of app1 in the usual manner. And don't forget to make sure the object gets destroyed too. Lastly you can call one app from another through the top most application::main(). You would need to construct the child app yourself, as above. But since main() gets the URL you can customize the URL handling to dispatch the call however you see fit. I'm sure this is "clear as mud". So ask questions and provide more detail and I'll see if I can't lend a hand. - Jon On 11/05/2020 06:00 AM, Varstray Pl wrote: > I am setting up a basic webcomic site which uses a class: > > class webcomic : cppcms::application { /*...*/ }; > > for delivering the webcomic functionality, and a class: > > class json_service : public cppcms::rpc::json_rpc_server { /*...*/ }; > > to deliver additional widget based content in a widgets panel. But now I > can't figure out how to properly dispatch the '/rpc' call that is > supposed to be sent to the rpc server in my overloaded webcomic::main > function. > > The source code for the implementing chat using json-rpc was... somewhat > helpful, but also confusing, as I couldn't see any other class in there > that inherited from cppcms::application. I'm kind of at a loss for how to > do this. > > Please help me. And thank you for your time. > > > > > _______________________________________________ > Cppcms-users mailing list > Cpp...@li... > https://lists.sourceforge.net/lists/listinfo/cppcms-users -- Sent from my Devuan Linux workstation -- https://devuan.org/ "Init Freedom", Yeah! Jon Foster JF Possibilities, Inc. jo...@jf... |