PhoenixSocketOptions constructor

const PhoenixSocketOptions({
  1. Duration? timeout,
  2. Duration? heartbeat,
  3. List<Duration> reconnectDelays = const [Duration.zero, Duration(milliseconds: 1000), Duration(milliseconds: 2000), Duration(milliseconds: 4000), Duration(milliseconds: 8000), Duration(milliseconds: 16000), Duration(milliseconds: 32000)],
  4. Map<String, String>? params,
  5. Future<Map<String, String>> dynamicParams()?,
  6. MessageSerializer? serializer,
})

Create a PhoenixSocketOptions

Implementation

const PhoenixSocketOptions({
  /// The duration after which a connection attempt
  /// is considered failed
  Duration? timeout,

  /// The interval between heartbeat roundtrips
  Duration? heartbeat,

  /// The list of delays between reconnection attempts.
  ///
  /// The last duration will be repeated until it works.
  this.reconnectDelays = const [
    Duration.zero,
    Duration(milliseconds: 1000),
    Duration(milliseconds: 2000),
    Duration(milliseconds: 4000),
    Duration(milliseconds: 8000),
    Duration(milliseconds: 16000),
    Duration(milliseconds: 32000),
  ],

  /// Parameters passed to the connection string as query string.
  ///
  /// Either this or [dynamicParams] can to be provided, but not both.
  this.params,

  /// A function that will be used lazily to retrieve parameters
  /// to pass to the connection string as query string.
  ///
  /// Either this or [params] car to be provided, but not both.
  this.dynamicParams,
  MessageSerializer? serializer,
})  : _timeout = timeout ?? const Duration(seconds: 10),
      serializer = serializer ?? const MessageSerializer(),
      _heartbeat = heartbeat ?? const Duration(seconds: 30),
      assert(!(params != null && dynamicParams != null),
          "Can't set both params and dynamicParams");