11/* eslint-disable camelcase */
2-
3- import { Clock , TypeClassName , MessageTypeClassName } from 'rclnodejs' ;
4- import { Logging } from 'rclnodejs' ;
5- import { Parameter , ParameterDescriptor , ParameterType } from 'rclnodejs' ;
6- import { QoS } from 'rclnodejs' ;
7- import { rcl_interfaces } from 'rclnodejs' ;
8-
92declare module 'rclnodejs' {
103 /**
114 * Identifies type of ROS message such as msg or srv.
@@ -60,71 +53,6 @@ declare module 'rclnodejs' {
6053 */
6154 const DEFAULT_OPTIONS : Options ;
6255
63- /**
64- * A service response to a client request.
65- *
66- * @remarks
67- * You can use {@link response.template | response.template} to get an empty result message.
68- */
69- class ServiceResponse {
70- /**
71- * Get an empty response message object.
72- * The template will be a message of type: <pkg>.srv.<serviceTypeClass>_Response.
73- * e.g., example_interface/srv/AddTwoInts_Response
74- */
75- readonly template : Message ;
76-
77- /**
78- * The service that this response object is attaching to.
79- */
80- readonly service : Service ;
81-
82- /**
83- * Send this response to client (the service caller)
84- *
85- * @param response - Response message.
86- *
87- * @remarks
88- * see {@link Response.template}
89- */
90- send ( response : Message ) : void ;
91- }
92-
93- /**
94- * A callback for receiving published messages.
95- *
96- * @param message - The published message.
97- *
98- * @remarks
99- * See {@link Node#createSubscription | Node.createSubscription}
100- * See {@link Node#createPublisher | Node.createPublisher}
101- * See {@link Publisher}
102- * See {@link Subscription}
103- */
104- type SubscriptionCallback < T extends TypeClass < MessageTypeClassName > > =
105- // * @param message - The published message
106- ( message : MessageType < T > | Buffer ) => void ;
107-
108- /**
109- * Callback for receiving service requests from a client.
110- *
111- * @param request - The request sent to the service
112- * @param response - The response to the client.
113- *
114- * @remarks
115- * Use {@link Response.send | response.send()} to send response object to client
116- *
117- * See {@link Node.createService | Node.createService}
118- * See {@link Client.sendRequest | Client.sendRequest}
119- * See {@link Client}
120- * See {@link Service}
121- * See {@link Response.send | Response.send}
122- */
123- type ServiceRequestCallback = (
124- request : Message ,
125- response : ServiceResponse
126- ) => void ;
127-
12856 /**
12957 * Callback for receiving periodic interrupts from a Timer.
13058 *
@@ -283,7 +211,7 @@ declare module 'rclnodejs' {
283211 topic : string ,
284212 options : Options ,
285213 callback : SubscriptionCallback < T >
286- ) : Subscription ;
214+ ) : Subscription
287215
288216 /**
289217 * Create a Client for making server requests.
@@ -293,11 +221,11 @@ declare module 'rclnodejs' {
293221 * @param options - The options argument used to parameterize the client.
294222 * @returns New instance of Client.
295223 */
296- createClient (
297- typeClass : TypeClass ,
224+ createClient < T extends TypeClass < ServiceTypeClassName > > (
225+ typeClass : T ,
298226 serviceName : string ,
299227 options ?: Options
300- ) : Client ;
228+ ) : Client < T > ;
301229
302230 /**
303231 * Create a Service.
@@ -308,12 +236,12 @@ declare module 'rclnodejs' {
308236 * @param callback - Notified for receiving incoming requests.
309237 * @returns An instance of Service.
310238 */
311- createService (
312- typeClass : TypeClass ,
239+ createService < T extends TypeClass < ServiceTypeClassName > > (
240+ typeClass : T ,
313241 serviceName : string ,
314242 options : Options ,
315- callback : ServiceRequestCallback
316- ) : Service ;
243+ callback : ServiceRequestHandler < T >
244+ ) : ServiceType < T > ;
317245
318246 /**
319247 * Create a guard condition.
@@ -335,7 +263,7 @@ declare module 'rclnodejs' {
335263 *
336264 * @param publisher - Publisher to be destroyed.
337265 */
338- destroyPublisher < T extends MessageTypeClassName > ( publisher : Publisher < T > ) : void ;
266+ destroyPublisher < T extends TypeClass < MessageTypeClassName > > ( publisher : Publisher < T > ) : void ;
339267
340268 /**
341269 * Destroy a Subscription.
@@ -349,7 +277,7 @@ declare module 'rclnodejs' {
349277 *
350278 * @param client - Client to be destroyed.
351279 */
352- destroyClient ( client : Client ) : void ;
280+ destroyClient < T extends TypeClass < ServiceTypeClassName > > ( client : Client < T > ) : void ;
353281
354282 /**
355283 * Destroy a Service.
0 commit comments