Skip to content

Commit

Permalink
适配Maui调整
Browse files Browse the repository at this point in the history
  • Loading branch information
JusterZhu committed Nov 16, 2024
1 parent 790875f commit 78bb7e2
Show file tree
Hide file tree
Showing 18 changed files with 108 additions and 184 deletions.
8 changes: 4 additions & 4 deletions src/c#/GeneralUpdate.Client/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ private static void Main(string[] args)
GeneralClientOSS.Start(paramsOSS);*/


IUpgradeHubService hub = new UpgradeHubService("http://localhost:5008/UpgradeHub", null, "GeneralUpdate");
hub.AddReceiveListener(Receive);
hub.StartAsync().Wait();
/*IUpgradeHubService hub = new UpgradeHubService("http://localhost:5008/UpgradeHub", null, "GeneralUpdate");
hub.AddListenerReceive(Receive);
hub.StartAsync().Wait();*/

Console.Read();
}

Expand Down
8 changes: 4 additions & 4 deletions src/c#/GeneralUpdate.ClientCore/Hubs/IUpgradeHubService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,25 @@ public interface IUpgradeHubService
/// Add a listener to receive upgrade information pushed from the server.
/// </summary>
/// <param name="receiveMessageCallback">string : group name , string : received message content.</param>
public void AddReceiveListener(Action<string, string> receiveMessageCallback);
public void AddListenerReceive(Action<string, string> receiveMessageCallback);

/// <summary>
/// Add a listener to receive online and offline notifications.
/// </summary>
/// <param name="onlineMessageCallback">string : Offline or online information.</param>
public void AddOnlineListener(Action<string> onlineMessageCallback);
public void AddListenerOnline(Action<string> onlineMessageCallback);

/// <summary>
/// Add a listener to receive reconnection notifications.
/// </summary>
/// <param name="reconnectedCallback">string? : Reconnection information.</param>
public void AddReconnectedListener(Func<string?, Task>? reconnectedCallback);
public void AddListenerReconnected(Func<string?, Task>? reconnectedCallback);

/// <summary>
/// Add a listener to receive disconnection notifications.
/// </summary>
/// <param name="closeCallback">Exception? : Offline exception information.</param>
public void AddClosedListener(Func<Exception?, Task> closeCallback);
public void AddListenerClosed(Func<Exception?, Task> closeCallback);

/// <summary>
/// Start subscribing to upgrade push notifications, and the content of the notifications should be agreed upon independently (it is recommended to use JSON data format).
Expand Down
8 changes: 4 additions & 4 deletions src/c#/GeneralUpdate.ClientCore/Hubs/UpgradeHubService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@ public class UpgradeHubService(string url, string? token = null, string? args =
.WithAutomaticReconnect(new RandomRetryPolicy())
.Build();

public void AddReceiveListener(Action<string, string> receiveMessageCallback)
public void AddListenerReceive(Action<string, string> receiveMessageCallback)
=> _connection?.On(ReceiveMessageflag, receiveMessageCallback);

public void AddOnlineListener(Action<string> onlineMessageCallback)
public void AddListenerOnline(Action<string> onlineMessageCallback)
=> _connection?.On(Onlineflag, onlineMessageCallback);

public void AddReconnectedListener(Func<string?, Task>? reconnectedCallback)
public void AddListenerReconnected(Func<string?, Task>? reconnectedCallback)
=> _connection!.Reconnected += reconnectedCallback;

public void AddClosedListener(Func<Exception?, Task> closeCallback)
public void AddListenerClosed(Func<Exception?, Task> closeCallback)
=> _connection!.Closed += closeCallback;

public async Task StartAsync()
Expand Down
16 changes: 16 additions & 0 deletions src/c#/GeneralUpdate.Common/Internal/Exception/OSSDownloadArgs.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System;

namespace GeneralUpdate.Common.Internal;

