import 'package:fis_common/logger/logger.dart';
import 'package:fis_jsonrpc/rpc.dart';
import 'package:flyinsono/rpc.dart';

import 'heartbeat.dart';

/// 登录心跳
class LoginHeartbeat extends Heartbeat {
  LoginHeartbeat({
    required this.token,
    required int interval,
  }) : super(interval);

  /// 登录令牌
  final String token;

  @override
  void sendOnce() async {
    try {
      final result = await rpc.user.heartRateAsync(TokenRequest(token: token));
      logger.i("[Heartbeat] Send Login heartbeat, result: $result.");
    } catch (e) {
      logger.e('[Heartbeat] Send Login heartbeat error', e);
    }
  }
}
