示例#1
0
        /// <summary>
        /// Create a proxy DistributedObject.
        /// </summary>
        protected DistributedObject(DistributedHost host, NetPeer netPeer, DistributedId id, ILocalObject localObject)
        {
            Contract.Requires(host != null);
            Contract.Requires(netPeer != null);
            Contract.Requires(localObject != null);

            Host        = host;
            OwningPeer  = netPeer;
            Id          = id;
            LocalObject = localObject;
        }
        private void OnDelete(NetPeer netPeer, DistributedId id, bool isRequest)
        {
            SerializedSocketAddress peerAddress = new SerializedSocketAddress(netPeer);

            if (isRequest)
            {
                // owner id may or may not still exist; it's OK if it doesn't.
                if (!owners.ContainsKey(id))
                {
                    // do nothing; ignore the delete request altogether
                }
                else
                {
                    // we will accept this request... for testing purposes.
                    // TBD if this is the right thing in general!
                    IDistributedObject distributedObject = owners[id];

                    // and tell all proxies
                    foreach (NetPeer proxyPeer in NetPeers)
                    {
                        distributedObject.DistributedType.SendDeleteMessageInternal(proxyPeer, false);
                    }

                    owners.Remove(id);
                    distributedObject.OnDelete();
                }
            }
            else
            {
                // this is an authoritative delete message from the owner.
                // we expect strong consistency here so the id should still exist.
                Contract.Requires(proxies[peerAddress].ContainsKey(id));

                IDistributedObject proxy = proxies[peerAddress][id];
                proxies[peerAddress].Remove(id);
                proxy.Delete();
            }
        }
 public void OnDelete(NetPeer netPeer, DistributedId id, bool isRequest)
 {
     Host.OnDelete(netPeer, id, isRequest);
 }