hijack method
Takes control of the underlying request socket.
Synchronously, this throws a HijackException
that indicates to the
adapter that it shouldn't emit a response itself. Asynchronously,
callback
is called with a StreamChannel<List<int>>
that provides
access to the underlying request socket.
This may only be called when using a Shelf adapter that supports
hijacking, such as the dart:io
adapter. In addition, a given request may
only be hijacked once. canHijack can be used to detect whether this
request can be hijacked.
Implementation
Never hijack(void Function(StreamChannel<List<int>>) callback) {
if (_onHijack == null) {
throw StateError("This request can't be hijacked.");
}
_onHijack.run(callback);
throw const HijackException();
}