Skip to content

Commit

Permalink
Merge branch 'main' into update/readme-maui
Browse files Browse the repository at this point in the history
  • Loading branch information
sacOO7 authored Jul 5, 2023
2 parents c7cb15b + 701efbf commit 7bc29b8
Show file tree
Hide file tree
Showing 37 changed files with 656 additions and 61 deletions.
29 changes: 29 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,34 @@
# Change Log

## [1.2.12](https://github.com/ably/ably-dotnet/tree/1.2.12) (2023-06-29)

[Full Changelog](https://github.com/ably/ably-dotnet/compare/1.2.11...1.2.12)

**Implemented enhancements:**

- Implement incremental backoff and jitter [\#1156](https://github.com/ably/ably-dotnet/issues/1156)

**Closed issues:**

- in maui, android, getting nullreference exception when creating ablyRest and AblyRealtime in Release [\#1241](https://github.com/ably/ably-dotnet/issues/1241)
- Update git submodules to `main` branch [\#1234](https://github.com/ably/ably-dotnet/issues/1234)
- Add tests + doc for batch publish [\#1232](https://github.com/ably/ably-dotnet/issues/1232)
- Fix SDK version for unity package exporter [\#1228](https://github.com/ably/ably-dotnet/issues/1228)
- Implement RTN20C: Handle os connectivity event while `CONNECTING` [\#1218](https://github.com/ably/ably-dotnet/issues/1218)
- Update README with logging [\#1217](https://github.com/ably/ably-dotnet/issues/1217)
- Add unity specific agent header [\#1208](https://github.com/ably/ably-dotnet/issues/1208)
- Expunge references of 'ably.io' from URLs etc [\#1112](https://github.com/ably/ably-dotnet/issues/1112)

**Merged pull requests:**

- Fix README supported platforms + flaky tests [\#1236](https://github.com/ably/ably-dotnet/pull/1236) ([sacOO7](https://github.com/sacOO7))
- Update/git submodules [\#1235](https://github.com/ably/ably-dotnet/pull/1235) ([sacOO7](https://github.com/sacOO7))
- Fix ably io urls [\#1233](https://github.com/ably/ably-dotnet/pull/1233) ([sacOO7](https://github.com/sacOO7))
- Update doc+tests for batch publish [\#1230](https://github.com/ably/ably-dotnet/pull/1230) ([sacOO7](https://github.com/sacOO7))
- Handle connectivity event [\#1226](https://github.com/ably/ably-dotnet/pull/1226) ([sacOO7](https://github.com/sacOO7))
- Unity agent header [\#1220](https://github.com/ably/ably-dotnet/pull/1220) ([sacOO7](https://github.com/sacOO7))
- Add incremental backoff and jitter [\#1176](https://github.com/ably/ably-dotnet/pull/1176) ([sacOO7](https://github.com/sacOO7))

## [1.2.11](https://github.com/ably/ably-dotnet/tree/1.2.11) (2023-05-22)

[Full Changelog](https://github.com/ably/ably-dotnet/compare/1.2.10...1.2.11)
Expand Down
13 changes: 12 additions & 1 deletion build-script/build.fs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ Usage:
Options:
-t <str> Target
-v <str> Version
-d <str> Define Compilation Constant
-f <str> Target Framework Moniker (TFM)
"""

Expand All @@ -64,6 +65,11 @@ let initTargets (argv) =
| None -> ""
| Some version -> version

let compilationConstant =
match DocoptResult.tryGetArgument "-d" parsedArguments with
| None -> ""
| Some compilationConstant -> compilationConstant

let framework: string option =
match DocoptResult.tryGetArgument "-f" parsedArguments with
| None -> None
Expand Down Expand Up @@ -356,7 +362,12 @@ let initTargets (argv) =
runFrameworkTests (Method test) TestRunnerErrorLevel.Error |> ignore)

Target.create "NetStandard - Build" (fun _ ->
DotNet.build (fun opts -> { opts with Configuration = configuration }) NetStandardSolution)
DotNet.build
(fun opts ->
{ opts with
Configuration = configuration
MSBuildParams = { opts.MSBuildParams with Properties = [ "DefineConstants", compilationConstant ] } })
NetStandardSolution)

Target.create "NetStandard - Unit Tests" (fun _ -> runStandardTests UnitTests |> ignore)

Expand Down
Binary file added lib/UnityEngine.dll
Binary file not shown.
8 changes: 4 additions & 4 deletions src/CommonAssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

[assembly: AssemblyCompany("Ably")]
[assembly: AssemblyProduct("Ably .NET Library")]
[assembly: AssemblyVersion("1.2.11")]
[assembly: AssemblyFileVersion("1.2.11")]
[assembly: AssemblyVersion("1.2.12")]
[assembly: AssemblyFileVersion("1.2.12")]
namespace System {
internal static class AssemblyVersionInformation {
internal const System.String AssemblyCompany = "Ably";
internal const System.String AssemblyProduct = "Ably .NET Library";
internal const System.String AssemblyVersion = "1.2.11";
internal const System.String AssemblyFileVersion = "1.2.11";
internal const System.String AssemblyVersion = "1.2.12";
internal const System.String AssemblyFileVersion = "1.2.12";
}
}
6 changes: 6 additions & 0 deletions src/IO.Ably.NETStandard20/IO.Ably.NETStandard20.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,10 @@
<ProjectReference Include="..\..\lib\delta-codec\IO.Ably.DeltaCodec\IO.Ably.DeltaCodec.csproj" />
</ItemGroup>

<ItemGroup>
<Reference Include="UnityEngine">
<HintPath>..\..\lib\UnityEngine.dll</HintPath>
</Reference>
</ItemGroup>

</Project>
2 changes: 2 additions & 0 deletions src/IO.Ably.NETStandard20/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
[assembly: InternalsVisibleTo("IO.Ably.Push.iOS, PublicKey=002400000480000094000000060200000024000052534131000400000100010001394bb0af9eb8e04f43676c91691de20f2137847e153e27bb96cf2dedf43bce3073f699ca136fb7f9eea0d9b9c6748e9c0be5543761945e101062f8770129512c4c397a08c1b459357e7a49a4dfd7e16ac9c84d1ab3fe1177b3e7741ea10eba746433691bbf1ad643bdf25bcf397a384f96e8d138b129bdb663189200d33dcf")]
#if !PACKAGE
[assembly: InternalsVisibleTo("IO.Ably.Tests.DotNET")]
#endif
#if UNITY_PACKAGE
[assembly: InternalsVisibleTo("Unity.Assets.Tests.AblySandbox")]
[assembly: InternalsVisibleTo("Unity.Assets.Tests.EditMode")]
[assembly: InternalsVisibleTo("Unity.Assets.Tests.PlayMode")]
Expand Down
123 changes: 102 additions & 21 deletions src/IO.Ably.Shared/Agent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
using System.Collections.Generic;
using System.Runtime.InteropServices;

#if NETSTANDARD2_0_OR_GREATER && UNITY_PACKAGE
using UnityEngine; // lib/UnityEngine.dll - 2019.4.40 LTS compile time, at runtime unity player version will be used.
#endif

namespace IO.Ably
{
internal static class Agent
Expand Down Expand Up @@ -82,14 +86,80 @@ string DotnetRuntimeVersion()
dotnetRuntimeName : $"{dotnetRuntimeName}/{dotnetRuntimeVersion}";
}

// Note - MAUI OS detection requires maui specific dependencies, https://learn.microsoft.com/en-us/dotnet/maui/platform-integration/device/information?view=net-maui-7.0&tabs=windows
#if NETSTANDARD2_0_OR_GREATER && UNITY_PACKAGE
internal static string UnityPlayerIdentifier()
{
return Application.unityVersion.IsEmpty() ?
"unity" : $"unity/{Application.unityVersion}";
}

public static class UnityOS
{
public const string Windows = "unity-windows";
public const string MacOS = "unity-macOS";
public const string Linux = "unity-linux";
public const string Android = "unity-android";
public const string IOS = "unity-iOS";
public const string TvOS = "unity-tvOS";
public const string WebGL = "unity-webGL";
public const string Switch = "unity-nintendo-switch";
public const string PS4 = "unity-PS4";
public const string PS5 = "unity-PS5";
public const string Xbox = "unity-xbox";
}

internal static string UnityOsIdentifier()
{
try
{
// lib/UnityEngine.dll - 2019.4.40 LTS compile time.
// Added cases for consistent platforms for future versions of unity.
// At runtime unity player version >= 2019.x.x will be used.
switch (Application.platform)
{
case RuntimePlatform.OSXEditor:
return UnityOS.MacOS;
case RuntimePlatform.OSXPlayer:
return UnityOS.MacOS;
case RuntimePlatform.WindowsPlayer:
return UnityOS.Windows;
case RuntimePlatform.WindowsEditor:
return UnityOS.Windows;
case RuntimePlatform.IPhonePlayer:
return UnityOS.IOS;
case RuntimePlatform.Android:
return UnityOS.Android;
case RuntimePlatform.LinuxPlayer:
return UnityOS.Linux;
case RuntimePlatform.LinuxEditor:
return UnityOS.Linux;
case RuntimePlatform.WebGLPlayer:
return UnityOS.WebGL;
case RuntimePlatform.PS4:
return UnityOS.PS4;
case RuntimePlatform.XboxOne:
return UnityOS.Xbox;
case RuntimePlatform.tvOS:
return UnityOS.TvOS;
case RuntimePlatform.Switch:
return UnityOS.Switch;
case RuntimePlatform.PS5:
return UnityOS.PS5;
}
}
catch
{
// ignored, If enum case is not found for future versions of unity
}

return string.Empty;
}
#endif

internal static string OsIdentifier()
{
switch (IoC.PlatformId)
{
// For windows only dotnet-framework, return windows OS => https://dotnet.microsoft.com/en-us/download/dotnet-framework
case PlatformRuntime.Framework:
return OS.Windows;
case PlatformRuntime.XamarinAndroid:
return OS.Android;
case PlatformRuntime.XamarinIos:
Expand Down Expand Up @@ -140,9 +210,14 @@ internal static string OsIdentifier()
}
#endif

// If netstandard target is used by .Net Core App, https://mariusschulz.com/blog/detecting-the-operating-system-in-net-core
#if NETSTANDARD2_0_OR_GREATER && UNITY_PACKAGE
return UnityOsIdentifier();
#endif

#pragma warning disable CS0162 // Disable code unreachable warning when above conditional statement is true
try
{
// If netstandard target is used by .Net Core App, https://mariusschulz.com/blog/detecting-the-operating-system-in-net-core
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
return OS.Linux;
Expand All @@ -157,28 +232,29 @@ internal static string OsIdentifier()
{
return OS.Windows;
}

// If netframework/netstandard target is used by .Net Mono App, http://docs.go-mono.com/?link=P%3aSystem.Environment.OSVersion
// https://stackoverflow.com/questions/9129491/c-sharp-compiled-in-mono-detect-os
switch (Environment.OSVersion.Platform)
{
case PlatformID.Win32NT:
case PlatformID.Win32S:
case PlatformID.Win32Windows:
case PlatformID.WinCE:
return OS.Windows;
case PlatformID.Unix:
return OS.Linux;
case PlatformID.MacOSX:
return OS.MacOS;
}
}
catch
{
// ignored
}

// If netstandard target is used by .Net Mono App, http://docs.go-mono.com/?link=P%3aSystem.Environment.OSVersion
// https://stackoverflow.com/questions/9129491/c-sharp-compiled-in-mono-detect-os
switch (Environment.OSVersion.Platform)
{
case PlatformID.Win32NT:
case PlatformID.Win32S:
case PlatformID.Win32Windows:
case PlatformID.WinCE:
return OS.Windows;
case PlatformID.Unix:
return OS.Linux;
case PlatformID.MacOSX:
return OS.MacOS;
// ignored, if above code throws runtime exception for class/type/enum not found
}

return string.Empty;
#pragma warning restore CS0162
}

internal static string AblyAgentIdentifier(Dictionary<string, string> additionalAgents)
Expand All @@ -199,6 +275,11 @@ void AddAgentIdentifier(ICollection<string> currentAgentComponents, string produ
var agentComponents = new List<string>();
AddAgentIdentifier(agentComponents, AblySdkIdentifier);
AddAgentIdentifier(agentComponents, DotnetRuntimeIdentifier());

#if NETSTANDARD2_0_OR_GREATER && UNITY_PACKAGE
AddAgentIdentifier(agentComponents, UnityPlayerIdentifier());
#endif

AddAgentIdentifier(agentComponents, OsIdentifier());

if (additionalAgents == null)
Expand Down
6 changes: 5 additions & 1 deletion src/IO.Ably.Shared/ClientOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,11 @@ public bool UseBinaryProtocol
/// which used to prevent the library from initialising.
/// Default: true.
/// </summary>
#if NETSTANDARD2_0_OR_GREATER && UNITY_PACKAGE
public bool AutomaticNetworkStateMonitoring { get; set; } = false;
#else
public bool AutomaticNetworkStateMonitoring { get; set; } = true;
#endif

/// <summary>
/// Allows developers to control how often (in milliseconds) the heartbeat is checked to determine if the server
Expand Down Expand Up @@ -432,7 +436,7 @@ internal Func<DateTimeOffset> NowFunc

internal bool SkipInternetCheck { get; set; }

internal TimeSpan RealtimeRequestTimeout { get; set; } = Defaults.DefaultRealtimeTimeout;
internal TimeSpan RealtimeRequestTimeout { get; set; } = Defaults.RealtimeRequestTimeout;

/// <summary>
/// Default constructor for ClientOptions.
Expand Down
6 changes: 1 addition & 5 deletions src/IO.Ably.Shared/Defaults.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Security.Cryptography;
using System.Text;
using IO.Ably.Transport;

namespace IO.Ably
Expand Down Expand Up @@ -46,7 +42,7 @@ internal static string GetVersion()
public static readonly TimeSpan HttpMaxRetryDuration = TimeSpan.FromSeconds(15);
public static readonly TimeSpan MaxHttpRequestTimeout = TimeSpan.FromSeconds(10);
public static readonly TimeSpan MaxHttpOpenTimeout = TimeSpan.FromSeconds(4);
public static readonly TimeSpan DefaultRealtimeTimeout = TimeSpan.FromSeconds(10);
public static readonly TimeSpan RealtimeRequestTimeout = TimeSpan.FromSeconds(10);
public static readonly TimeSpan DisconnectedRetryTimeout = TimeSpan.FromSeconds(15);
public static readonly TimeSpan SuspendedRetryTimeout = TimeSpan.FromSeconds(30);
public static readonly TimeSpan ConnectionStateTtl = TimeSpan.FromSeconds(60);
Expand Down
1 change: 1 addition & 0 deletions src/IO.Ably.Shared/IO.Ably.Shared.projitems
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@
<Compile Include="$(MSBuildThisFileDirectory)Utils\ActionUtils.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Utils\ConnectionChangeAwaiter.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Utils\ErrorPolicy.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Utils\ReconnectionStrategy.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Utils\StringUtils.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Utils\TaskUtils.cs" />
</ItemGroup>
Expand Down
Loading

0 comments on commit 7bc29b8

Please sign in to comment.