refuseBuild method

  1. @protected
void refuseBuild({
  1. required String code,
  2. required String reason,
})

The server refused this build: stop for good.

Latches the reason, frees anyone waiting on the handshake, and closes the transport. From here connect and the reconnect timer are both no-ops, and the status stays ConnectionStatus.unsupported.

Called when the server answers with a terminal error code (see SyncIncompatibility.isTerminalCode), and when the client itself finds the server unusable — a server that speaks another protocol version has no way to say so in a frame this build understands.

Implementation

@protected
void refuseBuild({required String code, required String reason}) {
  _incompatibility ??= SyncIncompatibility(code: code, message: reason);

  handshake.reset();
  // Set the terminal status before tearing the transport down: the teardown
  // would otherwise report a plain disconnect, and the status is sticky from
  // here on.
  updateConnectionStatus(ConnectionStatus.unsupported);
  unawaited(disconnect());
}