internal override IList <TransportManager> SelectTransportManagers()
        {
            //test override
            if (peerNode == null)
            {
                PeerNodeImplementation foundPeerNode = null;

                // use the private InnerNode if it has been configured and matches the channel
                if (privatePeerNode != null && this.Uri.Host == privatePeerNode.MeshId)
                {
                    foundPeerNode     = privatePeerNode;
                    this.registration = null;
                }
                else
                {
                    // find or create a InnerNode for the given Uri
                    this.registration = new PeerNodeImplementation.Registration(this.Uri, this);
                    foundPeerNode     = PeerNodeImplementation.Get(this.Uri, registration);
                }

                // ensure that the max message size is compatible
                if (foundPeerNode.MaxReceivedMessageSize < MaxReceivedMessageSize)
                {
                    foundPeerNode.Release();
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
                              new InvalidOperationException(SR.GetString(SR.PeerMaxReceivedMessageSizeConflict, MaxReceivedMessageSize, foundPeerNode.MaxReceivedMessageSize, this.Uri)));
                }

                // associate with the PeerNode and open it
                peerNode = new PeerNode(foundPeerNode);
            }

            return(null);
        }
 public OpenOperation(SimpleStateManager stateManager, PeerNodeImplementation peerNode, TimeSpan timeout,
                      AsyncCallback callback, object state, bool waitForOnline)
     : base(stateManager, timeout, callback, state)
 {
     this.peerNode      = peerNode;
     this.waitForOnline = waitForOnline;
 }
Example #3
0
        protected override TChannel OnCreateChannel(EndpointAddress to, Uri via)
        {
            base.ValidateScheme(via);

            PeerNodeImplementation peerNode = null;

            PeerNodeImplementation.Registration registration = null;

            // use the private PeerNode if it has been configured and matches the channel
            // otherwise have the channel look for one or create a new one
            if (privatePeerNode != null && via.Host == privatePeerNode.MeshId)
            {
                peerNode = privatePeerNode;
            }
            else
            {
                registration = new PeerNodeImplementation.Registration(via, this);
            }

            if (typeof(TChannel) == typeof(IOutputChannel))
            {
                return((TChannel)(object)new PeerOutputChannel(peerNode, registration, this, to, via, this.MessageVersion));
            }

            // typeof(TChannel) == typeof(IDuplexChannel)
            // 'to' is both the remote address and the local address
            PeerDuplexChannel duplexChannel = new PeerDuplexChannel(peerNode, registration, this, to, via);

            PeerMessageDispatcher <IDuplexChannel, PeerDuplexChannel> .PeerMessageQueueAdapter queueHandler = new PeerMessageDispatcher <IDuplexChannel, PeerDuplexChannel> .PeerMessageQueueAdapter(duplexChannel);

            PeerMessageDispatcher <IDuplexChannel, PeerDuplexChannel> dispatcher = new PeerMessageDispatcher <IDuplexChannel, PeerDuplexChannel>(queueHandler, duplexChannel.InnerNode, this, to, via);

            duplexChannel.Dispatcher = dispatcher;
            return((TChannel)(object)duplexChannel);
        }
        protected override TChannel OnCreateChannel(EndpointAddress to, Uri via)
        {
            base.ValidateScheme(via);
            PeerNodeImplementation peerNode = null;

            PeerNodeImplementation.Registration registration = null;
            if ((this.privatePeerNode != null) && (via.Host == this.privatePeerNode.MeshId))
            {
                peerNode = this.privatePeerNode;
            }
            else
            {
                registration = new PeerNodeImplementation.Registration(via, this);
            }
            if (typeof(TChannel) == typeof(IOutputChannel))
            {
                return((TChannel) new PeerOutputChannel(peerNode, registration, this, to, via, base.MessageVersion));
            }
            PeerDuplexChannel inputQueueChannel = new PeerDuplexChannel(peerNode, registration, this, to, via);

            PeerMessageDispatcher <IDuplexChannel, PeerDuplexChannel> .PeerMessageQueueAdapter queueHandler = new PeerMessageDispatcher <IDuplexChannel, PeerDuplexChannel> .PeerMessageQueueAdapter(inputQueueChannel);

            PeerMessageDispatcher <IDuplexChannel, PeerDuplexChannel> dispatcher = new PeerMessageDispatcher <IDuplexChannel, PeerDuplexChannel>(queueHandler, inputQueueChannel.InnerNode, this, to, via);

            inputQueueChannel.Dispatcher = dispatcher;
            return((TChannel)inputQueueChannel);
        }
