Files
desktop/WirelessTextSyncer.Windows/Services/SyncMessageHandler.cs
2026-05-15 20:12:07 +08:00

34 lines
911 B
C#

using WirelessTextSyncer.Windows.Models;
namespace WirelessTextSyncer.Windows.Services;
public sealed class SyncMessageHandler
{
private readonly IKeyboardInjectionService keyboard;
public SyncMessageHandler(IKeyboardInjectionService keyboard)
{
this.keyboard = keyboard;
}
public void Handle(SyncMessage message)
{
switch (message.Action)
{
case SyncAction.InsertText:
keyboard.InsertText(message.Text ?? string.Empty);
break;
case SyncAction.Backspace:
keyboard.Backspace();
break;
case SyncAction.Enter:
keyboard.Enter();
break;
case SyncAction.Ping:
break;
default:
throw new InvalidOperationException($"Unsupported sync action: {message.Action}");
}
}
}