close method
Closes every connection and stops accepting.
Implementation
Future<void> close({int closeCode = 0, String reason = ''}) async {
final bytes = reason.isEmpty ? nullptr : calloc<Uint8>(reason.length);
if (bytes != nullptr) {
bytes.asTypedList(reason.length).setAll(0, reason.codeUnits);
}
try {
final event = await nativeRuntime.oneShot(
'wt_server_close',
(opId) => b.wt_server_close(
_handle,
closeCode,
bytes,
bytes == nullptr ? 0 : reason.length,
opId,
),
);
if (!event.isOk) throw event.exception('close');
} finally {
if (bytes != nullptr) calloc.free(bytes);
}
}