sendDatagram method
Send an unreliable datagram for sessionId using the QUIC connection.
Falls back to a DATAGRAM capsule if the underlying transport does not support QUIC datagrams.
Throws StateError if HTTP Datagrams are not enabled by the peer.
Implementation
void sendDatagram(int sessionId, Uint8List data) {
if (!isH3DatagramEnabled) {
throw StateError(
'HTTP Datagrams not enabled: peer did not send SETTINGS_H3_DATAGRAM',
);
}
final quic = _quicConnection as dynamic;
try {
quic.sendDatagram(data);
} catch (_) {
// Fallback: send as DATAGRAM capsule on the session stream.
sendCapsule(sessionId, DatagramCapsule(data));
}
}