From: Campbell H. <Cam...@ex...> - 2013-10-23 13:03:46
|
Hi, some advice required on how-to setup for exporting methods AND calling remote methods. We have two modules, a network ping monitor (this application) and a PDU power monitor (remote). Despite many variants on the theme, I cannot get this application to both advertise and utilize simultaneously. We started with the example code from 'echo-server/-client' as a base, and can configure for client OR server successfully. Of course, we have tried... A single DBus::Connection object; which, we thought should be OK and A non-thread version of the client code, that simply calls the required method on the client object? The remote object is a python application using twisted, txdbus. If this code is modified as server only, the remote can query this server OK, and if this is configured as client only then it can query the remote code OK. // initialise our DBus connection DBus::_init_threading(); DBus::default_dispatcher = &dispatcher; // increase DBus-C++ frequency new DBus::DefaultTimeout(100, false, &dispatcher); // setup our DBus server DBus::Connection serverconn = DBus::Connection::SystemBus(); serverconn.request_name(PINGD_SERVER_NAME); pingdDBServer server(serverconn); // setup our DBus client(s) DBus::Connection powerclientconn = DBus::Connection::SystemBus(); powerProxy powerClient(powerclientconn,POWER_SERVER_PATH,POWER_SERVER_NAME); g_client = &powerClient; pthread_t threads[THREADS]; thread_pipe_list[0] = dispatcher.add_pipe(handler1, NULL); pthread_create(&threads[0], NULL, greeter_thread, (void *)0); pthread_join(threads[0], NULL); // enter DBus event loop dispatcher.enter(); printf("\ndispatcher run thread exited"); dispatcher.del_pipe(thread_pipe_list[0]); I can of course supply other sections of code, to a point, but don't know where to start with that at this time so believe this is the crux of it! Best regards |