public class OSSDownloadArgs : EventArgs
{
public long ReadLength { get; set; }

public long TotalLength { get; set; }

public OSSDownloadArgs(long readLength, long totalLength)
{
ReadLength = readLength;
TotalLength = totalLength;
}
}
5 changes: 0 additions & 5 deletions src/c#/GeneralUpdate.Core/GeneralUpdateOSS.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
using System;
using System.Diagnostics;
using System.Text.Json;
using System.Threading.Tasks;
using GeneralUpdate.Common.AOT.JsonContext;
using GeneralUpdate.Common.Download;
using GeneralUpdate.Common.Internal;
using GeneralUpdate.Common.Internal.Event;
using GeneralUpdate.Common.Shared.Object;
using GeneralUpdate.Core.Internal;
using GeneralUpdate.Core.Strategys;

namespace GeneralUpdate.Core
Expand Down
8 changes: 0 additions & 8 deletions src/c#/GeneralUpdate.Core/Internal/OSSDownloadArgs.cs

This file was deleted.

Empty file.
Empty file.
24 changes: 0 additions & 24 deletions src/c#/GeneralUpdate.Maui.OSS/Domain/Entity/ParamsAndroid.cs

This file was deleted.

Empty file.
Empty file.
99 changes: 2 additions & 97 deletions src/c#/GeneralUpdate.Maui.OSS/GeneralUpdate.Maui.OSS.csproj
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net8.0;net8.0-maccatalyst;net8.0-android</TargetFrameworks>
<!-- Uncomment to also build the tizen app. You will need to install tizen by following this: https://github.com/Samsung/Tizen.NET -->
<!-- <TargetFrameworks>$(TargetFrameworks);net7.0-tizen</TargetFrameworks> -->
<TargetFrameworks>net8.0;net8.0-android</TargetFrameworks>
<UseMaui>true</UseMaui>
<SingleProject>true</SingleProject>
<ImplicitUsings>enable</ImplicitUsings>
<PublishReadyToRun>false</PublishReadyToRun>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">11.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">14.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">21.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>
<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'tizen'">6.5</SupportedOSPlatformVersion>
<Authors>juster.zhu</Authors>
<Description>Based on. Automatic updates for NET MAUI multiplatform.</Description>
<Copyright>Copyright © 2023</Copyright>
Expand All @@ -23,94 +15,7 @@
<RepositoryUrl>https://github.com/JusterZhu/GeneralUpdate</RepositoryUrl>
<GeneratePackageOnBuild>False</GeneratePackageOnBuild>
</PropertyGroup>

<ItemGroup>
<Compile Remove="Bootstrap\**" />
<Compile Remove="Download\**" />
<Compile Remove="Pipelines\**" />
<Compile Remove="Platforms\iOS\**" />
<Compile Remove="Platforms\MacCatalyst\**" />
<Compile Remove="Platforms\Tizen\**" />
<EmbeddedResource Remove="Bootstrap\**" />
<EmbeddedResource Remove="Download\**" />
<EmbeddedResource Remove="Pipelines\**" />
<EmbeddedResource Remove="Platforms\iOS\**" />
<EmbeddedResource Remove="Platforms\MacCatalyst\**" />
<EmbeddedResource Remove="Platforms\Tizen\**" />
<MauiCss Remove="Bootstrap\**" />
<MauiCss Remove="Download\**" />
<MauiCss Remove="Pipelines\**" />
<MauiCss Remove="Platforms\iOS\**" />
<MauiCss Remove="Platforms\MacCatalyst\**" />
<MauiCss Remove="Platforms\Tizen\**" />
<MauiXaml Remove="Bootstrap\**" />
<MauiXaml Remove="Download\**" />
<MauiXaml Remove="Pipelines\**" />
<MauiXaml Remove="Platforms\iOS\**" />
<MauiXaml Remove="Platforms\MacCatalyst\**" />
<MauiXaml Remove="Platforms\Tizen\**" />
<None Remove="Bootstrap\**" />
<None Remove="Download\**" />
<None Remove="Pipelines\**" />
<None Remove="Platforms\iOS\**" />
<None Remove="Platforms\MacCatalyst\**" />
<None Remove="Platforms\Tizen\**" />
<ProjectReference Include="..\GeneralUpdate.Common\GeneralUpdate.Common.csproj" />
</ItemGroup>

