From 81d19c7b8cde74c4d23ef44bceefecdefb101989 Mon Sep 17 00:00:00 2001 From: Ednunp <29843396+Ednunp@users.noreply.github.com> Date: Thu, 23 Jul 2026 15:47:38 +0100 Subject: [PATCH] Discovery: optional display-name override for headless senders (announce a friendly name instead of the hostname; null keeps the machine name, so the app is unchanged) --- src/RemSound.Core/PeerDiscoveryService.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/RemSound.Core/PeerDiscoveryService.cs b/src/RemSound.Core/PeerDiscoveryService.cs index 1b89ff3..56db522 100644 --- a/src/RemSound.Core/PeerDiscoveryService.cs +++ b/src/RemSound.Core/PeerDiscoveryService.cs @@ -54,8 +54,18 @@ public sealed class PeerDiscoveryService : IDisposable private int broadcastCacheDirty = 1; // 1 = needs rebuild, 0 = current. Int for Interlocked. private NetworkAddressChangedEventHandler? networkChangeHandler; + // The name announced to other peers. Defaults to the machine name (what the desktop app has always + // shown); a headless sender can pass a friendly override so it shows up in peer lists under a + // meaningful name rather than its hostname. + private readonly string displayName; + public event Action? PeersChanged; + /// Create a discovery service. is what other peers see in + /// their list; null/blank falls back to the machine name (the app's long-standing behaviour). + public PeerDiscoveryService(string? displayName = null) + => this.displayName = string.IsNullOrWhiteSpace(displayName) ? Environment.MachineName : displayName.Trim(); + public IReadOnlyList Peers { get @@ -229,7 +239,7 @@ public sealed class PeerDiscoveryService : IDisposable var currentAnnouncer = announcer; if (currentAnnouncer is null || !announceEnabled) return; - var message = new DiscoveryMessage(instanceId, Environment.MachineName, audioPort, canSend, canReceive); + var message = new DiscoveryMessage(instanceId, displayName, audioPort, canSend, canReceive); var bytes = Encoding.UTF8.GetBytes(JsonSerializer.Serialize(message)); // Broadcast to LAN — instant discovery on the same physical/wifi network. Each connected