Phase 2 references for the host-agent Dune adapter, moved out of volatile /tmp
into docs/reference-repos/ (per Commander). Three upstream projects, .git +
node_modules + compiled binaries stripped (16MB source). Nested AI-instruction
files (.claude/, CLAUDE.md) removed so they don't pollute Corrosion sessions.
- icehunter/ dune-admin (Go+React) — 4 control planes; SETUP_DOCKER.md is the
closest analog to our agent's Dune docker control plane (compose
lifecycle, docker logs, RabbitMQ-via-exec, dune Postgres schema)
- adainrivers/ Rust/Tauri desktop — SSH+k8s BattleGroup control, maintenance
daemon, in-game admin console (Rust idiom reference)
- the4rchangel/ Node web UI replacing battlegroup.bat — matches the Commander's
Hyper-V self-host path + game-config schema
See docs/reference-repos/README.md for the full index + how we use each.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
48 lines
1.6 KiB
Go
48 lines
1.6 KiB
Go
package main
|
|
|
|
// presenceTracker detects player join events by diffing the set of online
|
|
// accounts across successive observations. The first observation seeds a silent
|
|
// baseline so a dune-admin (re)start does not re-fire on-join actions (e.g. the
|
|
// MOTD) for everyone already in-game; a player who goes offline and returns is a
|
|
// new join. Keyed on account id (always present), which is also what the whisper
|
|
// path consumes.
|
|
//
|
|
// Not safe for concurrent use: the scanner calls observe() serially from its
|
|
// single goroutine.
|
|
type presenceTracker struct {
|
|
seen map[int64]struct{}
|
|
seeded bool
|
|
}
|
|
|
|
func newPresenceTracker() *presenceTracker {
|
|
return &presenceTracker{seen: map[int64]struct{}{}}
|
|
}
|
|
|
|
// observe records the currently-online accounts and returns those newly online
|
|
// since the previous observation (join events). The first call returns no joins
|
|
// (it only seeds the baseline).
|
|
func (p *presenceTracker) observe(online []welcomeAccount) []welcomeAccount {
|
|
current := make(map[int64]struct{}, len(online))
|
|
var joins []welcomeAccount
|
|
for _, acc := range online {
|
|
current[acc.AccountID] = struct{}{}
|
|
if !p.seeded {
|
|
continue
|
|
}
|
|
if _, ok := p.seen[acc.AccountID]; !ok {
|
|
joins = append(joins, acc)
|
|
}
|
|
}
|
|
p.seen = current
|
|
p.seeded = true
|
|
return joins
|
|
}
|
|
|
|
// reset re-arms the baseline so the next observe is silent. Used when the MOTD
|
|
// feature is toggled off (and later on) so currently-online players are not
|
|
// messaged on the flip — only genuine future joins are.
|
|
func (p *presenceTracker) reset() {
|
|
p.seen = map[int64]struct{}{}
|
|
p.seeded = false
|
|
}
|