44 Napi::Env env =
info.Env();
47 throw Napi::Error::New(env,
"Client is not connected");
51 if (
info.Length() < 1 || !
info[0].IsBuffer()) {
52 throw Napi::TypeError::New(env,
"First argument must be a Buffer");
55 auto input_buffer =
info[0].As<Napi::Buffer<uint8_t>>();
56 const uint8_t* input_data = input_buffer.Data();
57 size_t input_len = input_buffer.Length();
62 constexpr uint64_t TIMEOUT_NS = 1000000000;
63 while (!
client_->send(input_data, input_len, TIMEOUT_NS)) {
70 while ((response =
client_->receive(TIMEOUT_NS)).empty()) {
75 auto js_buffer = Napi::Buffer<uint8_t>::Copy(env, response.data(), response.size());
78 client_->release(response.size());