Пример #1
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);
        }
Пример #3
0
 public LocalPeerReceiver(PeerDuplexChannel owner)
 {
     this.owner = owner;
 }