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 Interface (Domain)
abstract class NetworksMessagingRepository {
  /// Initialize with config
  void initialize(SocketConfig config);

  /// Connect to messaging server
  Future<bool> connect(String url, {String? token});

  /// Disconnect from server
  Future<void> disconnect();

  /// Check if connected
  bool get isConnected;

  /// Current connection state
  SocketConnectionState get connectionState;

  /// Send a JSON message
  Future<bool> send(Map<String, dynamic> message);

  /// Send a raw string message
  Future<bool> sendString(String message);

  /// Stream of incoming parsed JSON messages
  Stream<Map<String, dynamic>> get messageStream;

  /// Stream of raw string messages
  Stream<String> get rawMessageStream;

  /// Stream of connection state changes
  Stream<SocketConnectionState> get connectionStateStream;

  /// Stream of errors
  Stream<SocketError> get errorStream;

  /// Called when app enters foreground
  void onEnterForeground();

  /// Called when app enters background
  void onEnterBackground();

  /// Dispose all resources
  Future<void> dispose();
}

