Skip to content

Commit

Permalink
Change DI sig for Server and adjust helpers (#46)
Browse files Browse the repository at this point in the history
* Change DI sig for Server and adjust helpers

* Remove V1 server transport
  • Loading branch information
adamhathcock authored Jul 23, 2024
1 parent 5c7a96b commit 957a284
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 644 deletions.
12 changes: 4 additions & 8 deletions src/Speckle.Core/Api/Helpers.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
#nullable disable
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Diagnostics.Contracts;
using System.Linq;
using System.Net.Http;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Text.Json;
using System.Threading.Tasks;
using Speckle.Core.Api.GraphQL;
using Speckle.Core.Api.GraphQL.Models;
using Speckle.Core.Credentials;
Expand All @@ -36,6 +30,7 @@ public static class Helpers
/// <param name="onTotalChildrenCountKnown">Action invoked once the total count of objects is known.</param>
/// <returns></returns>
public static async Task<Base> Receive(
this IServerTransportFactory serverTransportFactory,
string stream,
Account account = null,
Action<ConcurrentDictionary<string, int>> onProgressAction = null,
Expand Down Expand Up @@ -65,7 +60,7 @@ public static async Task<Base> Receive(
}

using var client = new Client(account);
using var transport = new ServerTransport(client.Account, sw.StreamId);
using var transport = serverTransportFactory.Create(client.Account, sw.StreamId);

string objectId = "";
Commit commit = null;
Expand Down Expand Up @@ -146,6 +141,7 @@ await client
/// <param name="onProgressAction">Action invoked on progress iterations.</param>
/// <returns></returns>
public static async Task<string> Send(
this IServerTransportFactory serverTransportFactory,
string stream,
Base data,
string message = "No message",
Expand All @@ -160,7 +156,7 @@ public static async Task<string> Send(

using var client = new Client(account ?? await sw.GetAccount().ConfigureAwait(false));

using ServerTransport transport = new(client.Account, sw.StreamId);
using var transport = serverTransportFactory.Create(client.Account, sw.StreamId);
var branchName = string.IsNullOrEmpty(sw.BranchName) ? "main" : sw.BranchName;

var objectId = await Operations.Send(data, transport, useDefaultCache, onProgressAction).ConfigureAwait(false);
Expand Down
Loading

0 comments on commit 957a284

Please sign in to comment.