From aa90c7a15e908cf58458c5a697bba718bdec562b Mon Sep 17 00:00:00 2001 From: Mark Asdoorian Date: Wed, 20 Nov 2024 12:30:46 -0500 Subject: [PATCH] fix: Service types --- index.d.ts | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/index.d.ts b/index.d.ts index 8aa49e6..dc6c4df 100644 --- a/index.d.ts +++ b/index.d.ts @@ -404,15 +404,21 @@ export = ROSLIB; // getter public serviceType: string; + /** + * @callback callServiceCallback + * @param {TResponse} response - The response from the service request. + */ + /** + * @callback callServiceFailedCallback + * @param {string} error - The error message reported by ROS. + */ /** * Call the service. Returns the service response in the * callback. Does nothing if this service is currently advertised. * * @param {TServiceRequest} request - The ROSLIB.ServiceRequest to send. - * @param {function} callback - Function with the following params: - * @param {TServiceResponse} callback.response - The response from the service request. - * @param {function} [failedCallback] - The callback function when the service call failed with params: - * @param {string} failedCallback.error - The error message reported by ROS. + * @param {callServiceCallback} [callback] - Function with the following params: + * @param {callServiceFailedCallback} [failedCallback] - The callback function when the service call failed with params: */ callService( request: TServiceRequest, @@ -420,18 +426,20 @@ export = ROSLIB; failedCallback?: (error: string) => void, ): void; + /** + * @callback advertiseCallback + * @param {TRequest} request - The service request. + * @param {Partial} response - An empty dictionary. Take care not to overwrite this. Instead, only modify the values within. + * @returns {boolean} true if the service has finished successfully, i.e., without any fatal errors. + */ /** * Advertise the service. This turns the Service object from a client * into a server. The callback will be called with every request * that's made on this service. * - * @param {function} callback - This works similarly to the callback for a C++ service and should take the following params: - * @param {TServiceRequest} callback.request - The service request. - * @param {TServiceResponse} callback.response - An empty dictionary. Take care not to overwrite this. Instead, only modify the values within. - * It should return true if the service has finished successfully, - * i.e., without any fatal errors. + * @param {advertiseCallback} [callback] - This works similarly to the callback for a C++ service and should take the following params: */ - advertise(callback: (request: TServiceRequest, response: TServiceResponse) => void): void; + advertise(callback: (request: TServiceRequest, response: Partial) => boolean): void; /** * Unadvertise a previously advertised service.