import 'package:equatable/equatable.dart';

class TcpServerState extends Equatable {
  final bool isRunning;
  final int port;
  final int connectedClients;
  final String? error;

  const TcpServerState({
    this.isRunning = false,
    this.port = 0,
    this.connectedClients = 0,
    this.error,
  });

  TcpServerState copyWith({
    bool? isRunning,
    int? port,
    int? connectedClients,
    String? error,
    bool clearError = false,
  }) {
    return TcpServerState(
      isRunning: isRunning ?? this.isRunning,
      port: port ?? this.port,
      connectedClients: connectedClients ?? this.connectedClients,
      error: clearError ? null : (error ?? this.error),
    );
  }

  @override
  List<Object?> get props => [isRunning, port, connectedClients, error];
}
