accept method

Future<NativeSession> accept({
  1. Map<String, String>? headers,
})

Accepts the request, returning the server side of the session.

Implementation

Future<NativeSession> accept({Map<String, String>? headers}) async {
  if (_answered) {
    throw StateError('this session request was already answered');
  }
  _answered = true;
  final nativeHeaders = allocHeaders(headers);
  final Future<NativeEvent> event;
  try {
    event = nativeRuntime.oneShot(
      'wt_session_request_accept',
      (opId) => b.wt_session_request_accept(
        _handle,
        nativeHeaders.pointer,
        nativeHeaders.length,
        opId,
      ),
    );
  } finally {
    nativeHeaders.free();
  }
  final result = await event;
  if (!result.isOk) throw result.exception('accept');
  final session = NativeSession(result.handle.cast());
  session.watchClosed();
  return session;
}