Example #5
0
        public PeerInputChannelAcceptor(PeerNodeImplementation peerNode, PeerNodeImplementation.Registration registration, ChannelManagerBase channelManager, EndpointAddress localAddress, Uri via) : base(channelManager)
        {
            this.registration = registration;
            this.peerNode     = peerNode;
            this.localAddress = localAddress;
            this.via          = via;
            PeerMessageDispatcher <IInputChannel, PeerInputChannel> .PeerMessageQueueAdapter queueHandler = new PeerMessageDispatcher <IInputChannel, PeerInputChannel> .PeerMessageQueueAdapter(this);

            this.dispatcher = new PeerMessageDispatcher <IInputChannel, PeerInputChannel>(queueHandler, peerNode, base.ChannelManager, localAddress, via);
        }
Example #6
0
 public PeerInputChannel(PeerNodeImplementation peerNode, PeerNodeImplementation.Registration registration, ChannelManagerBase channelManager, EndpointAddress localAddress, Uri via) : base(channelManager, localAddress)
 {
     PeerNodeImplementation.ValidateVia(via);
     if (registration != null)
     {
         peerNode = PeerNodeImplementation.Get(via, registration);
     }
     this.peerNode = new PeerNode(peerNode);
     this.to       = localAddress;
     this.via      = via;
 }
