doClose method

  1. @override
void doClose([
  1. dynamic fn()?
])
override

Closes the transport.

Implementation

@override
void doClose([dynamic Function()? fn]) {
  var self = this;
  Timer? closeTimeoutTimer;

  if (dataReq != null) {
    dataReq = null;
  }

  onClose() {
    if (closeTimeoutTimer != null) closeTimeoutTimer.cancel();
    if (fn != null) fn();
    self.onClose();
  }

  if (writable == true) {
    send([
      {'type': 'close'}
    ]);
    onClose();
  } else if (discarded) {
    onClose();
  } else {
    shouldClose = onClose;
    closeTimeoutTimer = Timer(Duration(milliseconds: closeTimeout), onClose);
  }
}