close method Null safety

void close()

Close this channel.

As a side effect, this method also remove this channel from the encompassing PhoenixSocket.

Implementation

void close() {
  if (_state == PhoenixChannelState.closed) {
    return;
  }
  _state = PhoenixChannelState.closed;

  for (final push in pushBuffer) {
    push.cancelTimeout();
  }
  for (final sub in _subscriptions) {
    sub.cancel();
  }

  _joinPush.cancelTimeout();

  _controller.close();
  _waiters.clear();
  socket.removeChannel(this);
}