Core constructor

Core(
  1. ResolvedOptions opts,
  2. DRPlatform platform, {
  3. required String deviceId,
  4. required DeviceInfo deviceInfo,
})

Implementation

Core(this.opts, this.platform, {required this.deviceId, required this.deviceInfo}) {
  log = Logger(opts.log, platform.clock.now);
  kv = KvStore(platform.secureStore, SecureKeys.prefix);
  sessionStore = SessionStore(kv, opts.appKey);
  auth = AuthManager(
    platform,
    AuthOptions(
      appKey: opts.appKey,
      platformName: platform.platformName,
      deviceName: truncateChars(opts.deviceName ?? deviceInfo.deviceName, 64),
      sdkVersion: sdkVersion,
      deviceId: deviceId,
      ticketProvider: opts.ticketProvider,
    ),
    sessionStore,
    kv,
    this,
    log.child('auth'),
  );
  http = ApiClient(platform, opts.apiUrl, auth, log.child('http'), (record) {
    _failures.add(record);
    if (_failures.length > 20) _failures.removeRange(0, _failures.length - 20);
  });
  auth.attachHttp(http);
  conn = ConnectionManager(platform, opts.wsUrl, this, log.child('connection'), mobile: platform.platformName == 'ios' || platform.platformName == 'android');
  store = LocalStore(platform, opts.appKey, kv, this, log.child('store'), encrypt: opts.encryptDatabase);
  sync = SyncEngine(platform, routeNotification, this, log.child('sync'));
}