Skip to content

Commit

Permalink
Update CryptoExchange.Net version to 8.5.0, added SetOptions on clien…
Browse files Browse the repository at this point in the history
…ts, added setting of DefaultProxyCredentials to CredentialCache.DefaultCredentials on the DI http client, improved websocket disconnect detection, updated dotnet versions to 9.0
  • Loading branch information
JKorf committed Dec 23, 2024
1 parent c34f22b commit 07845bf
Show file tree
Hide file tree
Showing 12 changed files with 62 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: 8.0.x
dotnet-version: 9.0.x
- name: Set GitHub package source
run: dotnet nuget add source --username JKorf --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/JKorf/index.json"
- name: Restore dependencies
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: 8.0.x
dotnet-version: 9.0.x
- name: Set GitHub package source
run: dotnet nuget add source --username JKorf --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/JKorf/index.json"
- name: Restore dependencies
Expand Down
2 changes: 1 addition & 1 deletion HTX.Net.UnitTests/HTX.Net.UnitTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand Down
4 changes: 3 additions & 1 deletion HTX.Net.UnitTests/TestImplementations/TestSocket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace HTX.Net.UnitTests.TestImplementations
{
public class TestSocket: IWebsocket
public class TestSocket : IWebsocket
{
public bool CanConnect { get; set; } = true;
public bool Connected { get; set; }
Expand Down Expand Up @@ -120,5 +120,7 @@ public Task ReconnectAsync()
{
throw new NotImplementedException();
}

public void UpdateProxy(ApiProxy proxy) => throw new NotImplementedException();
}
}
9 changes: 9 additions & 0 deletions HTX.Net/Clients/HTXRestClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using HTX.Net.Interfaces.Clients.UsdtFuturesApi;
using HTX.Net.Clients.UsdtFutures;
using Microsoft.Extensions.Options;
using CryptoExchange.Net.Objects.Options;

