Make live world proof realtime and receipt-correlated
This commit is contained in:
parent
1a27b5e041
commit
65f1534b9d
4 changed files with 143 additions and 38 deletions
|
|
@ -48,9 +48,23 @@ namespace GameCult.Eve.Surface
|
|||
{
|
||||
if (mesh == null) throw new ArgumentNullException(nameof(mesh));
|
||||
var resolved = request ?? new EveSurfaceRequest();
|
||||
var providers = await mesh.CollectionAsync<EveProviderAdvertisementDocument>(endpointId, cancellationToken)
|
||||
.ConfigureAwait(false);
|
||||
var match = Select(await providers.LatestAsync().ConfigureAwait(false), resolved);
|
||||
IReadOnlyList<EveProviderAdvertisementDocument> providerDocuments;
|
||||
if (string.IsNullOrWhiteSpace(resolved.ProviderId))
|
||||
{
|
||||
var providers = await mesh.CollectionAsync<EveProviderAdvertisementDocument>(endpointId, cancellationToken)
|
||||
.ConfigureAwait(false);
|
||||
providerDocuments = await providers.LatestAsync().ConfigureAwait(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
var provider = await mesh.DocumentAsync<EveProviderAdvertisementDocument>(
|
||||
endpointId,
|
||||
ProviderAdvertisementRecordRef(resolved.ProviderId),
|
||||
cancellationToken)
|
||||
.ConfigureAwait(false);
|
||||
providerDocuments = new[] { await provider.LatestAsync().ConfigureAwait(false) };
|
||||
}
|
||||
var match = Select(providerDocuments, resolved);
|
||||
IReadOnlyList<EvePluginAdvertisementDocument> plugins = Array.Empty<EvePluginAdvertisementDocument>();
|
||||
if (match.Surface.RequiresPlugins.Count > 0)
|
||||
{
|
||||
|
|
@ -133,5 +147,12 @@ namespace GameCult.Eve.Surface
|
|||
|
||||
private static bool Matches(string expected, string actual) =>
|
||||
string.IsNullOrWhiteSpace(expected) || string.Equals(expected, actual, StringComparison.Ordinal);
|
||||
|
||||
public static string ProviderAdvertisementRecordRef(string providerId)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(providerId))
|
||||
throw new ArgumentException("Provider id must be non-empty.", nameof(providerId));
|
||||
return $"eve:provider:{providerId.Trim()}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,6 +56,7 @@ namespace GameCult.Eve.UnityScene
|
|||
private bool _liveSubscriptionsOpen;
|
||||
private EveProviderAdvertisementDocument? _advertisement;
|
||||
private EveAdvertisedSurface? _advertisedSurface;
|
||||
private string _assetCatalogPointer = "";
|
||||
|
||||
public EveUnityCultMeshLiveProviderTransport(
|
||||
string replicaPath,
|
||||
|
|
@ -123,6 +124,8 @@ namespace GameCult.Eve.UnityScene
|
|||
PublishReceipt(receipt);
|
||||
else if (document is EveInputCapabilityDocument inputCapability)
|
||||
CurrentInputCapability = inputCapability;
|
||||
else if (document is EveAssetCatalogDocument assetCatalog)
|
||||
ApplyAssetCatalog(assetCatalog);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -274,8 +277,18 @@ namespace GameCult.Eve.UnityScene
|
|||
if (string.IsNullOrWhiteSpace(interaction.AssetManifestRecordRef))
|
||||
return;
|
||||
|
||||
var catalog = _mesh.ReadAsync<EveAssetCatalogDocument>(_endpointId, interaction.AssetManifestRecordRef)
|
||||
if (string.Equals(_assetCatalogPointer, interaction.AssetManifestRecordRef, StringComparison.Ordinal))
|
||||
return;
|
||||
|
||||
_assetCatalogPointer = interaction.AssetManifestRecordRef;
|
||||
var document = _mesh.DocumentAsync<EveAssetCatalogDocument>(_endpointId, _assetCatalogPointer)
|
||||
.GetAwaiter().GetResult();
|
||||
ApplyAssetCatalog(document.LatestAsync().GetAwaiter().GetResult());
|
||||
_liveWatches.Add(document.Watch(catalog => _liveDocuments.Enqueue(catalog)));
|
||||
}
|
||||
|
||||
private void ApplyAssetCatalog(EveAssetCatalogDocument catalog)
|
||||
{
|
||||
if (catalog == null || catalog.Version == CurrentAssetCatalogVersion)
|
||||
return;
|
||||
|
||||
|
|
|
|||
Reference in a new issue