<ItemGroup>
<None Remove="ContentProvider\.gitkeep" />
<None Remove="Domain\DO\.gitkeep" />
<None Remove="Domain\Enum\.gitkeep" />
<None Remove="Domain\PO\Assembler\.gitkeep" />
</ItemGroup>

<ItemGroup>
<Compile Include="..\GeneralUpdate.Core\ContentProvider\FileNode.cs" Link="ContentProvider\FileNode.cs" />
<Compile Include="..\GeneralUpdate.Core\ContentProvider\FileProvider-Comparer.cs" Link="ContentProvider\FileProvider-Comparer.cs" />
<Compile Include="..\GeneralUpdate.Core\ContentProvider\FileProvider-Filter.cs" Link="ContentProvider\FileProvider-Filter.cs" />
<Compile Include="..\GeneralUpdate.Core\ContentProvider\FileProvider-Manage.cs" Link="ContentProvider\FileProvider-Manage.cs" />
<Compile Include="..\GeneralUpdate.Core\ContentProvider\FileProvider-Serialization.cs" Link="ContentProvider\FileProvider-Serialization.cs" />
<Compile Include="..\GeneralUpdate.Core\ContentProvider\FileProvider.cs" Link="ContentProvider\FileProvider.cs" />
<Compile Include="..\GeneralUpdate.Core\ContentProvider\FileTree.cs" Link="ContentProvider\FileTree.cs" />
<Compile Include="..\GeneralUpdate.Core\Domain\DO\Assembler\VersionAssembler.cs" Link="Domain\DO\Assembler\VersionAssembler.cs" />
<Compile Include="..\GeneralUpdate.Core\Domain\DO\VersionConfigDO.cs" Link="Domain\DO\VersionConfigDO.cs" />
<Compile Include="..\GeneralUpdate.Core\Domain\Entity\Entity.cs" Link="Domain\Entity\Entity.cs" />
<Compile Include="..\GeneralUpdate.Core\Domain\Entity\Packet.cs" Link="Domain\Entity\Packet.cs" />
<Compile Include="..\GeneralUpdate.Core\Domain\Entity\VersionInfo.cs" Link="Domain\Entity\VersionInfo.cs" />
<Compile Include="..\GeneralUpdate.Core\Domain\Enum\AppType.cs" Link="Domain\Enum\AppType.cs" />
<Compile Include="..\GeneralUpdate.Core\Domain\Enum\Format.cs" Link="Domain\Enum\Format.cs" />
<Compile Include="..\GeneralUpdate.Core\Domain\Enum\HttpStatus.cs" Link="Domain\Enum\HttpStatus.cs" />
<Compile Include="..\GeneralUpdate.Core\Domain\Enum\PlatformType.cs" Link="Domain\Enum\PlatformType.cs" />
<Compile Include="..\GeneralUpdate.Core\Domain\Enum\ProgressType.cs" Link="Domain\Enum\ProgressType.cs" />
<Compile Include="..\GeneralUpdate.Core\Domain\PO\Assembler\VersionAssembler.cs" Link="Domain\PO\Assembler\VersionAssembler.cs" />
<Compile Include="..\GeneralUpdate.Core\Domain\PO\VersionPO.cs" Link="Domain\PO\VersionPO.cs" />
<Compile Include="..\GeneralUpdate.Core\Events\CommonArgs\ExceptionEventArgs.cs" Link="Events\ExceptionEventArgs.cs" />
<Compile Include="..\GeneralUpdate.Core\Events\EventManager.cs" Link="Events\EventManager.cs" />
<Compile Include="..\GeneralUpdate.Core\Events\IEventManager.cs" Link="Events\IEventManager.cs" />
<Compile Include="..\GeneralUpdate.Core\Events\OSSArgs\OSSDownloadArgs.cs" Link="Events\OSSDownloadArgs.cs" />
</ItemGroup>

