*<Null safety>*
void sendMessageWithResponse (Message 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.
Implementation
void sendMessageWithResponse(Message message, Function callback) {
if (!_reader.isBound) {
proxyError('The sender is closed.');
return;
}
const int _kUserspaceTxidMask = 0x7FFFFFFF;
int txid = _nextTxid++ & _kUserspaceTxidMask;
while (txid == 0 || _callbackMap.containsKey(txid))
txid = _nextTxid++ & _kUserspaceTxidMask;
message.txid = txid;
final int status = _reader.channel!.write(message.data, message.handles);
if (status != ZX.OK) {
proxyError(
'Failed to write to channel: ${_reader.channel} (status: $status)');
return;
}
_callbackMap[message.txid] = callback;
_pendingResponsesCount++;
}