Skip to content

Commit

Permalink
Bump Core Deps to 2.20 (#120)
Browse files Browse the repository at this point in the history
* Bump Sdk

* Fixed compiler errors
  • Loading branch information
JR-Morgan authored Aug 8, 2024
1 parent 2da9c91 commit 9cc1c1f
Show file tree
Hide file tree
Showing 11 changed files with 614 additions and 326 deletions.
1 change: 1 addition & 0 deletions Assets/Extra/ManualReceive.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Speckle.ConnectorUnity;
using Speckle.ConnectorUnity.Components;
using Speckle.Core.Api;
using Speckle.Core.Api.GraphQL.Models;
using Speckle.Core.Credentials;
using Speckle.Core.Models;
using Speckle.Core.Transports;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Sentry;
using Speckle.Core.Api;
using Speckle.Core.Credentials;
using Speckle.Core.Kits;
Expand Down Expand Up @@ -234,18 +233,15 @@ await Client.CommitReceived(
new CommitReceivedInput
{
streamId = SelectedStream.id,
commitId = Branches[SelectedBranchIndex].commits.items[
SelectedCommitIndex
].id,
commitId = Branches[SelectedBranchIndex]
.commits
.items[SelectedCommitIndex]
.id,
message = $"received commit from {HostApplications.Unity.Name} Editor",
sourceApplication = HostApplications.Unity.Name
}
);
}
catch (Exception e)
{
throw new SpeckleException(e.Message, e, true, SentryLevel.Error);
}
finally
{
EditorApplication.delayCall += EditorUtility.ClearProgressBar;
Expand Down Expand Up @@ -384,8 +380,8 @@ public override async void OnInspectorGUI()
SelectedCommitIndex = EditorGUILayout.Popup(
"Commits",
SelectedCommitIndex,
Branches[SelectedBranchIndex].commits.items
.Select(x => $"{x.message} - {x.id}")
Branches[SelectedBranchIndex]
.commits.items.Select(x => $"{x.message} - {x.id}")
.ToArray(),
GUILayout.Height(20),
GUILayout.ExpandWidth(true)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
using Speckle.Core.Api;
using Speckle.Core.Api.SubscriptionModels;
using Speckle.Core.Credentials;
using Speckle.Core.Logging;
using Speckle.Core.Transports;
using System;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Sentry;
using Speckle.ConnectorUnity.Components;
using Speckle.ConnectorUnity.Utils;
using Speckle.Core.Api;
using Speckle.Core.Api.SubscriptionModels;
using Speckle.Core.Credentials;
using Speckle.Core.Kits;
using Speckle.Core.Logging;
using Speckle.Core.Transports;
using UnityEngine;

namespace Speckle.ConnectorUnity
Expand Down Expand Up @@ -91,23 +91,16 @@ public void Receive()

Task.Run(async () =>
{
try
{
var mainBranch = await Client.BranchGet(StreamId, BranchName, 1);
if (!mainBranch.commits.items.Any())
throw new Exception("This branch has no commits");
var commit = mainBranch.commits.items[0];
GetAndConvertObject(
commit.referencedObject,
commit.id,
commit.sourceApplication,
commit.authorId
);
}
catch (Exception e)
{
throw new SpeckleException(e.Message, e, true, SentryLevel.Error);
}
var mainBranch = await Client.BranchGet(StreamId, BranchName, 1);
if (!mainBranch.commits.items.Any())
throw new Exception("This branch has no commits");
var commit = mainBranch.commits.items[0];
GetAndConvertObject(
commit.referencedObject,
commit.id,
commit.sourceApplication,
commit.authorId
);
});
}

Expand Down Expand Up @@ -135,56 +128,46 @@ private async void GetAndConvertObject(
string authorId
)
{
try
{
var transport = new ServerTransport(Client.Account, StreamId);
var @base = await Operations.Receive(
objectId,
remoteTransport: transport,
onErrorAction: OnErrorAction,
onProgressAction: OnProgressAction,
onTotalChildrenCountKnown: OnTotalChildrenCountKnown,
disposeTransports: true
);

Analytics.TrackEvent(
Client.Account,
Analytics.Events.Receive,
new Dictionary<string, object>()
var transport = new ServerTransport(Client.Account, StreamId);
var @base = await Operations.Receive(
objectId,
remoteTransport: transport,
onErrorAction: OnErrorAction,
onProgressAction: OnProgressAction,
onTotalChildrenCountKnown: OnTotalChildrenCountKnown,
disposeTransports: true
);

Analytics.TrackEvent(
Client.Account,
Analytics.Events.Receive,
new Dictionary<string, object>()
{
{ "mode", nameof(Receiver) },
{
{ "mode", nameof(Receiver) },
{
"sourceHostApp",
HostApplications.GetHostAppFromString(sourceApplication).Slug
},
{ "sourceHostAppVersion", sourceApplication ?? "" },
{ "hostPlatform", Application.platform.ToString() },
{
"isMultiplayer",
authorId != null && authorId != Client.Account.userInfo.id
},
}
);
"sourceHostApp",
HostApplications.GetHostAppFromString(sourceApplication).Slug
},
{ "sourceHostAppVersion", sourceApplication ?? "" },
{ "hostPlatform", Application.platform.ToString() },
{ "isMultiplayer", authorId != null && authorId != Client.Account.userInfo.id },
}
);

Dispatcher
.Instance()
.Enqueue(() =>
{
var root = new GameObject() { name = commitId, };
var rc = GetComponent<RecursiveConverter>();
var go = rc.RecursivelyConvertToNative(@base, root.transform);
//remove previously received object
if (DeleteOld && ReceivedData != null)
Destroy(ReceivedData);
ReceivedData = root;
OnDataReceivedAction?.Invoke(root);
});
}
catch (Exception e)
{
throw new SpeckleException(e.Message, e, true, SentryLevel.Error);
}
Dispatcher
.Instance()
.Enqueue(() =>
{
var root = new GameObject() { name = commitId, };
var rc = GetComponent<RecursiveConverter>();
var go = rc.RecursivelyConvertToNative(@base, root.transform);
//remove previously received object
if (DeleteOld && ReceivedData != null)
Destroy(ReceivedData);
ReceivedData = root;
OnDataReceivedAction?.Invoke(root);
});

try
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
using Speckle.Core.Api;
using Speckle.Core.Credentials;
using Speckle.Core.Logging;
using Speckle.Core.Models;
using Speckle.Core.Transports;
using System;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Sentry;
using Speckle.ConnectorUnity.Components;
using Speckle.Core.Api;
using Speckle.Core.Credentials;
using Speckle.Core.Kits;
using Speckle.Core.Logging;
using Speckle.Core.Models;
using Speckle.Core.Transports;
using UnityEngine;
using UnityEngine.SceneManagement;

Expand Down Expand Up @@ -46,7 +46,6 @@ private void Awake()
/// <param name="onDataSentAction">Action to run after the data has been sent</param>
/// <param name="onProgressAction">Action to run when there is download/conversion progress</param>
/// <param name="onErrorAction">Action to run on error</param>
/// <exception cref="SpeckleException"></exception>
public void Send(
string streamId,
ISet<GameObject> gameObjects,
Expand All @@ -58,39 +57,32 @@ public void Send(
Action<string, Exception>? onErrorAction = null
)
{
try
{
CancelOperations();

cancellationTokenSource = new CancellationTokenSource();

var client = new Client(account ?? AccountManager.GetDefaultAccount()!);
transport = new ServerTransport(client.Account, streamId);
transport.CancellationToken = cancellationTokenSource.Token;

var rootObjects = SceneManager.GetActiveScene().GetRootGameObjects();

var data = converter.RecursivelyConvertToSpeckle(
rootObjects,
o => gameObjects.Contains(o)
);

SendData(
transport,
data,
client,
branchName,
createCommit,
cancellationTokenSource.Token,
onDataSentAction,
onProgressAction,
onErrorAction
);
}
catch (Exception e)
{
throw new SpeckleException(e.ToString(), e, true, SentryLevel.Error);
}
CancelOperations();

cancellationTokenSource = new CancellationTokenSource();

var client = new Client(account ?? AccountManager.GetDefaultAccount()!);
transport = new ServerTransport(client.Account, streamId);
transport.CancellationToken = cancellationTokenSource.Token;

var rootObjects = SceneManager.GetActiveScene().GetRootGameObjects();

var data = converter.RecursivelyConvertToSpeckle(
rootObjects,
o => gameObjects.Contains(o)
);

SendData(
transport,
data,
client,
branchName,
createCommit,
cancellationTokenSource.Token,
onDataSentAction,
onProgressAction,
onErrorAction
);
}

public static void SendData(
Expand Down Expand Up @@ -125,7 +117,6 @@ public static void SendData(
long count = data.GetTotalChildrenCount();
await client.CommitCreate(
cancellationToken,
new CommitCreateInput
{
streamId = remoteTransport.StreamId,
Expand All @@ -134,7 +125,8 @@ await client.CommitCreate(
message = $"Sent {count} objects from Unity",
sourceApplication = HostApplications.Unity.Name,
totalChildrenCount = (int)count,
}
},
cancellationToken
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Threading;
using System.Threading.Tasks;
using Speckle.Core.Api;
using Speckle.Core.Api.GraphQL.Models;
using Speckle.Core.Credentials;
using Speckle.Core.Logging;
using Speckle.Core.Models;
Expand Down
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit 9cc1c1f

Please sign in to comment.