public ICollection <IDistributedObject> GetDistributedObjects()
        {
            try
            {
                var request = ClientGetDistributedObjectsCodec.EncodeRequest();
                var task    = _client.InvocationService.InvokeOnRandomTarget(request);

                var localDistributedObjects = new HashSet <DistributedObjectInfo>();
                var distributedObjects      = GetLocalDistributedObjects();
                foreach (var localInfo in distributedObjects)
                {
                    localDistributedObjects.Add(new DistributedObjectInfo(localInfo.ServiceName, localInfo.Name));
                }

                var response = ThreadUtil.GetResult(task);
                var newDistributedObjectInfo = ClientGetDistributedObjectsCodec.DecodeResponse(response).Response;
                foreach (var distributedObjectInfo in newDistributedObjectInfo)
                {
                    localDistributedObjects.Remove(distributedObjectInfo);
                    GetOrCreateLocalProxy <IDistributedObject>(distributedObjectInfo.ServiceName, distributedObjectInfo.Name);
                }

                foreach (var distributedObjectInfo in localDistributedObjects)
                {
                    DestroyProxyLocally(distributedObjectInfo.ServiceName, distributedObjectInfo.Name);
                }
                return(GetLocalDistributedObjects());
            }
            catch (Exception e)
            {
                throw ExceptionUtil.Rethrow(e);
            }
        }
 public ICollection <IDistributedObject> GetDistributedObjects()
 {
     try
     {
         var request  = ClientGetDistributedObjectsCodec.EncodeRequest();
         var task     = invocationService.InvokeOnRandomTarget(request);
         var response = ThreadUtil.GetResult(task);
         var result   = ClientGetDistributedObjectsCodec.DecodeResponse(response).infoCollection;
         foreach (var data in result)
         {
             var o = serializationService.ToObject <DistributedObjectInfo>(data);
             GetDistributedObject <IDistributedObject>(o.GetServiceName(), o.GetName());
         }
         return(proxyManager.GetDistributedObjects());
     }
     catch (Exception e)
     {
         throw ExceptionUtil.Rethrow(e);
     }
 }
Ejemplo n.º 3
0
        public ICollection <IDistributedObject> GetDistributedObjects()
        {
            try
            {
                var request  = ClientGetDistributedObjectsCodec.EncodeRequest();
                var task     = _client.GetInvocationService().InvokeOnRandomTarget(request);
                var response = ThreadUtil.GetResult(task);
                var result   = ClientGetDistributedObjectsCodec.DecodeResponse(response).response;
                foreach (var distributedObjectInfo in result)
                {
                    var proxy = InitProxyLocal(distributedObjectInfo.ServiceName, distributedObjectInfo.ObjectName,
                                               typeof(IDistributedObject));
                    _proxies.TryAdd(distributedObjectInfo, proxy);
                }

                return(GetLocalDistributedObjects());
            }
            catch (Exception e)
            {
                throw ExceptionUtil.Rethrow(e);
            }
        }