Add desktop discovery responder

This commit is contained in:
Misaka
2026-05-16 20:36:12 +08:00
parent 4f6e817a76
commit 4caa21c4d2
3 changed files with 134 additions and 0 deletions

View File

@@ -6,6 +6,7 @@ public sealed class TrayApplicationContext : ApplicationContext
{
private readonly KeyboardInjectionService keyboard;
private readonly WebSocketServerService server;
private readonly DiscoveryResponderService discovery;
private readonly NotifyIcon notifyIcon;
private ToolStripMenuItem? clipboardPasteMenuItem;
private ToolStripMenuItem? sendInputTypingMenuItem;
@@ -18,6 +19,7 @@ public sealed class TrayApplicationContext : ApplicationContext
server = new WebSocketServerService(handler);
server.StatusChanged += (_, _) => UpdateTrayText();
discovery = new DiscoveryResponderService(() => server.LocalIpAddress, () => server.Port);
notifyIcon = new NotifyIcon
{
@@ -31,6 +33,7 @@ public sealed class TrayApplicationContext : ApplicationContext
try
{
server.Start(8181);
discovery.Start();
UpdateTrayText();
}
catch (Exception ex)
@@ -47,6 +50,7 @@ public sealed class TrayApplicationContext : ApplicationContext
if (disposing)
{
notifyIcon.Dispose();
discovery.Dispose();
server.Dispose();
}