Google is committed to advancing racial equity for Black communities. See how.

sendMessageWithResponse method

*<Null safety>*

void sendMessageWithResponse (OutgoingMessage message, Function callback)

Sends the given messages over the bound channel and registers a callback to handle the response.

Used by subclasses of Proxy<T> to send encoded messages.


void sendMessageWithResponse(OutgoingMessage message, Function callback) {
  if (!_reader.isBound) {
    proxyError('The sender is closed.');

  const int _kUserspaceTxidMask = 0x7FFFFFFF;

  int txid = _nextTxid++ & _kUserspaceTxidMask;
  while (txid == 0 || _callbackMap.containsKey(txid))
    txid = _nextTxid++ & _kUserspaceTxidMask;
  message.txid = txid;
  final int status =!.write(, message.handles);

  if (status != ZX.OK) {
        'Failed to write to channel: ${} (status: $status)');

  _callbackMap[message.txid] = callback;