Skip to content
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
13 changes: 13 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<Project>
<PropertyGroup Condition="$(Configuration.Contains('Server'))">
<UniScanModulePlatform>Server</UniScanModulePlatform>
</PropertyGroup>

<PropertyGroup Condition="$(Configuration.Contains('Client'))">
<UniScanModulePlatform>Client</UniScanModulePlatform>
</PropertyGroup>

<PropertyGroup Condition="$(Configuration.Contains('App'))">
<UniScanModulePlatform>App</UniScanModulePlatform>
</PropertyGroup>
</Project>
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ it up to the internet for others to listen to, and control it yourself by loggin
| [UniScan.Client.App.Platform.Desktop](src/Client/UniScan.Client.App.Platform.Desktop) | 0.0.3 | UniScan client for desktop |
| [UniScan.Client.App.Platform.iOS](src/Client/UniScan.Client.App.Platform.iOS) | 0.0.1 | UniScan client for iOS |
| [UniScan.Modules.DebugModule](src/Modules/UniScan.Modules.DebugModule) | 0.0.1 | |
| [UniScan.Modules.LibUvNetworkGroupModule](src/Modules/UniScan.Modules.LibUvNetworkGroupModule) | | |
| [UniScan.Modules.LibUvNetworkGroupModule](src/Modules/UniScan.Modules.LibUvNetworkGroupModule) | 1.0.1 | |
| [UniScan.Modules.WebSocketTransportMethod](src/Modules/UniScan.Modules.WebSocketTransportMethod) | 1.0.0 | |
| [UniScan.Audio](src/Audio/UniScan.Audio) | | |
| [UniScan.Audio.Server](src/Audio/UniScan.Audio.Server) | | |

