public GrainReference CreateObjectReference(IAddressable obj, IGrainMethodInvoker invoker) { if (obj is GrainReference) { throw new ArgumentException("Argument obj is already a grain reference.", nameof(obj)); } if (obj is Grain) { throw new ArgumentException("Argument must not be a grain class.", nameof(obj)); } var observerId = ObserverGrainId.Create(this.clientId); GrainReference reference = GrainReference.NewObserverGrainReference(observerId, this.GrainReferenceRuntime); if (!localObjects.TryRegister(obj, observerId, invoker)) { throw new ArgumentException($"Failed to add new observer {reference} to localObjects collection.", "reference"); } return(reference); }
internal static IClientGatewayObserver GetObserver(IInternalGrainFactory grainFactory, ClientGrainId clientId) { var observerId = ObserverGrainId.Create(clientId, ScopedId); return(grainFactory.GetGrain <IClientGatewayObserver>(observerId.GrainId)); }
internal override ObserverGrainId GetObserverGrainId(ClientGrainId clientId) => ObserverGrainId.Create(clientId, ScopedId);