/** * Call the service and wait for a response. This is a blocking call and * will only return once rosbridge returns the service response. For an * asynchronous version of this call, see the * {@link #callService(ServiceRequest request, ServiceCallback cb) * callService} method. * * @param request * The service request to send. * @return The corresponding service response from ROS. */ public synchronized ServiceResponse callServiceAndWait( ServiceRequest request) { // private inner class to use as a callback BlockingCallback cb = new BlockingCallback(this); // use the asynchronous version and block on the result this.callService(request, cb); // wait for a response while (cb.getResponse() == null) { try { this.wait(); } catch (InterruptedException e) { // continue on } } return cb.getResponse(); }
/** * Call the service and wait for a response. This is a blocking call and * will only return once rosbridge returns the service response. For an * asynchronous version of this call, see the * {@link #callService(ServiceRequest request, ServiceCallback cb) * callService} method. * * @param request * The service request to send. * @return The corresponding service response from ROS. */ public synchronized ServiceResponse callServiceAndWait( ServiceRequest request) { // private inner class to use as a callback BlockingCallback cb = new BlockingCallback(this); // use the asynchronous version and block on the result this.callService(request, cb); // wait for a response while (cb.getResponse() == null) { try { this.wait(); } catch (InterruptedException e) { // continue on } } return cb.getResponse(); }