close method
Closes the session.
Implementation
@override
Future<void> close([WebTransportCloseInfo? closeInfo]) async {
if (_disposed) return;
final info = closeInfo ?? const WebTransportCloseInfo();
final reason = info.reason;
final pointer = reason.isEmpty ? nullptr : calloc<Uint8>(reason.length);
if (pointer != nullptr) {
pointer.asTypedList(reason.length).setAll(0, reason.codeUnits);
}
try {
checkStatus(
b.wt_connection_close(
_connection,
info.closeCode,
pointer,
pointer == nullptr ? 0 : reason.length,
),
'wt_connection_close',
);
} finally {
if (pointer != nullptr) calloc.free(pointer);
}
completeClosed();
}