Example #7
0
 public PeerOutputChannel(PeerNodeImplementation peerNode, PeerNodeImplementation.Registration registration, ChannelManagerBase channelManager, EndpointAddress localAddress, Uri via, MessageVersion messageVersion) : base(channelManager, localAddress, via, false, messageVersion)
 {
     PeerNodeImplementation.ValidateVia(via);
     if (registration != null)
     {
         peerNode = PeerNodeImplementation.Get(via, registration);
     }
     this.peerNode       = new PeerNode(peerNode);
     this.via            = via;
     this.channelManager = channelManager;
     this.to             = localAddress;
 }
        internal void Unregister(bool release)
        {
            PeerNodeImplementation node = this.peerNode;

            if (node != null)
            {
                if (registered)
                {
                    node.UnregisterMessageFilter(this, via);
                    registered = false;
                }
                if (release)
                {
                    node.Release();
                }
            }
        }
        public PeerMessageDispatcher(PeerMessageQueueAdapter <ChannelInterfaceType, TChannel> queueHandler, PeerNodeImplementation peerNode, ChannelManagerBase channelManager, EndpointAddress to, Uri via)
        {
            this.quotaHelper = new PeerQuotaHelper(0x7fffffff);
            PeerNodeImplementation.ValidateVia(via);
            this.queueHandler   = queueHandler;
            this.peerNode       = peerNode;
            this.to             = to;
            this.via            = via;
            this.channelManager = channelManager;
            EndpointAddress address = null;

            this.securityProtocol = ((IPeerFactory)channelManager).SecurityManager.CreateSecurityProtocol <ChannelInterfaceType>(to, ServiceDefaults.SendTimeout);
            if (typeof(IDuplexChannel).IsAssignableFrom(typeof(ChannelInterfaceType)))
            {
                address = to;
            }
            PeerMessageFilter[] filters = new PeerMessageFilter[] { new PeerMessageFilter(via, address) };
            peerNode.RegisterMessageFilter(this, this.via, filters, (ITransportFactorySettings)this.channelManager, new PeerNodeImplementation.MessageAvailableCallback(this.OnMessageAvailable), this.securityProtocol);
            this.registered = true;
        }
 internal override IList <TransportManager> SelectTransportManagers()
 {
     if (this.peerNode == null)
     {
         PeerNodeImplementation peerNode = null;
         if ((this.privatePeerNode != null) && (this.Uri.Host == this.privatePeerNode.MeshId))
         {
             peerNode          = this.privatePeerNode;
             this.registration = null;
         }
         else
         {
             this.registration = new System.ServiceModel.Channels.PeerNodeImplementation.Registration(this.Uri, this);
             peerNode          = PeerNodeImplementation.Get(this.Uri, this.registration);
         }
         if (peerNode.MaxReceivedMessageSize < this.MaxReceivedMessageSize)
         {
             peerNode.Release();
             throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("PeerMaxReceivedMessageSizeConflict", new object[] { this.MaxReceivedMessageSize, peerNode.MaxReceivedMessageSize, this.Uri })));
         }
         this.peerNode = new PeerNode(peerNode);
     }
     return(null);
 }
 public OperationBase(PeerNodeImplementation.SimpleStateManager stateManager, TimeSpan timeout, AsyncCallback callback, object state) : base(callback, state)
 {
     this.stateManager = stateManager;
     this.timeoutHelper = new TimeoutHelper(timeout);
     this.callback = callback;
     this.invokeOperation = false;
     this.completed = false;
 }
 public IPAddressChangeOperation(PeerNodeImplementation peerNode)
 {
     this.peerNode = peerNode;
 }
 public OpenOperation(PeerNodeImplementation.SimpleStateManager stateManager, PeerNodeImplementation peerNode, TimeSpan timeout, AsyncCallback callback, object state, bool waitForOnline) : base(stateManager, timeout, callback, state)
 {
     this.peerNode = peerNode;
     this.waitForOnline = waitForOnline;
 }
 public SimpleStateManager(PeerNodeImplementation peerNode)
 {
     this.peerNode = peerNode;
 }
 public CloseOperation(PeerNodeImplementation.SimpleStateManager stateManager, PeerNodeImplementation peerNode, TimeSpan timeout, AsyncCallback callback, object state) : base(stateManager, timeout, callback, state)
 {
     this.peerNode = peerNode;
 }
 public CloseOperation(SimpleStateManager stateManager,
                       PeerNodeImplementation peerNode, TimeSpan timeout, AsyncCallback callback, object state)
     : base(stateManager, timeout, callback, state)
 {
     this.peerNode = peerNode;
 }
 public PeerNodeImplementation CreatePeerNode()
 {
     PeerNodeImplementation implementation = new PeerNodeImplementation {
         ListenIPAddress = this.listenIPAddress,
         ListenUri = this.listenUri,
         MaxReceivedMessageSize = this.maxReceivedMessageSize,
         Port = this.port,
         Resolver = this.resolver,
         SecurityManager = this.securityManager
     };
     this.readerQuotas.CopyTo(implementation.readerQuotas);
     implementation.MaxBufferPoolSize = this.maxBufferPoolSize;
     return implementation;
 }
            public void CheckIfCompatible(PeerNodeImplementation peerNode, Uri via)
            {
                string mismatch = null;
                // test the settings that must be identical

                if (listenUri != peerNode.ListenUri)
                    mismatch = PeerBindingPropertyNames.ListenUri;
                else if (port != peerNode.Port)
                    mismatch = PeerBindingPropertyNames.Port;
                else if (maxReceivedMessageSize != peerNode.MaxReceivedMessageSize)
                    mismatch = PeerBindingPropertyNames.MaxReceivedMessageSize;
                else if (maxBufferPoolSize != peerNode.MaxBufferPoolSize)
                    mismatch = PeerBindingPropertyNames.MaxBufferPoolSize;
                else if (HasMismatchedReaderQuotas(peerNode.ReaderQuotas, readerQuotas, out mismatch))
                { }
                else if (resolver.GetType() != peerNode.Resolver.GetType())
                    mismatch = PeerBindingPropertyNames.Resolver;
                else if (!resolver.Equals(peerNode.Resolver))
                    mismatch = PeerBindingPropertyNames.ResolverSettings;
                else if (listenIPAddress != peerNode.ListenIPAddress)
                {
                    if ((listenIPAddress == null || peerNode.ListenIPAddress == null)
                        ||
                        (!listenIPAddress.Equals(peerNode.ListenIPAddress)))
                        mismatch = PeerBindingPropertyNames.ListenIPAddress;
                }
                else if ((securityManager == null) && (peerNode.SecurityManager != null))
                    mismatch = PeerBindingPropertyNames.Security;
                if (mismatch != null)
                    PeerExceptionHelper.ThrowInvalidOperation_PeerConflictingPeerNodeSettings(mismatch);
                securityManager.CheckIfCompatibleNodeSettings(peerNode.SecurityManager);
            }
        internal protected static bool TryGet(Uri listenUri, out PeerNodeImplementation result)
        {
            if (listenUri == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("listenUri");
            }

            if (listenUri.Scheme != PeerStrings.Scheme)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("listenUri", SR.GetString(SR.InvalidUriScheme,
                    listenUri.Scheme, PeerStrings.Scheme));
            }
            result = null;
            bool success = false;
            // build base uri
            Uri baseUri = new UriBuilder(PeerStrings.Scheme, listenUri.Host).Uri;

            lock (peerNodes)
            {
                if (peerNodes.ContainsKey(baseUri))
                {
                    result = peerNodes[baseUri];
                    success = true;
                }
            }
            return success;
        }