namespace HTX.Net.Clients
{
Expand Down Expand Up @@ -49,6 +50,14 @@ public HTXRestClient(HttpClient? httpClient, ILoggerFactory? loggerFactory, IOpt
#endregion

#region methods

/// <inheritdoc />
public void SetOptions(UpdateOptions options)
{
SpotApi.SetOptions(options);
UsdtFuturesApi.SetOptions(options);
}

/// <summary>
/// Set the default options to be used when creating new clients
/// </summary>
Expand Down
9 changes: 9 additions & 0 deletions HTX.Net/Clients/HTXSocketClient.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using CryptoExchange.Net.Clients;
using CryptoExchange.Net.Objects.Options;
using HTX.Net.Clients.SpotApi;
using HTX.Net.Clients.UsdtFutures;
using HTX.Net.Interfaces.Clients;
Expand Down Expand Up @@ -45,6 +46,14 @@ public HTXSocketClient(IOptions<HTXSocketOptions> options, ILoggerFactory? logge
#endregion

#region methods

/// <inheritdoc />
public void SetOptions(UpdateOptions options)
{
SpotApi.SetOptions(options);
UsdtFuturesApi.SetOptions(options);
}

/// <summary>
/// Set the default options to be used when creating new clients
/// </summary>
Expand Down
1 change: 1 addition & 0 deletions HTX.Net/ExtensionMethods/ServiceCollectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ private static IServiceCollection AddHTXCore(
try
{
handler.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
handler.DefaultProxyCredentials = CredentialCache.DefaultCredentials;
}
catch (PlatformNotSupportedException)
{ }
Expand Down
2 changes: 1 addition & 1 deletion HTX.Net/HTX.Net.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="CryptoExchange.Net" Version="8.4.4" />
<PackageReference Include="CryptoExchange.Net" Version="8.5.0" />
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="9.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
18 changes: 18 additions & 0 deletions HTX.Net/HTX.Net.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
<param name="loggerFactory">The logger factory</param>
<param name="httpClient">Http client for this client</param>
</member>
<member name="M:HTX.Net.Clients.HTXRestClient.SetOptions(CryptoExchange.Net.Objects.Options.UpdateOptions)">
<inheritdoc />
</member>
<member name="M:HTX.Net.Clients.HTXRestClient.SetDefaultOptions(System.Action{HTX.Net.Objects.Options.HTXRestOptions})">
<summary>
Set the default options to be used when creating new clients
Expand Down Expand Up @@ -58,6 +61,9 @@
<param name="loggerFactory">The logger factory</param>
<param name="options">Option configuration</param>
</member>
<member name="M:HTX.Net.Clients.HTXSocketClient.SetOptions(CryptoExchange.Net.Objects.Options.UpdateOptions)">
<inheritdoc />
</member>
<member name="M:HTX.Net.Clients.HTXSocketClient.SetDefaultOptions(System.Action{HTX.Net.Objects.Options.HTXSocketOptions})">
<summary>
Set the default options to be used when creating new clients
Expand Down Expand Up @@ -3495,6 +3501,12 @@
Usdt futures endpoints
</summary>
</member>
<member name="M:HTX.Net.Interfaces.Clients.IHTXRestClient.SetOptions(CryptoExchange.Net.Objects.Options.UpdateOptions)">
<summary>
Update specific options
</summary>
<param name="options">Options to update. Only specific options are changable after the client has been created</param>
</member>
<member name="M:HTX.Net.Interfaces.Clients.IHTXRestClient.SetApiCredentials(CryptoExchange.Net.Authentication.ApiCredentials)">
<summary>
Set the API credentials for this client. All Api clients in this client will use the new credentials, regardless of earlier set options.
Expand All @@ -3516,6 +3528,12 @@
Usdt futures streams
</summary>
</member>
<member name="M:HTX.Net.Interfaces.Clients.IHTXSocketClient.SetOptions(CryptoExchange.Net.Objects.Options.UpdateOptions)">
<summary>
Update specific options
</summary>
<param name="options">Options to update. Only specific options are changable after the client has been created</param>
</member>
<member name="M:HTX.Net.Interfaces.Clients.IHTXSocketClient.SetApiCredentials(CryptoExchange.Net.Authentication.ApiCredentials)">
<summary>
Set the API credentials for this client. All Api clients in this client will use the new credentials, regardless of earlier set options.
Expand Down
9 changes: 8 additions & 1 deletion HTX.Net/Interfaces/Clients/IHTXRestClient.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using HTX.Net.Interfaces.Clients.SpotApi;
using CryptoExchange.Net.Objects.Options;
using HTX.Net.Interfaces.Clients.SpotApi;
using HTX.Net.Interfaces.Clients.UsdtFuturesApi;

namespace HTX.Net.Interfaces.Clients
Expand All @@ -17,6 +18,12 @@ public interface IHTXRestClient : IRestClient
/// </summary>
IHTXRestClientUsdtFuturesApi UsdtFuturesApi { get; }

/// <summary>
/// Update specific options
/// </summary>
/// <param name="options">Options to update. Only specific options are changable after the client has been created</param>
void SetOptions(UpdateOptions options);

/// <summary>
/// Set the API credentials for this client. All Api clients in this client will use the new credentials, regardless of earlier set options.
/// </summary>
Expand Down
9 changes: 8 additions & 1 deletion HTX.Net/Interfaces/Clients/IHTXSocketClient.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using HTX.Net.Interfaces.Clients.SpotApi;
using CryptoExchange.Net.Objects.Options;
using HTX.Net.Interfaces.Clients.SpotApi;
using HTX.Net.Interfaces.Clients.UsdtFuturesApi;

namespace HTX.Net.Interfaces.Clients
Expand All @@ -17,6 +18,12 @@ public interface IHTXSocketClient : ISocketClient
/// </summary>
public IHTXSocketClientUsdtFuturesApi UsdtFuturesApi { get; }

/// <summary>
/// Update specific options
/// </summary>
/// <param name="options">Options to update. Only specific options are changable after the client has been created</param>
void SetOptions(UpdateOptions options);

/// <summary>
/// Set the API credentials for this client. All Api clients in this client will use the new credentials, regardless of earlier set options.
/// </summary>
Expand Down
3 changes: 2 additions & 1 deletion HTX.Net/Objects/Options/HTXSocketOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ public class HTXSocketOptions : SocketExchangeOptions<HTXEnvironment>
internal static HTXSocketOptions Default { get; set; } = new HTXSocketOptions
{
Environment = HTXEnvironment.Live,
SocketSubscriptionsCombineTarget = 10
SocketSubscriptionsCombineTarget = 10,
SocketNoDataTimeout = TimeSpan.FromSeconds(30)
};

/// <summary>
Expand Down

0 comments on commit 07845bf

Please sign in to comment.