init method

Future<void> init({
  1. required String apiKey,
  2. required String cluster,
  3. bool? useTLS,
  4. int? activityTimeout,
  5. int? pongTimeout,
  6. int? maxReconnectionAttempts,
  7. int? maxReconnectGapInSeconds,
  8. String? proxy,
  9. bool? enableStats,
  10. List<String>? disabledTransports,
  11. List<String>? enabledTransports,
  12. bool? ignoreNullOrigin,
  13. String? authEndpoint,
  14. String? authTransport,
  15. Map<String, Map<String, String>>? authParams,
  16. bool? logToConsole,
  17. dynamic onConnectionStateChange(
    1. String currentState,
    2. String previousState
    )?,
  18. dynamic onSubscriptionSucceeded(
    1. String channelName,
    2. dynamic data
    )?,
  19. dynamic onSubscriptionError(
    1. String message,
    2. dynamic error
    )?,
  20. dynamic onDecryptionFailure(
    1. String event,
    2. String reason
    )?,
  21. dynamic onError(
    1. String message,
    2. int? code,
    3. dynamic error
    )?,
  22. dynamic onEvent(
    1. PusherEvent event
    )?,
  23. dynamic onMemberAdded(
    1. String channelName,
    2. PusherMember member
    )?,
  24. dynamic onMemberRemoved(
    1. String channelName,
    2. PusherMember member
    )?,
  25. dynamic onAuthorizer(
    1. String channelName,
    2. String socketId,
    3. dynamic options
    )?,
})

Implementation

Future<void> init({
  required String apiKey,
  required String cluster,
  bool? useTLS,
  int? activityTimeout,
  int? pongTimeout,
  int? maxReconnectionAttempts,
  int? maxReconnectGapInSeconds,
  String? proxy, // pusher-websocket-java only
  bool? enableStats, // pusher-js only
  List<String>? disabledTransports, // pusher-js only
  List<String>? enabledTransports, // pusher-js only
  bool? ignoreNullOrigin, // pusher-js only
  String? authEndpoint, // pusher-js only
  String? authTransport, // pusher-js only
  Map<String, Map<String, String>>? authParams, // pusher-js only
  bool? logToConsole, // pusher-js only
  Function(String currentState, String previousState)?
      onConnectionStateChange,
  Function(String channelName, dynamic data)? onSubscriptionSucceeded,
  Function(String message, dynamic error)? onSubscriptionError,
  Function(String event, String reason)? onDecryptionFailure,
  Function(String message, int? code, dynamic error)? onError,
  Function(PusherEvent event)? onEvent,
  Function(String channelName, PusherMember member)? onMemberAdded,
  Function(String channelName, PusherMember member)? onMemberRemoved,
  Function(String channelName, String socketId, dynamic options)?
      onAuthorizer,
}) async {
  methodChannel.setMethodCallHandler(_platformCallHandler);
  this.onConnectionStateChange = onConnectionStateChange;
  this.onError = onError;
  this.onSubscriptionSucceeded = onSubscriptionSucceeded;
  this.onEvent = onEvent;
  this.onSubscriptionError = onSubscriptionError;
  this.onDecryptionFailure = onDecryptionFailure;
  this.onMemberAdded = onMemberAdded;
  this.onMemberRemoved = onMemberRemoved;
  this.onAuthorizer = onAuthorizer;
  await methodChannel.invokeMethod('init', {
    "apiKey": apiKey,
    "cluster": cluster,
    "useTLS": useTLS,
    "activityTimeout": activityTimeout,
    "pongTimeout": pongTimeout,
    "maxReconnectionAttempts": maxReconnectionAttempts,
    "maxReconnectGapInSeconds": maxReconnectGapInSeconds,
    "authorizer": onAuthorizer != null ? true : null,
    "proxy": proxy,
    "enableStats": enableStats,
    "disabledTransports": disabledTransports,
    "enabledTransports": enabledTransports,
    "ignoreNullOrigin": ignoreNullOrigin,
    "authEndpoint": authEndpoint,
    "authTransport": authTransport,
    "authParams": authParams,
    "logToConsole": logToConsole
  });
}