Skip to content

Commit 5f5afe8

Browse files
committed
WSS Support + HTTPS Rework
Also dropped HTTP support
1 parent 40d6153 commit 5f5afe8

18 files changed

Lines changed: 925 additions & 235 deletions

LICENSE.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
The MIT License (MIT)
3+
4+
Copyright (c) 2026 Jasper M-W
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy
7+
of this software and associated documentation files (the "Software"), to deal
8+
in the Software without restriction, including without limitation the rights
9+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
copies of the Software, and to permit persons to whom the Software is
11+
furnished to do so, subject to the following conditions:
12+
13+
The above copyright notice and this permission notice shall be included in all
14+
copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
SOFTWARE.

src/HapticWebPlugin.cs

Lines changed: 47 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -67,17 +67,24 @@ private async Task InitializeServerAsync()
6767
var certCacheDir = Path.Combine(pluginDataDir, "certificates");
6868

6969
this._certificateManager = new CertificateManager(certCacheDir);
70-
var certLoaded = await this._certificateManager.InitializeAsync();
70+
await this._certificateManager.InitializeAsync();
7171

7272
this.UpdatePluginStatus();
7373

7474
this._httpsServer = new HttpsServer(
7575
HttpPort,
7676
HttpsPort,
7777
this._certificateManager.Certificate,
78-
this.HandleHttpRequest);
78+
this.HandleHttpRequest,
79+
this.RunHapticByIndex,
80+
HapticWaveforms);
7981

8082
this._httpsServer.Start();
83+
84+
if (!String.IsNullOrEmpty(this._httpsServer.BindError))
85+
{
86+
this.OnPluginStatusChanged(Loupedeck.PluginStatus.Error, this._httpsServer.BindError);
87+
}
8188
}
8289
catch (Exception ex)
8390
{
@@ -183,22 +190,27 @@ private Object HandleTriggerHaptic(String waveform)
183190
};
184191
}
185192

186-
try
193+
PluginLog.Verbose($"Queueing haptic: {waveform}");
194+
Task.Run(() =>
187195
{
188-
this.PluginEvents.RaiseEvent(waveform);
189-
PluginLog.Info($"Triggered haptic: {waveform}");
190-
191-
return new
196+
PluginLog.Verbose($"Starting haptic task: {waveform}");
197+
try
192198
{
193-
success = true,
194-
waveform = waveform
195-
};
196-
}
197-
catch (Exception ex)
199+
this.PluginEvents.RaiseEvent(waveform);
200+
PluginLog.Info($"Triggered haptic: {waveform}");
201+
}
202+
catch (Exception ex)
203+
{
204+
PluginLog.Error(ex, $"Failed haptic task: {waveform}");
205+
}
206+
});
207+
208+
PluginLog.Verbose($"Returning response for: {waveform}");
209+
return new
198210
{
199-
PluginLog.Error(ex, $"Failed to trigger haptic: {waveform}");
200-
return new { success = false, error = $"Failed to trigger haptic: {ex.Message}" };
201-
}
211+
success = true,
212+
waveform = waveform
213+
};
202214
}
203215

204216
private void RegisterHapticEvents()
@@ -209,5 +221,25 @@ private void RegisterHapticEvents()
209221
}
210222
PluginLog.Info($"Registered {HapticWaveforms.Count} haptic events");
211223
}
224+
225+
private void RunHapticByIndex(Int32 index)
226+
{
227+
if (index < 0 || index >= HapticWaveforms.Count)
228+
{
229+
PluginLog.Warning($"Invalid haptic index: {index}");
230+
return;
231+
}
232+
233+
var waveform = HapticWaveforms[index];
234+
try
235+
{
236+
this.PluginEvents.RaiseEvent(waveform);
237+
PluginLog.Verbose($"Triggered haptic by index: {index} -> {waveform}");
238+
}
239+
catch (Exception ex)
240+
{
241+
PluginLog.Error(ex, $"Failed to trigger haptic: {waveform}");
242+
}
243+
}
212244
}
213245
}

src/HapticWebPlugin.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
</ItemGroup>
3232

3333
<ItemGroup>
34+
<PackageReference Include="NetCoreServer" Version="8.0.7" />
3435
<PackageReference Include="SharpZipLib" Version="1.4.2" />
3536
</ItemGroup>
3637

0 commit comments

Comments
 (0)