## Credits
(in the future, these will be included in the About page.)
Expand Down
73 changes: 62 additions & 11 deletions UniScan.slnx
Original file line number Diff line number Diff line change
@@ -1,13 +1,48 @@
<Solution>
<Configurations>
<BuildType Name="Debug" />
<BuildType Name="Debug App" />
<BuildType Name="Debug Client" />
<BuildType Name="Debug Server" />
<BuildType Name="Release" />
<BuildType Name="Release App" />
<BuildType Name="Release Client" />
<BuildType Name="Release Server" />
</Configurations>
<Folder Name="/Audio/">
<Project Path="src/Audio/UniScan.Audio.Server/UniScan.Audio.Server.csproj">
<BuildType Solution="Debug|*" Project="Debug Server" />
<BuildType Solution="Release|*" Project="Release Server" />
</Project>
<Project Path="src/Audio/UniScan.Audio/UniScan.Audio.csproj" />
</Folder>
<Folder Name="/Client/">
<Project Path="src/Client/UniScan.Client.App/UniScan.Client.App.csproj" />
<Project Path="src/Client/UniScan.Client.Core/UniScan.Client.Core.csproj" />
<Project Path="src/Client/UniScan.Client.App/UniScan.Client.App.csproj">
<BuildType Solution="Debug|*" Project="Debug App" />
<BuildType Solution="Release|*" Project="Release App" />
</Project>
<Project Path="src/Client/UniScan.Client.Core/UniScan.Client.Core.csproj">
<BuildType Solution="Debug|*" Project="Debug Client" />
<BuildType Solution="Release|*" Project="Release Client" />
</Project>
</Folder>
<Folder Name="/Client/Platform/">
<Project Path="src/Client/UniScan.Client.App.Platform.Android/UniScan.Client.App.Platform.Android.csproj" />
<Project Path="src/Client/UniScan.Client.App.Platform.Browser/UniScan.Client.App.Platform.Browser.csproj" />
<Project Path="src/Client/UniScan.Client.App.Platform.Desktop/UniScan.Client.App.Platform.Desktop.csproj" />
<Project Path="src/Client/UniScan.Client.App.Platform.iOS/UniScan.Client.App.Platform.iOS.csproj" />
<Project Path="src/Client/UniScan.Client.App.Platform.Android/UniScan.Client.App.Platform.Android.csproj">
<BuildType Solution="Debug|*" Project="Debug App" />
<BuildType Solution="Release|*" Project="Release App" />
</Project>
<Project Path="src/Client/UniScan.Client.App.Platform.Browser/UniScan.Client.App.Platform.Browser.csproj">
<BuildType Solution="Debug|*" Project="Debug App" />
<BuildType Solution="Release|*" Project="Release App" />
</Project>
<Project Path="src/Client/UniScan.Client.App.Platform.Desktop/UniScan.Client.App.Platform.Desktop.csproj">
<BuildType Solution="Debug|*" Project="Debug App" />
<BuildType Solution="Release|*" Project="Release App" />
</Project>
<Project Path="src/Client/UniScan.Client.App.Platform.iOS/UniScan.Client.App.Platform.iOS.csproj">
<BuildType Solution="Debug|*" Project="Debug App" />
<BuildType Solution="Release|*" Project="Release App" />
</Project>
</Folder>
<Folder Name="/Core/">
<Project Path="src/Core/UniScan.Core/UniScan.Core.csproj" />
Expand Down Expand Up @@ -46,12 +81,19 @@
</Folder>
<Folder Name="/Modules/">
<Project Path="src/Modules/UniScan.Modules.DebugModule/UniScan.Modules.DebugModule.csproj" />
<Project Path="src/Modules/UniScan.Modules.WebSocketTransportMethod/UniScan.Modules.WebSocketTransportMethod.csproj" />
<Project Path="src\Modules\UniScan.Modules.LibUvNetworkGroupModule\UniScan.Modules.LibUvNetworkGroupModule.csproj" />
</Folder>
<Folder Name="/Network/">
<Project Path="src/Network/UniScan.Network.Client/UniScan.Network.Client.csproj" />
<Project Path="src/Network/UniScan.Network.Client/UniScan.Network.Client.csproj">
<BuildType Solution="Debug|*" Project="Debug Client" />
<BuildType Solution="Release|*" Project="Release Client" />
</Project>
<Project Path="src/Network/UniScan.Network.CodeGenerator/UniScan.Network.CodeGenerator.csproj" />
<Project Path="src/Network/UniScan.Network.Server/UniScan.Network.Server.csproj" />
<Project Path="src/Network/UniScan.Network.Server/UniScan.Network.Server.csproj">
<BuildType Solution="Debug|*" Project="Debug Server" />
<BuildType Solution="Release|*" Project="Release Server" />
</Project>
<Project Path="src/Network/UniScan.Network/UniScan.Network.csproj" />
</Folder>
<Folder Name="/Platform/">
Expand All @@ -61,9 +103,18 @@
<Project Path="src/Platform/UniScan.Platform/UniScan.Platform.csproj" />
</Folder>
<Folder Name="/Server/">
<Project Path="src/Server/UniScan.Server.Authentication/UniScan.Server.Authentication.csproj" />
<Project Path="src/Server/UniScan.Server.Core/UniScan.Server.Core.csproj" />
<Project Path="src/Server/UniScan.Server.Host/UniScan.Server.Host.csproj" />
<Project Path="src/Server/UniScan.Server.Authentication/UniScan.Server.Authentication.csproj">
<BuildType Solution="Debug|*" Project="Debug-Server" />
<BuildType Solution="Release|*" Project="Release-Server" />
</Project>
<Project Path="src/Server/UniScan.Server.Core/UniScan.Server.Core.csproj">
<BuildType Solution="Debug|*" Project="Debug Server" />
<BuildType Solution="Release|*" Project="Release Server" />
</Project>
<Project Path="src/Server/UniScan.Server.Host/UniScan.Server.Host.csproj">
<BuildType Solution="Debug|*" Project="Debug Server" />
<BuildType Solution="Release|*" Project="Release Server" />
</Project>
</Folder>
<Folder Name="/Tests/">
<Project Path="tests/UniScan.Tests/UniScan.Tests.csproj" />
Expand Down
2 changes: 1 addition & 1 deletion external/Shiki
Submodule Shiki updated from 26150a to 90eef0
65 changes: 65 additions & 0 deletions src/Audio/UniScan.Audio.Server/AudioHostSocket.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
using System.Collections.Immutable;
using DotNetty.Transport.Bootstrapping;
using DotNetty.Transport.Channels;
using Serilog;
using UniScan.Network;
using UniScan.Network.Group;
using UniScan.Network.Socket;

namespace UniScan.Audio.Server;

