Thread CultMesh trust through Unity provider discovery
This commit is contained in:
parent
758f686032
commit
ae48ea031d
4 changed files with 29 additions and 11 deletions
|
|
@ -30,8 +30,8 @@ namespace GameCult.Eve.UnityScene
|
||||||
private readonly string _providerId;
|
private readonly string _providerId;
|
||||||
private readonly string _surfaceId;
|
private readonly string _surfaceId;
|
||||||
private readonly string _runtimeId;
|
private readonly string _runtimeId;
|
||||||
|
private readonly CultMeshAuthorityTrustPolicy _authorityTrust;
|
||||||
private readonly HashSet<string> _pendingCommandIds = new HashSet<string>(StringComparer.Ordinal);
|
private readonly HashSet<string> _pendingCommandIds = new HashSet<string>(StringComparer.Ordinal);
|
||||||
private readonly HashSet<string> _publishedReceiptIds = new HashSet<string>(StringComparer.Ordinal);
|
|
||||||
private readonly Dictionary<string, Task<ReceiptSubscription>> _receiptSubscriptions =
|
private readonly Dictionary<string, Task<ReceiptSubscription>> _receiptSubscriptions =
|
||||||
new Dictionary<string, Task<ReceiptSubscription>>(StringComparer.Ordinal);
|
new Dictionary<string, Task<ReceiptSubscription>>(StringComparer.Ordinal);
|
||||||
private readonly Dictionary<string, GameObject> _prefabs = new Dictionary<string, GameObject>(StringComparer.Ordinal);
|
private readonly Dictionary<string, GameObject> _prefabs = new Dictionary<string, GameObject>(StringComparer.Ordinal);
|
||||||
|
|
@ -95,7 +95,8 @@ namespace GameCult.Eve.UnityScene
|
||||||
string providerId,
|
string providerId,
|
||||||
string surfaceId,
|
string surfaceId,
|
||||||
string runtimeId = "eve-unity",
|
string runtimeId = "eve-unity",
|
||||||
CultMeshBodyPublicationResolver? bodyResolver = null)
|
CultMeshBodyPublicationResolver? bodyResolver = null,
|
||||||
|
CultMeshAuthorityTrustPolicy? authorityTrust = null)
|
||||||
{
|
{
|
||||||
_cachePath = string.IsNullOrWhiteSpace(cachePath)
|
_cachePath = string.IsNullOrWhiteSpace(cachePath)
|
||||||
? throw new ArgumentException("Cache path must be non-empty.", nameof(cachePath))
|
? throw new ArgumentException("Cache path must be non-empty.", nameof(cachePath))
|
||||||
|
|
@ -112,6 +113,8 @@ namespace GameCult.Eve.UnityScene
|
||||||
: surfaceId.Trim();
|
: surfaceId.Trim();
|
||||||
_runtimeId = string.IsNullOrWhiteSpace(runtimeId) ? "eve-unity" : runtimeId.Trim();
|
_runtimeId = string.IsNullOrWhiteSpace(runtimeId) ? "eve-unity" : runtimeId.Trim();
|
||||||
_bodyResolver = bodyResolver;
|
_bodyResolver = bodyResolver;
|
||||||
|
_authorityTrust = authorityTrust ?? new CultMeshAuthorityTrustPolicy(
|
||||||
|
CultMeshAuthorityTrustMode.AuthenticatedRemote);
|
||||||
CurrentSurfaceDocument = EmptySurfaceDocument();
|
CurrentSurfaceDocument = EmptySurfaceDocument();
|
||||||
CurrentAssetManifestDocument = EmptyAssetManifest();
|
CurrentAssetManifestDocument = EmptyAssetManifest();
|
||||||
CurrentInputCapability = new EveInputCapabilityDocument();
|
CurrentInputCapability = new EveInputCapabilityDocument();
|
||||||
|
|
@ -459,7 +462,6 @@ namespace GameCult.Eve.UnityScene
|
||||||
lock (_pendingCommandIds)
|
lock (_pendingCommandIds)
|
||||||
{
|
{
|
||||||
_pendingCommandIds.Clear();
|
_pendingCommandIds.Clear();
|
||||||
_publishedReceiptIds.Clear();
|
|
||||||
foreach (var subscription in _receiptSubscriptions.Values)
|
foreach (var subscription in _receiptSubscriptions.Values)
|
||||||
DisposeReceiptSubscription(subscription);
|
DisposeReceiptSubscription(subscription);
|
||||||
_receiptSubscriptions.Clear();
|
_receiptSubscriptions.Clear();
|
||||||
|
|
@ -511,6 +513,7 @@ namespace GameCult.Eve.UnityScene
|
||||||
_meshClient = new CultMeshClient(new CultMeshClientOptions
|
_meshClient = new CultMeshClient(new CultMeshClientOptions
|
||||||
{
|
{
|
||||||
RendezvousEndpoints = new[] { _rendezvousEndpoint },
|
RendezvousEndpoints = new[] { _rendezvousEndpoint },
|
||||||
|
Sessions = new CultMeshSessionManagerOptions { Trust = _authorityTrust },
|
||||||
RealtimeConnectors = new ICultMeshRealtimeTransportConnector[]
|
RealtimeConnectors = new ICultMeshRealtimeTransportConnector[]
|
||||||
{
|
{
|
||||||
new CultMeshNativeQuicRealtimeTransportConnector()
|
new CultMeshNativeQuicRealtimeTransportConnector()
|
||||||
|
|
@ -1570,7 +1573,7 @@ namespace GameCult.Eve.UnityScene
|
||||||
{
|
{
|
||||||
lock (_pendingCommandIds)
|
lock (_pendingCommandIds)
|
||||||
{
|
{
|
||||||
if (!_pendingCommandIds.Contains(receipt.CommandId) || !_publishedReceiptIds.Add(receipt.ReceiptId))
|
if (!_pendingCommandIds.Remove(receipt.CommandId))
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_commandOutbox?.Acknowledge(receipt.CommandId);
|
_commandOutbox?.Acknowledge(receipt.CommandId);
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,8 @@ namespace GameCult.Eve.UnityScene
|
||||||
[FormerlySerializedAs("replicaPath")]
|
[FormerlySerializedAs("replicaPath")]
|
||||||
[SerializeField] private string cacheDirectory = "";
|
[SerializeField] private string cacheDirectory = "";
|
||||||
[SerializeField] private string runtimeId = "eve-unity";
|
[SerializeField] private string runtimeId = "eve-unity";
|
||||||
|
private CultMeshAuthorityTrustPolicy _authorityTrust = new CultMeshAuthorityTrustPolicy(
|
||||||
|
CultMeshAuthorityTrustMode.AuthenticatedRemote);
|
||||||
|
|
||||||
private EveUnityCultMeshLiveProviderTransport? _transport;
|
private EveUnityCultMeshLiveProviderTransport? _transport;
|
||||||
private EveUnitySceneLiveProviderBridge? _bridge;
|
private EveUnitySceneLiveProviderBridge? _bridge;
|
||||||
|
|
@ -87,7 +89,8 @@ namespace GameCult.Eve.UnityScene
|
||||||
string surfaceId = "",
|
string surfaceId = "",
|
||||||
string verseId = "",
|
string verseId = "",
|
||||||
string requiredSurfaceKind = "interactive-world",
|
string requiredSurfaceKind = "interactive-world",
|
||||||
string clientRuntimeId = "eve-unity")
|
string clientRuntimeId = "eve-unity",
|
||||||
|
CultMeshAuthorityTrustPolicy? authorityTrust = null)
|
||||||
{
|
{
|
||||||
if (_bridge != null || _preparation != null)
|
if (_bridge != null || _preparation != null)
|
||||||
throw new InvalidOperationException("Disconnect the active provider before changing discovery configuration.");
|
throw new InvalidOperationException("Disconnect the active provider before changing discovery configuration.");
|
||||||
|
|
@ -99,6 +102,8 @@ namespace GameCult.Eve.UnityScene
|
||||||
verseFilter = verseId ?? "";
|
verseFilter = verseId ?? "";
|
||||||
surfaceKind = string.IsNullOrWhiteSpace(requiredSurfaceKind) ? "interactive-world" : requiredSurfaceKind;
|
surfaceKind = string.IsNullOrWhiteSpace(requiredSurfaceKind) ? "interactive-world" : requiredSurfaceKind;
|
||||||
runtimeId = string.IsNullOrWhiteSpace(clientRuntimeId) ? "eve-unity" : clientRuntimeId;
|
runtimeId = string.IsNullOrWhiteSpace(clientRuntimeId) ? "eve-unity" : clientRuntimeId;
|
||||||
|
_authorityTrust = authorityTrust ?? new CultMeshAuthorityTrustPolicy(
|
||||||
|
CultMeshAuthorityTrustMode.AuthenticatedRemote);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Connect()
|
public void Connect()
|
||||||
|
|
@ -245,7 +250,7 @@ namespace GameCult.Eve.UnityScene
|
||||||
if (string.IsNullOrWhiteSpace(rendezvousEndpoint))
|
if (string.IsNullOrWhiteSpace(rendezvousEndpoint))
|
||||||
throw new InvalidOperationException("EveUnity requires a CultMesh rendezvous endpoint.");
|
throw new InvalidOperationException("EveUnity requires a CultMesh rendezvous endpoint.");
|
||||||
|
|
||||||
Selection = await new EveUnityCultMeshProviderDiscovery().DiscoverAsync(
|
Selection = await new EveUnityCultMeshProviderDiscovery(_authorityTrust).DiscoverAsync(
|
||||||
rendezvousEndpoint,
|
rendezvousEndpoint,
|
||||||
providerFilter,
|
providerFilter,
|
||||||
surfaceFilter,
|
surfaceFilter,
|
||||||
|
|
@ -264,7 +269,8 @@ namespace GameCult.Eve.UnityScene
|
||||||
Selection.AuthorityRuntimeId,
|
Selection.AuthorityRuntimeId,
|
||||||
Selection.ProviderId,
|
Selection.ProviderId,
|
||||||
Selection.SurfaceId,
|
Selection.SurfaceId,
|
||||||
runtimeId);
|
runtimeId,
|
||||||
|
authorityTrust: _authorityTrust);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await transport.PrepareAsync(cancellationToken);
|
await transport.PrepareAsync(cancellationToken);
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,14 @@ namespace GameCult.Eve.UnityScene
|
||||||
|
|
||||||
public sealed class EveUnityCultMeshProviderDiscovery
|
public sealed class EveUnityCultMeshProviderDiscovery
|
||||||
{
|
{
|
||||||
|
private readonly CultMeshAuthorityTrustPolicy _authorityTrust;
|
||||||
|
|
||||||
|
public EveUnityCultMeshProviderDiscovery(CultMeshAuthorityTrustPolicy? authorityTrust = null)
|
||||||
|
{
|
||||||
|
_authorityTrust = authorityTrust ?? new CultMeshAuthorityTrustPolicy(
|
||||||
|
CultMeshAuthorityTrustMode.AuthenticatedRemote);
|
||||||
|
}
|
||||||
|
|
||||||
public async Task<EveUnityCultMeshProviderSelection> DiscoverAsync(
|
public async Task<EveUnityCultMeshProviderSelection> DiscoverAsync(
|
||||||
string rendezvousEndpoint,
|
string rendezvousEndpoint,
|
||||||
string providerId = "",
|
string providerId = "",
|
||||||
|
|
@ -85,7 +93,8 @@ namespace GameCult.Eve.UnityScene
|
||||||
var observed = new List<string>();
|
var observed = new List<string>();
|
||||||
using var mesh = new CultMeshClient(new CultMeshClientOptions
|
using var mesh = new CultMeshClient(new CultMeshClientOptions
|
||||||
{
|
{
|
||||||
RendezvousEndpoints = new[] { rendezvousEndpoint }
|
RendezvousEndpoints = new[] { rendezvousEndpoint },
|
||||||
|
Sessions = new CultMeshSessionManagerOptions { Trust = _authorityTrust }
|
||||||
});
|
});
|
||||||
foreach (var candidate in candidates)
|
foreach (var candidate in candidates)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
{
|
{
|
||||||
"name": "org.gamecult.eve.unity-scene",
|
"name": "org.gamecult.eve.unity-scene",
|
||||||
"displayName": "Eve Unity Scene Lowering",
|
"displayName": "Eve Unity Scene Lowering",
|
||||||
"version": "0.3.109",
|
"version": "0.3.110",
|
||||||
"unity": "6000.0",
|
"unity": "6000.0",
|
||||||
"description": "Provider-agnostic Unity scene shell for gamecult.eve.surface.v1 interactive world surfaces.",
|
"description": "Provider-agnostic Unity scene shell for gamecult.eve.surface.v1 interactive world surfaces.",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"org.gamecult.cultlib": "1.0.47",
|
"org.gamecult.cultlib": "1.0.48",
|
||||||
"org.gamecult.eve.plugin-fields": "0.2.3",
|
"org.gamecult.eve.plugin-fields": "0.2.3",
|
||||||
"org.gamecult.eve.surface": "0.3.2",
|
"org.gamecult.eve.surface": "0.3.3",
|
||||||
"org.gamecult.eve.unity-uitoolkit": "0.1.4",
|
"org.gamecult.eve.unity-uitoolkit": "0.1.4",
|
||||||
"com.unity.mathematics": "1.3.2",
|
"com.unity.mathematics": "1.3.2",
|
||||||
"com.unity.render-pipelines.universal": "17.4.0",
|
"com.unity.render-pipelines.universal": "17.4.0",
|
||||||
|
|
|
||||||
Reference in a new issue