init method
Future<void>
init({
- required String apiKey,
- required String cluster,
- bool? useTLS,
- int? activityTimeout,
- int? pongTimeout,
- int? maxReconnectionAttempts,
- int? maxReconnectGapInSeconds,
- String? proxy,
- bool? enableStats,
- List<
String> ? disabledTransports, - List<
String> ? enabledTransports, - bool? ignoreNullOrigin,
- String? authEndpoint,
- String? authTransport,
- Map<
String, Map< ? authParams,String, String> > - bool? logToConsole,
- dynamic onConnectionStateChange()?,
- dynamic onSubscriptionSucceeded(
- String channelName,
- dynamic data
- dynamic onSubscriptionError(
- String message,
- dynamic error
- dynamic onDecryptionFailure()?,
- dynamic onError()?,
- dynamic onEvent(
- PusherEvent event
- dynamic onMemberAdded(
- String channelName,
- PusherMember member
- dynamic onMemberRemoved(
- String channelName,
- PusherMember member
- dynamic onAuthorizer()?,
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
});
}