원격관리: 연결 끊기 후 표시 막대가 남는 문제 수정

- 화면 프레임 전송을 화면 중지 토큰으로 취소하지 않음 (TLS 스트림 손상 방지)
- screenStop/연결 종료/[연결 끊기] 시 표시 막대 즉시 갱신 (EndScreen)
- Passive 수신을 켠 적이 없으면 시작 시 "Passive 수신 중지" 로그 생략

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013U497kUNL8ArhV7jkzCpKa
main
Claude 2026-10-27 05:02:50 +00:00
parent e7f7bcf1f2
commit 39a8f03b59
No known key found for this signature in database
2 changed files with 20 additions and 7 deletions

View File

@ -456,11 +456,12 @@ namespace JJServiceManager.Remote
var key = enabled ? $"{mode}|{port}" : "off"; var key = enabled ? $"{mode}|{port}" : "off";
if (key == _key) return; if (key == _key) return;
_key = key; _key = key;
bool wasRunning = _listener != null;
_listener?.Dispose(); _listener?.Dispose();
_listener = null; _listener = null;
if (!enabled) if (!enabled)
{ {
_log("Passive 수신 중지", LogLevel.Info); if (wasRunning) _log("Passive 수신 중지", LogLevel.Info);
return; return;
} }
try try

View File

@ -399,7 +399,7 @@ namespace JJServiceManager.Remote
} }
} }
var old = Interlocked.Exchange(ref screen, null); var old = Interlocked.Exchange(ref screen, null);
old?.Stop(); EndScreen(old);
var s = new ScreenSession(Interlocked.Increment(ref _nextScreenId), whoNow, control, monitor); var s = new ScreenSession(Interlocked.Increment(ref _nextScreenId), whoNow, control, monitor);
screen = s; screen = s;
_screens[s.Id] = s; _screens[s.Id] = s;
@ -425,7 +425,7 @@ namespace JJServiceManager.Remote
case "screenStop": case "screenStop":
{ {
var s = Interlocked.Exchange(ref screen, null); var s = Interlocked.Exchange(ref screen, null);
s?.Stop(); EndScreen(s);
await Reply(conn, id, result: new JsonObject()); await Reply(conn, id, result: new JsonObject());
break; break;
} }
@ -473,7 +473,7 @@ namespace JJServiceManager.Remote
streams.Clear(); streams.Clear();
} }
var s = Interlocked.Exchange(ref screen, null); var s = Interlocked.Exchange(ref screen, null);
s?.Stop(); EndScreen(s);
conn.Dispose(); conn.Dispose();
if (authed && who != peer) _log($"원격 연결 종료: {who}", LogLevel.Info); if (authed && who != peer) _log($"원격 연결 종료: {who}", LogLevel.Info);
} }
@ -544,7 +544,7 @@ namespace JJServiceManager.Remote
["w"] = w, ["w"] = w,
["h"] = h, ["h"] = h,
["data"] = Convert.ToBase64String(jpeg) ["data"] = Convert.ToBase64String(jpeg)
}, s.Token).ConfigureAwait(false); }, ct).ConfigureAwait(false); // 보내는 도중 취소하면 TLS 스트림이 깨지므로 화면 중지 토큰은 쓰지 않음
lastHash = hash; lastHash = hash;
lastMonitor = monitor; lastMonitor = monitor;
lastSent = DateTime.UtcNow; lastSent = DateTime.UtcNow;
@ -564,7 +564,11 @@ namespace JJServiceManager.Remote
_screens.TryRemove(s.Id, out _); _screens.TryRemove(s.Id, out _);
if (!conn.IsDisposed) if (!conn.IsDisposed)
{ {
try { await conn.SendAsync(new JsonObject { ["event"] = "screenEnd", ["sid"] = s.Id, ["reason"] = endReason }).ConfigureAwait(false); } try
{
using var t = new CancellationTokenSource(TimeSpan.FromSeconds(5));
await conn.SendAsync(new JsonObject { ["event"] = "screenEnd", ["sid"] = s.Id, ["reason"] = endReason }, t.Token).ConfigureAwait(false);
}
catch { } catch { }
} }
_log($"[원격 화면] {s.Who} 연결 끝", LogLevel.Info); _log($"[원격 화면] {s.Who} 연결 끝", LogLevel.Info);
@ -572,10 +576,18 @@ namespace JJServiceManager.Remote
} }
} }
/// <summary>화면 연결 하나 끝내기 — 표시 막대는 바로 갱신</summary>
private void EndScreen(ScreenSession s)
{
if (s == null) return;
s.Stop();
if (_screens.TryRemove(s.Id, out _)) NotifyViewers();
}
/// <summary>이 PC에서 [연결 끊기]를 눌렀을 때 모든 화면 연결 종료</summary> /// <summary>이 PC에서 [연결 끊기]를 눌렀을 때 모든 화면 연결 종료</summary>
public void StopAllScreens() public void StopAllScreens()
{ {
foreach (var s in _screens.Values) s.Stop(); foreach (var s in _screens.Values.ToList()) EndScreen(s);
} }
private void NotifyViewers() private void NotifyViewers()