public class AudioHostSocket(
UniScanChannelInitializer channelInitializer,
IEnumerable<IAudioHostMethod> methods,
IHostNetworkGroupManager groupManager)
: ISocket
{
public ILogger Logger { get; } = Log.ForContext<AudioHostSocket>();

public UniScanChannelInitializer ChannelInitializer { get; } = channelInitializer;

private readonly ImmutableList<IAudioHostMethod> _hostMethods = [.. methods];
private readonly List<IChannel> _channels = [];

public async Task StartAsync()
{
if (_hostMethods.IsEmpty)
{
throw new Exception("No host methods found");
}

try
{
var task = _hostMethods.Select(async m =>
{
IChannel c = await m.BindAsync(groupManager, ChannelInitializer);
Logger.Information("Audio hosting on transport {Transport}", m.ToDisplayString());

return c;
});

_channels.AddRange(await Task.WhenAll(task));
}
catch (Exception ex)
{
Logger.Error(ex, "Failed to start audio host");
await StopAsync();
}
}

public async Task StopAsync()
{
var t = _channels.Select(c => c.CloseAsync());
await Task.WhenAll(t);

_channels.Clear();
}

public async Task<bool> SendPacketAsync(IChannel? client, IPacket packet)
{
if (client is not { Active: true }) return false;

await client.WriteAndFlushAsync(packet);
return true;
}
}
13 changes: 13 additions & 0 deletions src/Audio/UniScan.Audio.Server/IAudioHostMethod.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using DotNetty.Transport.Bootstrapping;
using DotNetty.Transport.Channels;
using UniScan.Network.Group;
using UniScan.Network.Socket;

namespace UniScan.Audio.Server;

public interface IAudioHostMethod
{
Task<IChannel> BindAsync(IHostNetworkGroupManager networkGroupManager, UniScanChannelInitializer channelInitializer);

string ToDisplayString();
}
15 changes: 15 additions & 0 deletions src/Audio/UniScan.Audio.Server/UniScan.Audio.Server.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Configurations>Debug;Release;Debug Server;Debug Client;Release Server;Release Client;Release App;Debug App</Configurations>
<Platforms>AnyCPU</Platforms>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\Network\UniScan.Network\UniScan.Network.csproj" />
</ItemGroup>

</Project>
11 changes: 11 additions & 0 deletions src/Audio/UniScan.Audio/UniScan.Audio.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Configurations>Debug;Release;Debug Server;Debug Client;Release Server;Release Client;Release App;Debug App</Configurations>
<Platforms>AnyCPU</Platforms>
</PropertyGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
<ApplicationVersion>2</ApplicationVersion>
<ApplicationDisplayVersion>$(AssemblyVersion)</ApplicationDisplayVersion>
<Description>UniScan client for Android</Description>
<Configurations>Release App;Debug App</Configurations>
<Platforms>AnyCPU</Platforms>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
<Product>UniScan Web</Product>
<AssemblyVersion>0.1.4</AssemblyVersion>
<FileVersion>0.1.4</FileVersion>
<Configurations>Release App;Debug App</Configurations>
<Platforms>AnyCPU</Platforms>
</PropertyGroup>

<ItemGroup>
Expand All @@ -39,6 +41,7 @@

<ItemGroup>
<ProjectReference Include="..\..\..\external\Shiki\src\FileSystem\Shiki.FileSystem.Implementations.Web\Shiki.FileSystem.Implementations.Web.csproj" />
<ProjectReference Include="..\..\Modules\UniScan.Modules.WebSocketTransportMethod\UniScan.Modules.WebSocketTransportMethod.csproj" />
<ProjectReference Include="..\..\Platform\UniScan.Platform.Implementations.Web\UniScan.Platform.Implementations.Web.csproj" />
<ProjectReference Include="..\UniScan.Client.App\UniScan.Client.App.csproj" AdditionalProperties="UniScanPlatform=browser" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
<AssemblyVersion>0.0.3</AssemblyVersion>
<FileVersion>0.0.3</FileVersion>
<Description>UniScan client for desktop</Description>
<Configurations>Release App;Debug App</Configurations>
<Platforms>AnyCPU</Platforms>
</PropertyGroup>

<PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<Description>UniScan client for iOS</Description>
<AssemblyVersion>0.0.1</AssemblyVersion>
<FileVersion>0.0.1</FileVersion>
<Configurations>Release App;Debug App</Configurations>
</PropertyGroup>

<ItemGroup>
Expand Down
19 changes: 19 additions & 0 deletions src/Client/UniScan.Client.App/Core/EndPointParserValidator.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System;
using System.Diagnostics.CodeAnalysis;
using UniScan.Client.App.UI.Validation;