Example #20
0
 void OnEndCloseNode(IAsyncResult result)
 {
     PeerNodeImplementation.EndClose(result);
 }
Example #21
0
 internal PeerNode(PeerNodeImplementation peerNode)
 {
     this.innerNode = peerNode;
 }
 public IPAddressChangeOperation(PeerNodeImplementation peerNode)
 {
     this.peerNode = peerNode;
 }
 public SimpleStateManager(PeerNodeImplementation peerNode)
 {
     this.peerNode = peerNode;
 }
Example #24
0
 protected override void OnEndSend(IAsyncResult result)
 {
     PeerNodeImplementation.EndSend(result);
 }
Example #25
0
 void OnEndOpenNode(IAsyncResult result)
 {
     PeerNodeImplementation.EndOpen(result);
 }
 public static bool TryGet(string meshId, out PeerNodeImplementation result)
 {
     UriBuilder builder = new UriBuilder {
         Host = meshId,
         Scheme = "net.p2p"
     };
     return TryGet(builder.Uri, out result);
 }
 public PeerNodeImplementation CreatePeerNode()
 {
     PeerNodeImplementation peerNode = new PeerNodeImplementation();
     peerNode.ListenIPAddress = listenIPAddress;
     peerNode.ListenUri = listenUri;
     peerNode.MaxReceivedMessageSize = maxReceivedMessageSize;
     peerNode.Port = port;
     peerNode.Resolver = resolver;
     peerNode.SecurityManager = securityManager;
     this.readerQuotas.CopyTo(peerNode.readerQuotas);
     peerNode.MaxBufferPoolSize = maxBufferPoolSize;
     return peerNode;
 }
 protected internal static bool TryGet(Uri listenUri, out PeerNodeImplementation result)
 {
     if (listenUri == null)
     {
         throw System.ServiceModel.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("listenUri");
     }
     if (listenUri.Scheme != "net.p2p")
     {
         throw System.ServiceModel.DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("listenUri", System.ServiceModel.SR.GetString("InvalidUriScheme", new object[] { listenUri.Scheme, "net.p2p" }));
     }
     result = null;
     bool flag = false;
     Uri key = new UriBuilder("net.p2p", listenUri.Host).Uri;
     lock (peerNodes)
     {
         if (peerNodes.ContainsKey(key))
         {
             result = peerNodes[key];
             flag = true;
         }
     }
     return flag;
 }
 public static bool TryGet(string meshId, out PeerNodeImplementation result)
 {
     UriBuilder uriBuilder = new UriBuilder();
     uriBuilder.Host = meshId;
     uriBuilder.Scheme = PeerStrings.Scheme;
     bool success = PeerNodeImplementation.TryGet(uriBuilder.Uri, out result);
     return success;
 }
 public void CheckIfCompatible(PeerNodeImplementation peerNode, Uri via)
 {
     string result = null;
     if (this.listenUri != peerNode.ListenUri)
     {
         result = PeerBindingPropertyNames.ListenUri;
     }
     else if (this.port != peerNode.Port)
     {
         result = PeerBindingPropertyNames.Port;
     }
     else if (this.maxReceivedMessageSize != peerNode.MaxReceivedMessageSize)
     {
         result = PeerBindingPropertyNames.MaxReceivedMessageSize;
     }
     else if (this.maxBufferPoolSize != peerNode.MaxBufferPoolSize)
     {
         result = PeerBindingPropertyNames.MaxBufferPoolSize;
     }
     else if (!this.HasMismatchedReaderQuotas(peerNode.ReaderQuotas, this.readerQuotas, out result))
     {
         if (this.resolver.GetType() != peerNode.Resolver.GetType())
         {
             result = PeerBindingPropertyNames.Resolver;
         }
         else if (!this.resolver.Equals(peerNode.Resolver))
         {
             result = PeerBindingPropertyNames.ResolverSettings;
         }
         else if (this.listenIPAddress != peerNode.ListenIPAddress)
         {
             if (((this.listenIPAddress == null) || (peerNode.ListenIPAddress == null)) || !this.listenIPAddress.Equals(peerNode.ListenIPAddress))
             {
                 result = PeerBindingPropertyNames.ListenIPAddress;
             }
         }
         else if ((this.securityManager == null) && (peerNode.SecurityManager != null))
         {
             result = PeerBindingPropertyNames.Security;
         }
     }
     if (result != null)
     {
         PeerExceptionHelper.ThrowInvalidOperation_PeerConflictingPeerNodeSettings(result);
     }
     this.securityManager.CheckIfCompatibleNodeSettings(peerNode.SecurityManager);
 }