import 'dart:typed_data';

import 'package:networks_sdk/src/domain/entities/socket_connection_state.dart';
import 'package:networks_sdk/src/domain/entities/socket_error.dart';
import 'package:networks_sdk/src/presentation/wiring/socket_config.dart';

/// Messaging Repository 接口
abstract class NetworksMessagingRepository {
  void initialize(SocketConfig config);

  Future<bool> connect(String url, {String? token});

  Future<void> disconnect();

  bool get isConnected;

  SocketConnectionState get connectionState;

  /// Token 热更新（不断连）
  void updateToken(String token);

  Future<bool> send(Map<String, dynamic> message);

  Future<bool> sendString(String message);

  /// 发送二进制数据
  Future<bool> sendBytes(List<int> bytes);

  Stream<Map<String, dynamic>> get messageStream;

  Stream<String> get rawMessageStream;

  /// 二进制消息流
  Stream<Uint8List> get binaryMessageStream;

  Stream<SocketConnectionState> get connectionStateStream;

  Stream<SocketError> get errorStream;

  void onEnterForeground();

  void onEnterBackground();

  Future<void> dispose();
}
