diff --git a/CShocker/CShocker.csproj b/CShocker/CShocker.csproj
index 9b8dc9a..ff79641 100644
--- a/CShocker/CShocker.csproj
+++ b/CShocker/CShocker.csproj
@@ -7,7 +7,7 @@
Glax
https://github.com/C9Glax/CShocker
git
- 2.4.2
+ 2.5.0
diff --git a/CShocker/Devices/APIs/OpenShockHttp.cs b/CShocker/Devices/APIs/OpenShockHttp.cs
index 4b71e6e..3949c65 100644
--- a/CShocker/Devices/APIs/OpenShockHttp.cs
+++ b/CShocker/Devices/APIs/OpenShockHttp.cs
@@ -20,7 +20,7 @@ public class OpenShockHttp : OpenShockApi
" \"shocks\": [" +
" {" +
$" \"id\": \"{openShockShocker.ID}\"," +
- $" \"type\": {ControlActionToByte(action)}," +
+ $" \"type\": \"{Enum.GetName(action)}\"," +
$" \"intensity\": {intensity}," +
$" \"duration\": {duration}" +
" }" +
@@ -31,17 +31,6 @@ public class OpenShockHttp : OpenShockApi
ApiHttpClient.MakeAPICall(HttpMethod.Post, $"{Endpoint}/2/shockers/control", json, this.Logger, new ValueTuple("OpenShockToken", ApiKey));
}
- private byte ControlActionToByte(ControlAction action)
- {
- return action switch
- {
- ControlAction.Beep => 3,
- ControlAction.Vibrate => 2,
- ControlAction.Shock => 1,
- _ => 0
- };
- }
-
public OpenShockHttp(string apiKey, string endpoint = "https://api.shocklink.net", ILogger? logger = null) : base(DeviceApi.OpenShockHttp, apiKey, endpoint, logger)
{
}
diff --git a/CShocker/Devices/Abstract/Api.cs b/CShocker/Devices/Abstract/Api.cs
index c26a8ee..71bf305 100644
--- a/CShocker/Devices/Abstract/Api.cs
+++ b/CShocker/Devices/Abstract/Api.cs
@@ -20,11 +20,6 @@ public abstract class Api : IDisposable
internal void Control(ControlAction action, int intensity, int duration, params Shocker[] shockers)
{
bool enqueueItem = true;
- if (action is ControlAction.Nothing)
- {
- this.Logger?.Log(LogLevel.Information, "No action defined.");
- enqueueItem = false;
- }
if (!ValidIntensityRange.IsValueWithinLimits(intensity))
{
this.Logger?.Log(LogLevel.Information, $"Value not within allowed {nameof(intensity)}-Range ({ValidIntensityRange.RangeString()}): {intensity}");
diff --git a/CShocker/Devices/Abstract/OpenShockApi.cs b/CShocker/Devices/Abstract/OpenShockApi.cs
index d9fda5c..e6f723f 100644
--- a/CShocker/Devices/Abstract/OpenShockApi.cs
+++ b/CShocker/Devices/Abstract/OpenShockApi.cs
@@ -11,7 +11,7 @@ public abstract class OpenShockApi : Api
// ReSharper disable twice MemberCanBeProtected.Global -> Exposed
public string Endpoint { get; init; }
public string ApiKey { get; init; }
- private const string DefaultEndpoint = "https://api.shocklink.net";
+ private const string DefaultEndpoint = "https://api.openshock.app";
// ReSharper disable once PublicConstructorInAbstractClass -> Exposed
public OpenShockApi(DeviceApi apiType, string apiKey, string endpoint = DefaultEndpoint, ILogger? logger = null) : base(apiType, new IntegerRange(0, 100), new IntegerRange(300, 30000), logger)
diff --git a/CShocker/Devices/Additional/ApiHttpClient.cs b/CShocker/Devices/Additional/ApiHttpClient.cs
index 93645c8..cca3053 100644
--- a/CShocker/Devices/Additional/ApiHttpClient.cs
+++ b/CShocker/Devices/Additional/ApiHttpClient.cs
@@ -18,12 +18,15 @@ public static class ApiHttpClient
Headers =
{
UserAgent = { userAgent },
- Accept = { new MediaTypeWithQualityHeaderValue("application/json") }
+ Accept = { new MediaTypeWithQualityHeaderValue("application/json") },
+
}
};
if (jsonContent is not null && jsonContent.Length > 0)
- request.Content =
- new StringContent(jsonContent, Encoding.UTF8, new MediaTypeHeaderValue("application/json"));
+ request.Content = new ByteArrayContent(Encoding.UTF8.GetBytes(jsonContent))
+ {
+ Headers = { ContentType = MediaTypeHeaderValue.Parse("application/json") }
+ };
foreach ((string, string) customHeader in customHeaders)
request.Headers.Add(customHeader.Item1, customHeader.Item2);
logger?.Log(LogLevel.Debug, string.Join("\n\t",
diff --git a/CShocker/Devices/Additional/ControlActionEnum.cs b/CShocker/Devices/Additional/ControlActionEnum.cs
index 49bffb4..6b54d92 100644
--- a/CShocker/Devices/Additional/ControlActionEnum.cs
+++ b/CShocker/Devices/Additional/ControlActionEnum.cs
@@ -5,5 +5,5 @@ public enum ControlAction
Beep,
Vibrate,
Shock,
- Nothing
+ Stop
}
\ No newline at end of file