send method

void send(
  1. int connectionId,
  2. NativeOwnedBuffer buffer, {
  3. bool transfer = false,
})

Queue acceptance only. A transferred buffer is consumed on success or native rejection; retained sends preserve the caller's immutable handle.

Implementation

void send(
  int connectionId,
  NativeOwnedBuffer buffer, {
  bool transfer = false,
}) {
  _require();
  RangeError.checkValueInInterval(
    connectionId,
    1,
    0x7fffffff,
    'connectionId',
  );
  buffer._handle.check();
  if (buffer._handle.api._identity != _identity) {
    throw ArgumentError('Buffer belongs to a different native library');
  }
  final submitted = transfer ? buffer : buffer.retain();
  final handle = submitted._handle.consume();
  _check(_send(connectionId, handle));
}