Skip to content

Commit 62b791f

Browse files
authored
Add optional timeout argument to callService (#835)
* Add optional timeout argument to callService * Pass timeout property even if it is undefined
1 parent 3c9dbce commit 62b791f

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/core/Service.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,10 @@ export default class Service extends EventEmitter {
4545
* @param {TRequest} request - The service request to send.
4646
* @param {callServiceCallback} [callback] - Function with the following params:
4747
* @param {callServiceFailedCallback} [failedCallback] - The callback function when the service call failed with params:
48-
*/
49-
callService(request, callback, failedCallback) {
48+
* @param {number} [timeout] - Optional timeout, in seconds, for the service call. A non-positive value means no timeout.
49+
* If not provided, the rosbridge server will use its default value.
50+
*/
51+
callService(request, callback, failedCallback, timeout) {
5052
if (this.isAdvertised) {
5153
return;
5254
}
@@ -71,8 +73,10 @@ export default class Service extends EventEmitter {
7173
id: serviceCallId,
7274
service: this.name,
7375
type: this.serviceType,
74-
args: request
76+
args: request,
77+
timeout: timeout
7578
};
79+
7680
this.ros.callOnConnection(call);
7781
}
7882
/**

0 commit comments

Comments
 (0)