<ItemGroup>
<Folder Include="Domain\DO\Assembler\" />
<Folder Include="Domain\Enum\" />
<Folder Include="Domain\PO\Assembler\" />
<Folder Include="Domain\PO\Assembler\" />
</ItemGroup>

<ItemGroup>
<None Include="..\..\..\imgs\GeneralUpdate128.png">
<Pack>True</Pack>
<PackagePath>\</PackagePath>
</None>
</ItemGroup>

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\GeneralUpdate.Differential\GeneralUpdate.Differential.csproj" />
<ProjectReference Include="..\GeneralUpdate.Zip\GeneralUpdate.Zip.csproj" />
</ItemGroup>

</Project>
17 changes: 6 additions & 11 deletions src/c#/GeneralUpdate.Maui.OSS/GeneralUpdateOSS.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using GeneralUpdate.Core.Events;
using GeneralUpdate.Core.Events.CommonArgs;
using GeneralUpdate.Core.Events.OSSArgs;
using GeneralUpdate.Maui.OSS.Domain.Entity;
using GeneralUpdate.Common.Internal;
using GeneralUpdate.Common.Internal.Event;
using GeneralUpdate.Maui.OSS.Internal;
using GeneralUpdate.Maui.OSS.Strategys;

namespace GeneralUpdate.Maui.OSS
Expand All @@ -11,12 +10,7 @@ namespace GeneralUpdate.Maui.OSS
/// </summary>
public sealed class GeneralUpdateOSS
{
#region Constructors

private GeneralUpdateOSS()
{ }

#endregion Constructors
private GeneralUpdateOSS() { }

#region Public Methods

Expand Down Expand Up @@ -69,7 +63,8 @@ public static void AddListenerException(Action<object, ExceptionEventArgs> callb

private static void AddListener<TArgs>(Action<object, TArgs> callbackAction) where TArgs : EventArgs
{
if (callbackAction != null) EventManager.Instance.AddListener(callbackAction);
if (callbackAction != null)
EventManager.Instance.AddListener(callbackAction);
}

#endregion Private Methods
Expand Down
15 changes: 15 additions & 0 deletions src/c#/GeneralUpdate.Maui.OSS/Internal/ParamsAndroid.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
namespace GeneralUpdate.Maui.OSS.Internal
{
public class ParamsAndroid
{
public string Url { get; set; }

public string Apk { get; set; }

public string CurrentVersion { get; set; }

public string Authority { get; set; }

public string VersionFileName { get; set; }
}
}
37 changes: 37 additions & 0 deletions src/c#/GeneralUpdate.Maui.OSS/Internal/VersionInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using System.Text.Json.Serialization;

namespace GeneralUpdate.Maui.OSS.Internal
{
public class VersionInfo
{
/// <summary>
/// Update package release time.
/// </summary>
[JsonPropertyName("PubTime")]
public long PubTime { get; set; }

/// <summary>
/// Update package name.
/// </summary>
[JsonPropertyName("Name")]
public string Name { get; set; }

/// <summary>
/// Compare and verify with the downloaded update package.
/// </summary>
[JsonPropertyName("Hash")]
public string Hash { get; set; }

/// <summary>
/// The version number.
/// </summary>
[JsonPropertyName("Version")]
public string Version { get; set; }

/// <summary>
/// Remote service url address.
/// </summary>
[JsonPropertyName("Url")]
public string Url { get; set; }
}
}
Loading

0 comments on commit 78bb7e2

Please sign in to comment.