Initialize Windows desktop skeleton
This commit is contained in:
33
WirelessTextSyncer.Windows/Services/SyncMessageHandler.cs
Normal file
33
WirelessTextSyncer.Windows/Services/SyncMessageHandler.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
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}");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user