public void Destroy() { OnDestroy(); var request = ClientDestroyProxyCodec.EncodeRequest(ObjectName, ServiceName); Invoke(request); }
// internal for tests only internal async ValueTask DestroyAsync(string serviceName, string name, CancellationToken cancellationToken = default) { // regardless of whether the object was known locally, destroy on server var clientMessage = ClientDestroyProxyCodec.EncodeRequest(name, serviceName); var responseMessage = await _cluster.Messaging.SendAsync(clientMessage, cancellationToken).CfAwait(); _ = ClientDestroyProxyCodec.DecodeResponse(responseMessage); }
public void Destroy() { OnDestroy(); var request = ClientDestroyProxyCodec.EncodeRequest(_objectName, GetServiceName()); Invoke(request); _context.RemoveProxy(this); _context = null; }
/// <summary> /// Destroys a distributed object. /// </summary> /// <param name="serviceName">The service name.</param> /// <param name="name">The unique object name.</param> /// <param name="cancellationToken">A cancellation token.</param> public async ValueTask DestroyAsync(string serviceName, string name, CancellationToken cancellationToken = default) { // try to get the object - and then, dispose it var info = new DistributedObjectInfo(serviceName, name); var attempt = await _objects.TryGetAndRemoveAsync(info).CAF(); if (attempt) { await TryDispose(info, attempt.Value).CAF(); } // regardless of whether the object was known locally, destroy on server var clientMessage = ClientDestroyProxyCodec.EncodeRequest(name, serviceName); var responseMessage = await _cluster.Messaging.SendAsync(clientMessage, cancellationToken).CAF(); _ = ClientDestroyProxyCodec.DecodeResponse(responseMessage); }
/// <summary> /// Destroys a distributed object. /// </summary> /// <param name="o">The distributed object.</param> /// <param name="cancellationToken">A cancellation token.</param> public async ValueTask DestroyAsync(IDistributedObject o, CancellationToken cancellationToken = default) { // try to get the object - and then, dispose it var info = new DistributedObjectInfo(o.ServiceName, o.Name); var attempt = await _objects.TryGetAndRemoveAsync(info).CfAwait(); if (attempt) { await TryDispose(attempt.Value).CfAwait(); } var ob = (DistributedObjectBase)o; // we *know* all our objects inherit from the base object await ob.DestroyingAsync().CfAwait(); // regardless of whether the object was known locally, destroy on server var clientMessage = ClientDestroyProxyCodec.EncodeRequest(o.Name, o.ServiceName); var responseMessage = await _cluster.Messaging.SendAsync(clientMessage, cancellationToken).CfAwait(); _ = ClientDestroyProxyCodec.DecodeResponse(responseMessage); }
public void DestroyRemotely() { var clientMessage = ClientDestroyProxyCodec.EncodeRequest(Name, ServiceName); Invoke(clientMessage); }