Albion Data Client
repository·master·Indexed 41 days ago
https://github.com/ao-data/albiondata-clientA 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.
What's inside Albion Data Client
- 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.
Use albiondata-client/lib structs for JSON uploads
masterThealbiondata-client/libpackage 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.Dashboard UI Components
masterThe 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.
Dashboard behavior at launch
masterThe 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: trueand only becomes visible and focused once theApplicationStartedevent fires. This ensures the window is fully realized before being shown.On macOS, the app uses
ActivationPolicyAccessory, so the dashboard explicitly callsFocus()after becoming visible to ensure it appears in front of other active applications.How dashboard activity heartbeat and staleness work
masterThe 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,CaptureRunningis set totrue. A background goroutine (the staleness ticker) periodically checks the time since the last activity. If the time elapsed exceedsCaptureStaleAfter,CaptureRunningis set tofalse.Key configuration variables (overridable in tests):
CaptureStaleAfter: Duration of inactivity before the status becomes stale (default30s).StaleCheckInterval: Frequency of the staleness check (default5s).
// Example of how activity is recorded during packet decoding if err == nil { dashboard.RecordActivity() }How the self-update mechanism works
masterThe
albiondata-clientuses thestartUpdater()function (defined inalbiondata-client.go) to poll for updates hourly viagithub.com/ao-data/go-githubupdate.Important constraints:
- Dev builds do not update: The updater only runs if the
versionstring is not empty and does not contain the substringdev. Dev builds (the default when usingscripts/run.shorbuildall_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.
- Dev builds do not update: The updater only runs if the
Understand the Dashboard Capturing Status behavior
masterThe 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, orEventData) 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'.
Implementation Plan: Dashboard Auto-Open and Windows Console Management
masterThis 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/consolepackage 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 manualruntime.GOOSchecks. - Dashboard Auto-Open: Uses the
showDashboardWindow()helper. This is preferred over the WailsHiddenoption becauseshowDashboardWindow()usesInvokeSync(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 returnstrueonly 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.
Windows console visibility and tray control
masterOn 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.
Understand the Dashboard Frontend architecture
masterThe 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 theCountersPanel.lib/CountersPanel.svelte: Displays counters as a vertical label/value list within the sidebar.lib/LogTail.svelte: A scrolling log view. It automatically linkifieshttp(s)://URLs and specific data identifiers. An identifier is recognized if it follows the literal prefix"Identifier: "(e.g.,Identifier: <uuid>), which links toalbion-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.OpenURLto open in the user's system browser rather than navigating within the webview.
The single-file build convention
masterThe project follows a strict single-file build convention for the
mainpackage. 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.goRules for adding code to the root:
- Never add a second
.gofile directly in the repository root if it belongs topackage main. - Any additional
.gofiles in the root will be ignored by the build scripts, leading toundefined:linker errors. - If the
mainfunction requires new logic or dependencies, place that code in aninternal/package and import it normally.
go build ... albiondata-client.go- Never add a second
How the Private Server label is determined
masterThe dashboard's Server field displays a 'Private' label if the user has configured a custom ingest URL via the
-iflag.Technically,
PrivateIngestis set totruewhenever the configuration value forclient.ConfigGlobal.PublicIngestBaseUrlsis 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.