Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Linux & Web Build #31

Merged
merged 10 commits into from
May 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions .github/workflows/ci-ubuntu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
on:
push:
branches:
- '*'
pull_request:
branches:
- '*'
types: [opened, reopened, synchronize]
workflow_call:
workflow_dispatch:

name: ci-ubuntu

env:
DOTNET_VERSION: 8.0.x
REGISTRY: ghcr.io

jobs:

build:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup .NET SDK ${{ env.DOTNET_VERSION }}
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}

- name: Cache NuGet packages
uses: actions/cache@v3
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
restore-keys: |
${{ runner.os }}-nuget-

- name: Publish ShockOSC Photino Linux
run: dotnet publish ShockOsc/ShockOsc.csproj -c Release-Photino -o ./publish/ShockOsc/Linux

- name: Upload ShockOSC Photino Linux artifacts
uses: actions/upload-artifact@v4
with:
name: ShockOsc
path: publish/ShockOsc/Linux/*
retention-days: 1
if-no-files-found: error
4 changes: 2 additions & 2 deletions .github/workflows/ci-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
${{ runner.os }}-nuget-

- name: Publish ShockOSC Windows
run: dotnet publish ShockOsc/ShockOsc.csproj -c Release -f net8.0-windows10.0.19041.0 -o ./publish/ShockOsc
run: dotnet publish ShockOsc/ShockOsc.csproj -c Release-Windows -o ./publish/ShockOsc

- name: Upload ShockOSC Windows artifacts
uses: actions/upload-artifact@v4
Expand All @@ -48,7 +48,7 @@ jobs:
retention-days: 1
if-no-files-found: error

instller:
installer:
runs-on: windows-latest
needs: build

Expand Down
25 changes: 18 additions & 7 deletions ShockOsc.sln
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,26 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ShockOsc", "ShockOsc\ShockO
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
Release-Windows|Any CPU = Release-Windows|Any CPU
Debug-Windows|Any CPU = Debug-Windows|Any CPU
Release-Photino|Any CPU = Release-Photino|Any CPU
Debug-Photino|Any CPU = Debug-Photino|Any CPU
Release-Web|Any CPU = Release-Web|Any CPU
Debug-Web|Any CPU = Debug-Web|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{D3C13FCF-0FF6-45E1-AA57-0EDF1AB8C48B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D3C13FCF-0FF6-45E1-AA57-0EDF1AB8C48B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D3C13FCF-0FF6-45E1-AA57-0EDF1AB8C48B}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
{D3C13FCF-0FF6-45E1-AA57-0EDF1AB8C48B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D3C13FCF-0FF6-45E1-AA57-0EDF1AB8C48B}.Release|Any CPU.Build.0 = Release|Any CPU
{D3C13FCF-0FF6-45E1-AA57-0EDF1AB8C48B}.Release-Windows|Any CPU.ActiveCfg = Release-Windows|Any CPU
{D3C13FCF-0FF6-45E1-AA57-0EDF1AB8C48B}.Release-Windows|Any CPU.Build.0 = Release-Windows|Any CPU
{D3C13FCF-0FF6-45E1-AA57-0EDF1AB8C48B}.Debug-Windows|Any CPU.ActiveCfg = Debug-Windows|Any CPU
{D3C13FCF-0FF6-45E1-AA57-0EDF1AB8C48B}.Debug-Windows|Any CPU.Build.0 = Debug-Windows|Any CPU
{D3C13FCF-0FF6-45E1-AA57-0EDF1AB8C48B}.Release-Photino|Any CPU.ActiveCfg = Release-Photino|Any CPU
{D3C13FCF-0FF6-45E1-AA57-0EDF1AB8C48B}.Release-Photino|Any CPU.Build.0 = Release-Photino|Any CPU
{D3C13FCF-0FF6-45E1-AA57-0EDF1AB8C48B}.Debug-Photino|Any CPU.ActiveCfg = Debug-Photino|Any CPU
{D3C13FCF-0FF6-45E1-AA57-0EDF1AB8C48B}.Debug-Photino|Any CPU.Build.0 = Debug-Photino|Any CPU
{D3C13FCF-0FF6-45E1-AA57-0EDF1AB8C48B}.Release-Web|Any CPU.ActiveCfg = Release-Web|Any CPU
{D3C13FCF-0FF6-45E1-AA57-0EDF1AB8C48B}.Release-Web|Any CPU.Build.0 = Release-Web|Any CPU
{D3C13FCF-0FF6-45E1-AA57-0EDF1AB8C48B}.Debug-Web|Any CPU.ActiveCfg = Debug-Web|Any CPU
{D3C13FCF-0FF6-45E1-AA57-0EDF1AB8C48B}.Debug-Web|Any CPU.Build.0 = Debug-Web|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
33 changes: 30 additions & 3 deletions ShockOsc/Backend/OpenShockApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,13 @@ public sealed class OpenShockApi
{
private readonly ILogger<OpenShockApi> _logger;
private readonly ConfigManager _configManager;
private OpenShockApiClient _client;
private OpenShockApiClient? _client = null;

/// <summary>
/// DI constructor
/// </summary>
/// <param name="logger"></param>
/// <param name="configManager"></param>
public OpenShockApi(ILogger<OpenShockApi> logger, ConfigManager configManager)
{
_logger = logger;
Expand All @@ -37,6 +42,11 @@ public void SetupApiClient()

public async Task RefreshShockers()
{
if (_client == null)
{
_logger.LogError("Client is not initialized!");
throw new Exception("Client is not initialized!");
}
var response = await _client.GetOwnShockers();

response.Switch(success =>
Expand Down Expand Up @@ -71,8 +81,25 @@ public async Task RefreshShockers()
});
}

public void Logout()
{
Devices = Array.Empty<ResponseDeviceWithShockers>();
Shockers = Array.Empty<ShockerResponse>();

OnShockersUpdated.Raise(Shockers);
}

public
Task<OneOf<Success<LcgResponse>, NotFound, DeviceOffline, DeviceNotConnectedToGateway, UnauthenticatedError>>
GetDeviceGateway(Guid deviceId, CancellationToken cancellationToken = default) =>
_client.GetDeviceGateway(deviceId, cancellationToken);
GetDeviceGateway(Guid deviceId, CancellationToken cancellationToken = default)
{
if (_client == null)
{
_logger.LogError("Client is not initialized!");
throw new Exception("Client is not initialized!");
}

return _client.GetDeviceGateway(deviceId, cancellationToken);
}

}
8 changes: 1 addition & 7 deletions ShockOsc/Cli/CliOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,8 @@

namespace OpenShock.ShockOsc.Cli;

public sealed class CliOptions
public class CliOptions
{
[Option("headless", Required = false, Default = false, HelpText = "Run the application in headless mode.")]
public required bool Headless { get; init; }

[Option('c', "console", Required = false, Default = false, HelpText = "Create console window for stdout/stderr.")]
public required bool Console { get; init; }

[Option("uri", Required = false, HelpText = "Custom URI for callbacks")]
public required string Uri { get; init; }
}
12 changes: 12 additions & 0 deletions ShockOsc/Cli/MauiCliOptions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using CommandLine;

namespace OpenShock.ShockOsc.Cli;

public sealed class MauiCliOptions : CliOptions
{
[Option('c', "console", Required = false, Default = false, HelpText = "Create console window for stdout/stderr.")]
public required bool Console { get; init; }

[Option("uri", Required = false, HelpText = "Custom URI for callbacks")]
public required string Uri { get; init; }
}
28 changes: 28 additions & 0 deletions ShockOsc/Cli/ParseHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using CommandLine;

namespace OpenShock.ShockOsc.Cli;

public static class ParseHelper
{
public static void Parse<T>(string[] args, Action<T> success)
{
var parsed = Parser.Default.ParseArguments<T>(args);
parsed.WithParsed(success);
parsed.WithNotParsed(errors =>
{
errors.Output();
Environment.Exit(1);
});
}

public static async Task ParseAsync<T>(string[] args, Func<T, Task> success)
{
var parsed = Parser.Default.ParseArguments<T>(args);
await parsed.WithParsedAsync(success);
parsed.WithNotParsed(errors =>
{
errors.Output();
Environment.Exit(1);
});
}
}
6 changes: 4 additions & 2 deletions ShockOsc/MauiProgram.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public static Microsoft.Maui.Hosting.MauiApp CreateMauiApp()
// <---- Services ---->

builder.Services.AddShockOscServices();
builder.Services.AddCommonBlazorServices();
builder.Services.AddMauiBlazorWebView();

#if WINDOWS
builder.Services.AddWindowsServices();
Expand Down Expand Up @@ -53,8 +55,8 @@ public static Microsoft.Maui.Hosting.MauiApp CreateMauiApp()
appWindow.Hide();
return;
}
if(Application.Current == null) return;

if (Application.Current == null) return;

var result = await Application.Current.MainPage!.DisplayAlert(
"Close?",
Expand Down
1 change: 1 addition & 0 deletions ShockOsc/OscChangeTracker/ChangeTrackedOscParam.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using OpenShock.ShockOsc.Services;
using Serilog;
using ILogger = Serilog.ILogger;

namespace OpenShock.ShockOsc.OscChangeTracker;

Expand Down
51 changes: 51 additions & 0 deletions ShockOsc/OscQueryLibrary/HostInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
using System.Net;
using System.Text.Json.Serialization;
using OpenShock.ShockOsc.Utils;

// ReSharper disable InconsistentNaming

namespace OpenShock.ShockOsc.OscQueryLibrary;

public sealed class HostInfo
{
[JsonPropertyName("NAME")]
public required string Name { get; set; }

[JsonPropertyName("OSC_IP")]
[JsonConverter(typeof(JsonIPAddressConverter))]
public required IPAddress OscIp { get; set; }

[JsonPropertyName("OSC_PORT")]
public required ushort OscPort { get; set; }

[JsonPropertyName("OSC_TRANSPORT")]
[JsonConverter(typeof(JsonStringEnumConverter<OscTransportType>))]
public required OscTransportType OscTransport { get; set; }

[JsonPropertyName("EXTENSIONS")]
public required ExtensionsNode Extensions { get; set; }

public enum OscTransportType
{
TCP,
UDP
}

public sealed class ExtensionsNode
{
[JsonPropertyName("ACCESS")]
public required bool Access { get; set; }

[JsonPropertyName("CLIPMODE")]
public required bool ClipMode { get; set; }

[JsonPropertyName("RANGE")]
public required bool Range { get; set; }

[JsonPropertyName("TYPE")]
public required bool Type { get; set; }

[JsonPropertyName("VALUE")]
public required bool Value { get; set; }
}
}
28 changes: 28 additions & 0 deletions ShockOsc/OscQueryLibrary/Node.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System.Text.Json.Serialization;

namespace OpenShock.ShockOsc.OscQueryLibrary;

// technically every class in the JSON is this "Node" class but that's gross
public class Node
{
[JsonPropertyOrder(-4)]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
[JsonPropertyName("DESCRIPTION")]
public string? Description { get; set; }

[JsonPropertyOrder(-3)]
[JsonPropertyName("FULL_PATH")]
public required string FullPath { get; set; }

[JsonPropertyOrder(-2)]
[JsonPropertyName("ACCESS")]
public required int Access { get; set; }
}

public class Node<T> : Node
{
[JsonPropertyOrder(-1)]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
[JsonPropertyName("CONTENTS")]
public T? Contents { get; set; }
}
Loading
Loading