@@ -128,13 +128,32 @@ Napi::Value GetSubscriptionCount(const Napi::CallbackInfo& info) {
128128 return Napi::Number::New (env, count);
129129}
130130
131+ Napi::Value WaitForAllAcked (const Napi::CallbackInfo& info) {
132+ Napi::Env env = info.Env ();
133+ rcl_publisher_t * publisher = reinterpret_cast <rcl_publisher_t *>(
134+ RclHandle::Unwrap (info[0 ].As <Napi::Object>())->ptr ());
135+ bool lossless;
136+ int64_t nanoseconds = info[1 ].As <Napi::BigInt>().Int64Value (&lossless);
137+
138+ rcl_ret_t ret = rcl_publisher_wait_for_all_acked (publisher, nanoseconds);
139+ if (RCL_RET_OK == ret) {
140+ return Napi::Boolean::New (env, true );
141+ } else if (RCL_RET_TIMEOUT == ret) {
142+ return Napi::Boolean::New (env, false );
143+ }
144+ Napi::Error::New (env, " Failed to wait for all acknowledgements" )
145+ .ThrowAsJavaScriptException ();
146+ throw env.Undefined ();
147+ }
148+
131149Napi::Object InitPublisherBindings (Napi::Env env, Napi::Object exports) {
132150 exports.Set (" createPublisher" , Napi::Function::New (env, CreatePublisher));
133151 exports.Set (" publish" , Napi::Function::New (env, Publish));
134152 exports.Set (" getPublisherTopic" , Napi::Function::New (env, GetPublisherTopic));
135153 exports.Set (" publishRawMessage" , Napi::Function::New (env, PublishRawMessage));
136154 exports.Set (" getSubscriptionCount" ,
137155 Napi::Function::New (env, GetSubscriptionCount));
156+ exports.Set (" waitForAllAcked" , Napi::Function::New (env, WaitForAllAcked));
138157 return exports;
139158}
140159
0 commit comments