From 62b791fd78b1793b349bc94813a7f69b006cb971 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C5=82a=C5=BCej=20Sowa?= Date: Thu, 23 Jan 2025 23:42:49 +0100 Subject: [PATCH] Add optional timeout argument to callService (#835) * Add optional timeout argument to callService * Pass timeout property even if it is undefined --- src/core/Service.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/core/Service.js b/src/core/Service.js index dfcdea3b3..9d9984468 100644 --- a/src/core/Service.js +++ b/src/core/Service.js @@ -45,8 +45,10 @@ export default class Service extends EventEmitter { * @param {TRequest} request - The service request to send. * @param {callServiceCallback} [callback] - Function with the following params: * @param {callServiceFailedCallback} [failedCallback] - The callback function when the service call failed with params: - */ - callService(request, callback, failedCallback) { + * @param {number} [timeout] - Optional timeout, in seconds, for the service call. A non-positive value means no timeout. + * If not provided, the rosbridge server will use its default value. + */ + callService(request, callback, failedCallback, timeout) { if (this.isAdvertised) { return; } @@ -71,8 +73,10 @@ export default class Service extends EventEmitter { id: serviceCallId, service: this.name, type: this.serviceType, - args: request + args: request, + timeout: timeout }; + this.ros.callOnConnection(call); } /**