diff --git a/Core/Models.cs b/Core/Models.cs index f83cc44..f168ebd 100644 --- a/Core/Models.cs +++ b/Core/Models.cs @@ -95,10 +95,14 @@ namespace JJServiceManager { get { - var addr = Direction == ConnectDirection.Passive - ? (string.IsNullOrWhiteSpace(LastAddress) ? "Passive " + AccessCode : LastAddress) - : Address; - return string.IsNullOrWhiteSpace(Hostname) ? addr : $"{addr} / {Hostname}"; + if (Direction == ConnectDirection.Passive) + { + // 아직 한 번도 접속하지 않았으면 코드로 표시 + if (string.IsNullOrWhiteSpace(LastAddress)) return "Passive " + AccessCode; + var p = string.IsNullOrWhiteSpace(Hostname) ? LastAddress : $"{LastAddress} / {Hostname}"; + return p + " (Passive)"; + } + return string.IsNullOrWhiteSpace(Hostname) ? Address : $"{Address} / {Hostname}"; } } diff --git a/Windows/MainWindow.cs b/Windows/MainWindow.cs index af377ba..0eb4b62 100644 --- a/Windows/MainWindow.cs +++ b/Windows/MainWindow.cs @@ -794,7 +794,13 @@ namespace JJServiceManager StatusBrush = Brushes2.Pending, EmptyText = "연결 중…" }; - client.StateChanged += c => Dispatcher.BeginInvoke(new Action(() => OnRemoteState(g, c))); + client.StateChanged += c => + { + // 상태는 이벤트 시점 값으로 넘김 (UI에서 나중에 읽으면 연속 변경이 모두 같은 값으로 보임) + var st = c.State; + var stMsg = c.StateMessage; + Dispatcher.BeginInvoke(new Action(() => OnRemoteState(g, st, stMsg))); + }; client.ServicesChanged += c => Dispatcher.BeginInvoke(new Action(() => OnRemoteServices(g, c))); client.HostnameDiscovered += (c, host) => Dispatcher.BeginInvoke(new Action(() => OnHostname(g, c, host))); client.PeerAddressDiscovered += (c, addr) => Dispatcher.BeginInvoke(new Action(() => OnPeerAddress(g, addr))); @@ -851,10 +857,10 @@ namespace JJServiceManager _logWindows.ChoicesChanged(); } - private void OnRemoteState(HostGroup g, RemoteClient c) + private void OnRemoteState(HostGroup g, RemoteState state, string stateMessage) { if (!_groups.Contains(g)) return; - switch (c.State) + switch (state) { case RemoteState.Connected: g.StatusText = "연결됨"; @@ -868,17 +874,17 @@ namespace JJServiceManager break; default: bool wasConnected = g.Rows.Any(r => r.StatusKnown); - g.StatusText = (c.State == RemoteState.AuthFailed ? "인증 실패: " : "연결 안 됨: ") + c.StateMessage; + g.StatusText = (state == RemoteState.AuthFailed ? "인증 실패: " : "연결 안 됨: ") + stateMessage; g.StatusBrush = Brushes2.Stopped; g.EmptyText = g.StatusText; foreach (var r in g.Rows) r.MarkUnknown(); // 같은 실패 메시지는 처음 한 번만 기록 - if (wasConnected || g.Tag != c.StateMessage) - Log($"[{g.Prefix}] {g.StatusText}", c.State == RemoteState.AuthFailed ? LogLevel.Error : LogLevel.Warning); - g.Tag = c.StateMessage; + if (wasConnected || g.Tag != stateMessage) + Log($"[{g.Prefix}] {g.StatusText}", state == RemoteState.AuthFailed ? LogLevel.Error : LogLevel.Warning); + g.Tag = stateMessage; break; } - if (c.State == RemoteState.Connected) g.Tag = null; + if (state == RemoteState.Connected) g.Tag = null; UpdateCounts(); }