ServerpodClientShared constructor

ServerpodClientShared(
  1. String host,
  2. SerializationManager serializationManager, {
  3. dynamic securityContext,
  4. required AuthenticationKeyManager? authenticationKeyManager,
  5. required Duration? streamingConnectionTimeout,
  6. required Duration? connectionTimeout,
  7. void onFailedCall(
    1. MethodCallContext callContext,
    2. Object error,
    3. StackTrace stackTrace
    )?,
  8. void onSucceededCall(
    1. MethodCallContext callContext
    )?,
  9. bool? disconnectStreamsOnLostInternetConnection,
})

Creates a new ServerpodClientShared.

Implementation

ServerpodClientShared(
  this.host,
  this.serializationManager, {
  dynamic securityContext,
  required this.authenticationKeyManager,
  required Duration? streamingConnectionTimeout,
  required Duration? connectionTimeout,
  this.onFailedCall,
  this.onSucceededCall,
  bool? disconnectStreamsOnLostInternetConnection,
})  : connectionTimeout = connectionTimeout ?? const Duration(seconds: 20),
      streamingConnectionTimeout =
          streamingConnectionTimeout ?? const Duration(seconds: 5) {
  assert(host.endsWith('/'),
      'host must end with a slash, eg: https://example.com/');
  assert(host.startsWith('http://') || host.startsWith('https://'),
      'host must include protocol, eg: https://example.com/');
  _requestDelegate = ServerpodClientRequestDelegateImpl(
    connectionTimeout: this.connectionTimeout,
    serializationManager: serializationManager,
    securityContext: securityContext,
  );
  disconnectStreamsOnLostInternetConnection ??= false;
  _disconnectMethodStreamsOnLostInternetConnection =
      disconnectStreamsOnLostInternetConnection;
  _disconnectWebSocketStreamOnLostInternetConnection =
      disconnectStreamsOnLostInternetConnection;
}