onStateChanged method

  1. @override
void onStateChanged(
  1. WsConnectionState state, {
  2. String? url,
  3. Object? raw,
})
override

Records a connection-state transition. raw is the client's own state object, retained as a stringified hint when present.

Implementation

@override
void onStateChanged(WsConnectionState state, {String? url, Object? raw}) {
  if (!settings.enabled) return;

  final useRedaction = settings.enableRedaction;
  final normalizedUrl = _normalizeUrl(url, useRedaction).url;

  _logger.wsState(
    source: source,
    state: state.name,
    target: normalizedUrl,
    correlationId: _connectionId,
    config: useRedaction ? null : NetworkRedactionMixin.noRedactConfig,
    consoleMessage: '→ state:${state.name} $normalizedUrl',
    meta: {
      'url': normalizedUrl,
      if (raw != null) 'raw': '$raw',
    },
  );
}