init method

void init(
  1. MethodCall call
)

Implementation

void init(MethodCall call) {
  if (pusher != null) {
    pusher!.unbind_all();
    pusher!.disconnect();
  }
  var options = Options();
  if (call.arguments['cluster'] != null) {
    options.cluster = call.arguments['cluster'];
  }
  if (call.arguments['forceTLS'] != null) {
    options.forceTLS = call.arguments['forceTLS'];
  }
  if (call.arguments['pongTimeout'] != null) {
    options.pongTimeout = call.arguments['pongTimeout'];
  }
  if (call.arguments['enableStats'] != null) {
    options.enableStats = call.arguments['enableStats'];
  }
  if (call.arguments['disabledTransports'] != null) {
    options.disabledTransports = call.arguments['disabledTransports'];
  }
  if (call.arguments['enabledTransports'] != null) {
    options.enabledTransports = call.arguments['enabledTransports'];
  }
  if (call.arguments['ignoreNullOrigin'] != null) {
    options.ignoreNullOrigin = call.arguments['ignoreNullOrigin'];
  }
  if (call.arguments['authTransport'] != null) {
    options.authTransport = call.arguments['authTransport'];
  }
  if (call.arguments['authEndpoint'] != null) {
    options.authEndpoint = call.arguments['authEndpoint'];
  }
  if (call.arguments['authParams'] != null) {
    options.auth = call.arguments['authParams'];
  }
  if (call.arguments['logToConsole'] != null) {
    Pusher.logToConsole = call.arguments['logToConsole'];
  }
  if (call.arguments['authorizer'] != null) {
    options.authorizer = js_util.allowInterop(onAuthorizer);
  }
  pusher = Pusher(call.arguments['apiKey'], options);
  pusher!.connection.bind('error', js_util.allowInterop(onError));
  pusher!.connection.bind('message', js_util.allowInterop(onMessage));
  pusher!.connection.bind('state_change', js_util.allowInterop(onStateChange));
  pusher!.connection.bind('connected', js_util.allowInterop(onConnected));
  pusher!.connection.bind('disconnected', js_util.allowInterop(onDisconnected));
}