accept method

bool accept(
  1. HubLink link
)

Takes a freshly opened link, challenges it, and waits — briefly — for it to authenticate.

Returns false, having closed link, if the hub is closed or full.

Implementation

bool accept(HubLink link) {
  final refused = refusal;
  if (refused != null) {
    if (_status == HubSessionStatus.open) {
      logger.warning(
        'Hub: refusing connection, at capacity (${limits.maxConnections})',
      );
    }
    unawaited(
      link.close(
        _status == HubSessionStatus.closed
            ? HubCloseCode.sessionClosed
            : HubCloseCode.policyViolation,
        refused,
      ),
    );
    return false;
  }
  _onConnected(link);
  return true;
}