40 Napi::Env env =
info.Env();
43 throw Napi::Error::New(env,
"Client is not connected");
47 if (
info.Length() < 1 || !
info[0].IsBuffer()) {
48 throw Napi::TypeError::New(env,
"First argument must be a Buffer");
51 auto input_buffer =
info[0].As<Napi::Buffer<uint8_t>>();
52 const uint8_t* input_data = input_buffer.Data();
53 size_t input_len = input_buffer.Length();
58 constexpr uint64_t TIMEOUT_NS = 1000000000;
59 while (!
client_->send(input_data, input_len, TIMEOUT_NS)) {
66 while ((response =
client_->receive(TIMEOUT_NS)).empty()) {
71 auto js_buffer = Napi::Buffer<uint8_t>::Copy(env, response.data(), response.size());
74 client_->release(response.size());