@@ -27,7 +27,8 @@ function Service(options) {
2727}
2828Service . prototype . __proto__ = EventEmitter2 . prototype ;
2929/**
30- * Calls the service. Returns the service response in the callback.
30+ * Calls the service. Returns the service response in the
31+ * callback. Does nothing if this service is currently advertised.
3132 *
3233 * @param request - the ROSLIB.ServiceRequest to send
3334 * @param callback - function with params:
@@ -64,11 +65,15 @@ Service.prototype.callService = function(request, callback, failedCallback) {
6465} ;
6566
6667/**
67- * Every time a message is published for the given topic, the callback
68- * will be called with the message object.
68+ * Advertise the service. This turns the Service object from a client
69+ * into a server. The callback will be called with every request
70+ * that's made on this service.
6971 *
70- * @param callback - function with the following params:
71- * * message - the published message
72+ * @param callback - This works similarly to the callback for a C++ service and should take the following params:
73+ * * request - the service request
74+ * * response - an empty dictionary. Take care not to overwrite this. Instead, only modify the values within.
75+ * It should return true if the service has finished successfully,
76+ * i.e. without any fatal errors.
7277 */
7378Service . prototype . advertise = function ( callback ) {
7479 if ( this . isAdvertised || typeof callback !== 'function' ) {
@@ -114,4 +119,4 @@ Service.prototype._serviceResponse = function(rosbridgeRequest) {
114119 this . ros . callOnConnection ( call ) ;
115120} ;
116121
117- module . exports = Service ;
122+ module . exports = Service ;
0 commit comments