rclnodejs 0.23.2 → 0.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/publisher.js +1 -2
- package/lib/service.js +10 -9
- package/lib/subscription.js +1 -1
- package/package.json +2 -2
- package/src/rcl_bindings.cpp +13 -2
- package/types/interfaces.d.ts +0 -941
package/lib/publisher.js
CHANGED
|
@@ -32,8 +32,7 @@ class Publisher extends Entity {
|
|
|
32
32
|
* @type {string}
|
|
33
33
|
*/
|
|
34
34
|
get topic() {
|
|
35
|
-
|
|
36
|
-
return fullTopic.split('/').pop();
|
|
35
|
+
return rclnodejs.getPublisherTopic(this._handle);
|
|
37
36
|
}
|
|
38
37
|
|
|
39
38
|
/**
|
package/lib/service.js
CHANGED
|
@@ -75,17 +75,18 @@ class Service extends Entity {
|
|
|
75
75
|
|
|
76
76
|
const plainObj = request.toPlainObject(this.typedArrayEnabled);
|
|
77
77
|
const response = new Response(this, headerHandle);
|
|
78
|
-
|
|
78
|
+
Promise.resolve(this._callback(plainObj, response)).then((responseToReturn) => {
|
|
79
79
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
80
|
+
if (!response.sent && responseToReturn) {
|
|
81
|
+
responseToReturn = new this._typeClass.Response(responseToReturn);
|
|
82
|
+
const rawResponse = responseToReturn.serialize();
|
|
83
|
+
rclnodejs.sendResponse(this._handle, rawResponse, headerHandle);
|
|
84
|
+
}
|
|
85
85
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
86
|
+
debug(
|
|
87
|
+
`Service has processed the ${this._serviceName} request and sent the response.`
|
|
88
|
+
);
|
|
89
|
+
});
|
|
89
90
|
}
|
|
90
91
|
|
|
91
92
|
static createService(nodeHandle, serviceName, typeClass, options, callback) {
|
package/lib/subscription.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rclnodejs",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.24.0",
|
|
4
4
|
"description": "ROS2.0 JavaScript client with Node.js",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "types/index.d.ts",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"postinstall": "npm run generate-messages",
|
|
24
24
|
"docs": "cd docs && make",
|
|
25
25
|
"test": "node --expose-gc ./scripts/run_test.js && npm run dtslint",
|
|
26
|
-
"dtslint": "node scripts/generate_tsd.js
|
|
26
|
+
"dtslint": "node scripts/generate_tsd.js",
|
|
27
27
|
"lint": "eslint --max-warnings=0 --ext js,ts index.js types scripts lib example rosidl_gen rosidl_parser test benchmark/rclnodejs && node ./scripts/cpplint.js",
|
|
28
28
|
"format": "clang-format -i -style=file ./src/*.cpp ./src/*.hpp && prettier --write \"{lib,rosidl_gen,rostsd_gen,rosidl_parser,types,example,test,scripts,benchmark}/**/*.{js,md,ts}\" ./*.{js,md,ts}"
|
|
29
29
|
},
|
package/src/rcl_bindings.cpp
CHANGED
|
@@ -942,7 +942,7 @@ NAN_METHOD(Publish) {
|
|
|
942
942
|
info.GetReturnValue().Set(Nan::Undefined());
|
|
943
943
|
}
|
|
944
944
|
|
|
945
|
-
NAN_METHOD(
|
|
945
|
+
NAN_METHOD(GetPublisherTopic) {
|
|
946
946
|
rcl_publisher_t* publisher = reinterpret_cast<rcl_publisher_t*>(
|
|
947
947
|
RclHandle::Unwrap<RclHandle>(
|
|
948
948
|
Nan::To<v8::Object>(info[0]).ToLocalChecked())
|
|
@@ -952,6 +952,16 @@ NAN_METHOD(GetTopic) {
|
|
|
952
952
|
info.GetReturnValue().Set(Nan::New(topic).ToLocalChecked());
|
|
953
953
|
}
|
|
954
954
|
|
|
955
|
+
NAN_METHOD(GetSubscriptionTopic) {
|
|
956
|
+
rcl_subscription_t* subscription = reinterpret_cast<rcl_subscription_t*>(
|
|
957
|
+
RclHandle::Unwrap<RclHandle>(
|
|
958
|
+
Nan::To<v8::Object>(info[0]).ToLocalChecked())
|
|
959
|
+
->ptr());
|
|
960
|
+
|
|
961
|
+
const char* topic = rcl_subscription_get_topic_name(subscription);
|
|
962
|
+
info.GetReturnValue().Set(Nan::New(topic).ToLocalChecked());
|
|
963
|
+
}
|
|
964
|
+
|
|
955
965
|
NAN_METHOD(CreateClient) {
|
|
956
966
|
v8::Local<v8::Context> currentContent = Nan::GetCurrentContext();
|
|
957
967
|
RclHandle* node_handle = RclHandle::Unwrap<RclHandle>(
|
|
@@ -2039,7 +2049,8 @@ std::vector<BindingMethod> binding_methods = {
|
|
|
2039
2049
|
{"clearContentFilter", ClearContentFilter},
|
|
2040
2050
|
{"createPublisher", CreatePublisher},
|
|
2041
2051
|
{"publish", Publish},
|
|
2042
|
-
{"
|
|
2052
|
+
{"getPublisherTopic", GetPublisherTopic},
|
|
2053
|
+
{"getSubscriptionTopic", GetSubscriptionTopic},
|
|
2043
2054
|
{"createClient", CreateClient},
|
|
2044
2055
|
{"rclTakeResponse", RclTakeResponse},
|
|
2045
2056
|
{"sendRequest", SendRequest},
|