Skip to content

Commit

Permalink
remove unused imports; sendAndAddEvent now adds to events even when w…
Browse files Browse the repository at this point in the history
…ebsocket is not started
  • Loading branch information
christian-photo committed Jan 2, 2025
1 parent 376b39f commit 1814e46
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
6 changes: 6 additions & 0 deletions ninaAPI/Utility/CoreUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ This Source Code Form is subject to the terms of the Mozilla Public
using ninaAPI.WebService;
using System.Text.Json;
using System.Text.Json.Serialization;
using Xceed.Wpf.Toolkit.Core.Converters;

namespace ninaAPI.Utility
{
Expand Down Expand Up @@ -164,6 +165,11 @@ public static void WriteToResponse(this IHttpContext context, object json)
}
}

public static bool IsParameterOmitted(this IHttpContext context, string parameter)
{
return !context.Request.QueryString.AllKeys.Contains(parameter);
}

public static object CastString(this string str, Type type)
{
if (type == typeof(int))
Expand Down
4 changes: 0 additions & 4 deletions ninaAPI/WebService/V2/Application/Sequence.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ This Source Code Form is subject to the terms of the Mozilla Public
using System.Collections;
using NINA.Profile.Interfaces;
using NINA.Sequencer.Trigger.Autofocus;
using NINA.Sequencer.Trigger;
using NINA.Sequencer.Conditions;
using NINA.Sequencer.SequenceItem.Utility;
using NINA.Sequencer.Trigger.Guider;
Expand All @@ -37,9 +36,6 @@ This Source Code Form is subject to the terms of the Mozilla Public
using NINA.Sequencer.SequenceItem.Switch;
using NINA.Sequencer.SequenceItem.Telescope;
using System.IO;
using System.Security.Policy;
using NINA.Sequencer;
using System.Linq;

namespace ninaAPI.WebService.V2
{
Expand Down
1 change: 0 additions & 1 deletion ninaAPI/WebService/V2/Equipment/FilterWheel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ This Source Code Form is subject to the terms of the Mozilla Public

#endregion "copyright"

using Accord.Imaging.Filters;
using EmbedIO;
using EmbedIO.Routing;
using EmbedIO.WebApi;
Expand Down
6 changes: 3 additions & 3 deletions ninaAPI/WebService/V2/WebSocketV2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public static async Task SendAndAddEvent(string eventName, DateTime time)
HttpResponse Event = new HttpResponse() { Type = HttpResponse.TypeSocket, Response = new Dictionary<string, object>() { { "Event", eventName }, { "Time", time } } };
Events.Add(Event);

await instance.Send(response);
await instance?.Send(response);
}


Expand Down Expand Up @@ -137,15 +137,15 @@ protected override Task OnMessageReceivedAsync(IWebSocketContext context, byte[]

protected override Task OnClientConnectedAsync(IWebSocketContext context)
{
Logger.Debug("WebSocket connected " + context.RemoteEndPoint.ToString());
Logger.Info("WebSocket connected " + context.RemoteEndPoint.ToString());
return Task.CompletedTask;
}

public async Task Send(HttpResponse payload)
{
foreach (IWebSocketContext context in ActiveContexts)
{
Logger.Debug("Sending to " + context.RemoteEndPoint.ToString());
Logger.Trace("Sending to " + context.RemoteEndPoint.ToString());
await SendAsync(context, JsonConvert.SerializeObject(payload));
}
}
Expand Down

0 comments on commit 1814e46

Please sign in to comment.