class AltSocketEndpoint {
  static const defaultHost = String.fromEnvironment(
    'ALT_SOCKET_HOST',
    defaultValue: '127.0.0.1',
  );
  static const defaultPort = int.fromEnvironment(
    'ALT_SOCKET_PORT',
    defaultValue: 8080,
  );
  static const defaultPath = String.fromEnvironment(
    'ALT_SOCKET_PATH',
    defaultValue: '/socket',
  );

  final String host;
  final int port;
  final String path;

  const AltSocketEndpoint({
    this.host = defaultHost,
    this.port = defaultPort,
    this.path = defaultPath,
  });

  @override
  bool operator ==(Object other) =>
      identical(this, other) ||
      other is AltSocketEndpoint &&
          runtimeType == other.runtimeType &&
          host == other.host &&
          port == other.port &&
          path == other.path;

  @override
  int get hashCode => host.hashCode ^ port.hashCode ^ path.hashCode;

  @override
  String toString() => 'ws://$host:$port$path';
}