namespace UniScan.Client.App.Core;

public abstract class EndpointValidatorParser : IValidatorParser
{
public static bool Validate([NotNullWhen(true)] string? s, IFormatProvider? provider)
{
if (string.IsNullOrWhiteSpace(s) || !Uri.TryCreate("shit://" + s, UriKind.Absolute, out Uri? uri))
return false;

if (uri.Port == 0 || string.IsNullOrWhiteSpace(uri.Host))
return false;

return uri.HostNameType is UriHostNameType.Dns or UriHostNameType.IPv4 or UriHostNameType.IPv6;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.ComponentModel.DataAnnotations;
using System.Diagnostics.CodeAnalysis;

namespace UniScan.Client.App.UI.Validation;

Expand All @@ -13,6 +14,25 @@ public class ParsableValidatorAttribute<T> : ValidationAttribute
return ValidationResult.Success;
}

return new ValidationResult(ErrorMessage);
}
}

public interface IValidatorParser
{
static abstract bool Validate([NotNullWhen(true)] string? s, IFormatProvider? provider);
}

public class ValidatorParserAttribute<TParser> : ValidationAttribute
where TParser : IValidatorParser
{
protected override ValidationResult? IsValid(object? value, ValidationContext validationContext)
{
if (value is string v && TParser.Validate(v, null))
{
return ValidationResult.Success;
}

return new ValidationResult(ErrorMessage);
}
}
5 changes: 4 additions & 1 deletion src/Client/UniScan.Client.App/UI/ViewLocator.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
using System;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using Avalonia.Controls;
using Avalonia.Controls.Templates;
using Shiki.Common.Serialization.Registry;
using Shiki.Common.Serialization.Registry.Validators;
using UniScan.Client.App.Views.ViewModel;

namespace UniScan.Client.App.UI;
Expand All @@ -23,7 +26,7 @@ public class ViewLocator : IDataTemplate
return null;

string name = param.GetType().FullName!.Replace("ControlViewModel", "Control", StringComparison.Ordinal).Replace("ViewModel", "View", StringComparison.Ordinal);
Type? type = Type.GetType(name);
Type? type = GlobalTypeRegistry<IHasNameTypeRegistryValidator<Control>>.GetScope(typeof(Control)).FirstOrDefault(kvp => kvp.Key == name).Value;

if (type != null)
{
Expand Down
2 changes: 2 additions & 0 deletions src/Client/UniScan.Client.App/UniScan.Client.App.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
<AssemblyVersion>0.1.1</AssemblyVersion>
<FileVersion>0.1.1</FileVersion>
<Description>UniScan client</Description>
<Configurations>Release App;Debug App</Configurations>
<Platforms>AnyCPU</Platforms>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Client/UniScan.Client.App/UniScanApp.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public partial class UniScanApp : Application
private static readonly UniScanPlatformAttribute? PlatformAttribute = PlatformContainingAssembly?.GetCustomAttribute<UniScanPlatformAttribute>();
private static readonly Assembly PlatformAssembly = PlatformContainingAssembly ?? typeof(UniScanApp).Assembly;

public static readonly Identifier Identifier = UniScanClient.ClientIdentifier.Derived("app");
public static readonly Identifier Identifier = UniScanClient.Identifier.Derived("app");
public static readonly SemVersion PlatformVersion = SemVersion.Parse(PlatformAssembly.InformationalVersionString);

public static readonly ClientSoftwareInfo SoftwareInfo = new(new SoftwareAssemblyInfo(Identifier, SemVersion.Parse(typeof(UniScanApp).Assembly.InformationalVersionString)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

<Grid ColumnDefinitions="*, Auto" ColumnSpacing="10" HorizontalAlignment="Stretch">
<StackPanel Spacing="5">
<TextBlock Text="IP Address" />
<TextBox Text="{Binding Address}" PlaceholderText="127.0.0.1" MaxLines="1" AcceptsReturn="False" VerticalAlignment="Center" />
<TextBlock Text="Host" />
<TextBox Text="{Binding Address}" PlaceholderText="example.com / 127.0.0.1" MaxLines="1" AcceptsReturn="False" VerticalAlignment="Center" />
</StackPanel>
<StackPanel Grid.Column="1" Spacing="5">
<TextBlock Text="Port" />
Expand Down
Loading
Loading