rclnodejs 0.23.3 → 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 CHANGED
@@ -32,8 +32,7 @@ class Publisher extends Entity {
32
32
  * @type {string}
33
33
  */
34
34
  get topic() {
35
- const fullTopic = rclnodejs.getTopic(this._handle); // returns /my_node/mytopic
36
- return fullTopic.split('/').pop();
35
+ return rclnodejs.getPublisherTopic(this._handle);
37
36
  }
38
37
 
39
38
  /**
@@ -70,7 +70,7 @@ class Subscription extends Entity {
70
70
  * @type {string}
71
71
  */
72
72
  get topic() {
73
- return this._topic;
73
+ return rclnodejs.getSubscriptionTopic(this._handle);
74
74
  }
75
75
 
76
76
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rclnodejs",
3
- "version": "0.23.3",
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",
@@ -942,7 +942,7 @@ NAN_METHOD(Publish) {
942
942
  info.GetReturnValue().Set(Nan::Undefined());
943
943
  }
944
944
 
945
- NAN_METHOD(GetTopic) {
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
- {"getTopic", GetTopic},
2052
+ {"getPublisherTopic", GetPublisherTopic},
2053
+ {"getSubscriptionTopic", GetSubscriptionTopic},
2043
2054
  {"createClient", CreateClient},
2044
2055
  {"rclTakeResponse", RclTakeResponse},
2045
2056
  {"sendRequest", SendRequest},