Albion Data Client

repository·master·Indexed 41 days ago

https://github.com/ao-data/albiondata-client

A distributed client that monitors local network traffic for Albion Online UDP packets and forwards the extracted data to a central NATS server. It includes a GUI dashboard built with Wails, Go, and Svelte, and provides a Go library (`albiondata-client/lib`) containing structs for processing and validating the project's JSON uploads.

Tokens
16.4K
Snippets
55
Records
90
Agent score
49%

What's inside Albion Data Client

  1. Overview of Albion Data - Client

    master
    The Albion Data - Client is a distributed client for the Albion Online Data project. It works by monitoring local network traffic to identify UDP packets containing relevant Albion Online data. Once identified, the client ships this information to a central NATS server, which can be subscribed to by other services.
  2. Use albiondata-client/lib structs for JSON uploads

    master
    The albiondata-client/lib package provides the necessary Go structs required to process and work with JSON uploads generated by the Albion Data client. Use these structs to deserialize or validate the JSON data format used by the project.
  3. Dashboard UI Components

    master

    The Svelte-based dashboard is organized into three main sections:

    • Header: Displays connection status (capturing/idle), the detected server, the client version, and an update-available badge.
    • Counters Panel: Shows live tallies for various upload types.
    • Log Tail: A scrolling, color-coded list of recent log lines. It features auto-scroll functionality that pauses if the user manually scrolls up to inspect previous lines.
  4. Dashboard behavior at launch

    master

    The Wails v3 dashboard app is designed to open automatically upon launch. To prevent an initial-paint flash on Windows, the window is initialized with Hidden: true and only becomes visible and focused once the ApplicationStarted event fires. This ensures the window is fully realized before being shown.

    On macOS, the app uses ActivationPolicyAccessory, so the dashboard explicitly calls Focus() after becoming visible to ensure it appears in front of other active applications.

  5. How dashboard activity heartbeat and staleness work

    master

    The dashboard uses an activity heartbeat to track whether the client is actively capturing data. Instead of relying on the network watcher's liveness, the system now uses RecordActivity() to mark successful packet decoding.

    When RecordActivity() is called, CaptureRunning is set to true. A background goroutine (the staleness ticker) periodically checks the time since the last activity. If the time elapsed exceeds CaptureStaleAfter, CaptureRunning is set to false.

    Key configuration variables (overridable in tests):

    • CaptureStaleAfter: Duration of inactivity before the status becomes stale (default 30s).
    • StaleCheckInterval: Frequency of the staleness check (default 5s).
    // Example of how activity is recorded during packet decoding
    if err == nil {
        dashboard.RecordActivity()
    }
  6. How the self-update mechanism works

    master

    The albiondata-client uses the startUpdater() function (defined in albiondata-client.go) to poll for updates hourly via github.com/ao-data/go-githubupdate.

    Important constraints:

    • Dev builds do not update: The updater only runs if the version string is not empty and does not contain the substring dev. Dev builds (the default when using scripts/run.sh or buildall_main.sh) will never check for updates.
    • In-place replacement: The updater replaces the running binary in place as a single file, not as a bundle.
  7. Understand the Dashboard Capturing Status behavior

    master

    The dashboard's capturing status badge reflects real-time game traffic rather than just the liveness of the client process.

    • Ready (Light Blue): The initial state when the client is running but no game traffic is being decoded.
    • Capturing (Green): Triggered immediately when a successfully decoded Photon message (OperationRequest, OperationResponse, or EventData) is detected.
    • Error (Red): Triggered if packet capture stops due to a fatal error (via Status.CaptureError).
    • Timeout: If no activity is detected for 30 seconds, the status automatically reverts from 'Capturing' to 'Ready'.
  8. Implementation Plan: Dashboard Auto-Open and Windows Console Management

    master

    This plan outlines the implementation of automatic dashboard launching and Windows console visibility management.

    Goals

    • Automatically open and focus the dashboard window at launch.
    • Hide the Windows console by default when the application is launched without arguments.
    • Provide a system tray toggle to show/hide the console on Windows.

    Architecture & Behavior

    • Console Management: A new internal/console package wraps WinAPI calls to hide/show the process's console window. This package uses build-tag-splitting to provide no-op stubs on non-Windows platforms, allowing callers to use it without manual runtime.GOOS checks.
    • Dashboard Auto-Open: Uses the showDashboardWindow() helper. This is preferred over the Wails Hidden option because showDashboardWindow() uses InvokeSync(w.Run) to force synchronous window realization, preventing race conditions during the Wails startup sequence.
    • Windows-Only Features: Console hiding and the tray toggle are exclusive to Windows. The tray toggle is gated by console.Supported(), which returns true only on Windows.
    • Launch Logic: Console hiding only triggers if the application is launched with no arguments (len(os.Args) == 1). This ensures that command-line flags (e.g., -version, -h) remain visible in the console.
  9. Windows console visibility and tray control

    master

    On Windows, the application manages the visibility of the console window to provide a cleaner user experience.

    Default Behavior

    • No-argument launch: If the application is launched without any command-line arguments (e.g., via a desktop shortcut) and it owns its own console, the console window is hidden immediately at startup to prevent flashing.
    • Argument-based launch: If the application is launched with any arguments (such as -version, -h, or -debug), the console remains visible so that flag output is readable.

    Tray Menu Toggle

    When running on Windows, a toggle item is added to the system tray menu. This item allows users to manually show or hide the console window. The menu item label dynamically updates (e.g., switching between "Show Console" and "Hide Console") based on the current visibility state.

  10. Understand the Dashboard Frontend architecture

    master

    The frontend is built with Svelte 5 (using runes) and Vite.

    Key UI Components:

    • App.svelte: The top-level layout. It defines the global design tokens via CSS variables (e.g., --bg, --blue, --font-display).
    • lib/Sidebar.svelte: Contains the status badge, server/version info, and the CountersPanel.
    • lib/CountersPanel.svelte: Displays counters as a vertical label/value list within the sidebar.
    • lib/LogTail.svelte: A scrolling log view. It automatically linkifies http(s):// URLs and specific data identifiers. An identifier is recognized if it follows the literal prefix "Identifier: " (e.g., Identifier: <uuid>), which links to albion-online-data.com/identifier?identifier=<uuid>.
    • lib/Footer.svelte: Contains external links (Project site, Discord).

    Design Guidelines:

    • Color Palette: Uses a "charcoal & electric blue" theme. Use the provided CSS tokens (e.g., --bg, --blue) instead of inventing new colors.
    • Semantic Colors: --ember (error/red) and --moss (success/green) are reserved for semantic status and should not be part of general palette swaps.
    • Navigation: All external links must use Browser.OpenURL to open in the user's system browser rather than navigating within the webview.
  11. The single-file build convention

    master

    The project follows a strict single-file build convention for the main package. All build scripts (e.g., scripts/build-windows.sh, scripts/run.sh, buildall_main.sh) invoke the compiler by targeting a specific file rather than the package directory:

    go build ... albiondata-client.go

    Rules for adding code to the root:

    • Never add a second .go file directly in the repository root if it belongs to package main.
    • Any additional .go files in the root will be ignored by the build scripts, leading to undefined: linker errors.
    • If the main function requires new logic or dependencies, place that code in an internal/ package and import it normally.
    go build ... albiondata-client.go
  12. How the Private Server label is determined

    master

    The dashboard's Server field displays a 'Private' label if the user has configured a custom ingest URL via the -i flag.

    Technically, PrivateIngest is set to true whenever the configuration value for client.ConfigGlobal.PublicIngestBaseUrls is not equal to the default string: https+pow://albion-online-data.com. This value is computed once at startup and is not recomputed during runtime.