Esempio n. 1
0
        public Writer(IDuplexChannel<Message> channel)
        {
            Channel = channel;

            Id = Guid.NewGuid();
            SequenceNumber = new SequenceNumber();                        
        }
Esempio n. 2
0
		public void Reply (IDuplexChannel channel, bool useTimeout)
		{
			EventsHandler.BeforeSendReply ();
			if (useTimeout && Operation.Parent.ChannelDispatcher != null) // FIXME: this condition is a workaround for NRE, there might be better way to get timeout value.
				channel.Send (ReplyMessage, Operation.Parent.ChannelDispatcher.timeouts.SendTimeout);
			else
				channel.Send (ReplyMessage);
		}
		public void Reply (IDuplexChannel channel, bool useTimeout)
		{
			EventsHandler.BeforeSendReply ();
			if (useTimeout)
				channel.Send (ReplyMessage, Operation.Parent.ChannelDispatcher.timeouts.SendTimeout);
			else
				channel.Send (ReplyMessage);
		}
Esempio n. 4
0
            public IChannelBinder Accept(TimeSpan timeout)
            {
                IDuplexChannel channel = this.listener.AcceptChannel(timeout);

                if (channel == null)
                {
                    return(null);
                }

                return(new DuplexChannelBinder(channel, this.correlator, this.listener.Uri));
            }
Esempio n. 5
0
            public async Task <IChannelBinder> AcceptAsync(CancellationToken token)
            {
                IDuplexChannel channel = await listener.AcceptChannelAsync(token);

                if (channel == null)
                {
                    return(null);
                }
                return(null);
                //return new DuplexChannelBinder(channel, correlator, listener.Uri);
            }
Esempio n. 6
0
            public IChannelBinder EndAccept(IAsyncResult result)
            {
                IDuplexChannel channel = this.listener.EndAcceptChannel(result);

                if (channel == null)
                {
                    return(null);
                }

                return(new DuplexChannelBinder(channel, this.correlator, this.listener.Uri));
            }
Esempio n. 7
0
 public void Reply(IDuplexChannel channel, bool useTimeout)
 {
     EventsHandler.BeforeSendReply();
     if (useTimeout)
     {
         channel.Send(ReplyMessage, Operation.Parent.ChannelDispatcher.timeouts.SendTimeout);
     }
     else
     {
         channel.Send(ReplyMessage);
     }
 }
 public void Reply(IDuplexChannel channel, bool useTimeout)
 {
     EventsHandler.BeforeSendReply();
     if (useTimeout && Operation.Parent.ChannelDispatcher != null)             // FIXME: this condition is a workaround for NRE, there might be better way to get timeout value.
     {
         channel.Send(ReplyMessage, Operation.Parent.ChannelDispatcher.timeouts.SendTimeout);
     }
     else
     {
         channel.Send(ReplyMessage);
     }
 }
Esempio n. 9
0
 /// <summary>
 /// Initializes a new instance of the DuplexRequestContext class
 /// </summary>
 /// <param name="request">request message</param>
 /// <param name="defaultTimeouts">default timeouts</param>
 /// <param name="innerChannel">inner channel</param>
 /// <param name="observer">indicating the broker observer</param>
 /// <param name="client">indicating the broker client</param>
 public DuplexRequestContext(Message request, IDefaultCommunicationTimeouts defaultTimeouts, IDuplexChannel innerChannel, BrokerObserver observer, BrokerClient client)
     : base(request.Version, client)
 {
     this.defaultTimeouts = defaultTimeouts;
     this.innerChannel    = innerChannel;
     this.observer        = observer;
     if (request != null)
     {
         this.messageId = request.Headers.MessageId;
         this.replyTo   = request.Headers.ReplyTo;
     }
 }
        public DurableInstanceContextDuplexChannel(ChannelManagerBase channelManger,
            ContextType contextType,
            IDuplexChannel innerChannel,
            string contextStoreLocation)
            : base(channelManger, innerChannel)
        {
            this.contextType = contextType;

            this.outputChannel = new DurableInstanceContextOutputChannel(channelManger,
                contextType, (IOutputChannel)innerChannel, contextStoreLocation);

            this.inputChannel = new DurableInstanceContextInputChannel(channelManger,
                contextType, (IInputChannel)innerChannel);
        }
        public DurableInstanceContextDuplexChannel(ChannelManagerBase channelManger,
                                                   ContextType contextType,
                                                   IDuplexChannel innerChannel,
                                                   string contextStoreLocation)
            : base(channelManger, innerChannel)
        {
            this.contextType = contextType;

            this.outputChannel = new DurableInstanceContextOutputChannel(channelManger,
                                                                         contextType, (IOutputChannel)innerChannel, contextStoreLocation);

            this.inputChannel = new DurableInstanceContextInputChannel(channelManger,
                                                                       contextType, (IInputChannel)innerChannel);
        }
Esempio n. 12
0
 public MainWindow()
 {
     InitializeComponent();
     try
     {
         binding = new NetTcpBinding(); //创建绑定
         factory = binding.BuildChannelFactory <IDuplexChannel>(new BindingParameterCollection());
         factory.Open();                //打开通道工厂
                                        //再这里创建IRequestChannel
         duplexChannel = factory.CreateChannel(new EndpointAddress("net.tcp://localhost:9090/DuplexService/Pouint2"));
         duplexChannel.Open();          //打开通道
     }
     catch (Exception ex)
     { }
 }
        public CompactSignatureSecurityDuplexChannel(
            ChannelManagerBase channelManager,
            IDuplexChannel innerChannel,
            DiscoveryVersion discoveryVersion,
            X509Certificate2 certificate,
            ReceivedCertificatesStoreSettings receivedCertificatesStoreSettings)
            : base(channelManager)
        {
            Utility.IfNullThrowNullArgumentException(innerChannel, "innerChannel");

            this.DiscoveryInfo = new ProtocolSettings(discoveryVersion);
            this.InnerChannel  = innerChannel;
            this.ReceivedCertificatesStoreSettings = receivedCertificatesStoreSettings;
            this.SigningCertificate = certificate;

            this.onInnerChannelFaulted = new EventHandler(OnInnerChannelFaulted);
            this.InnerChannel.Faulted += this.onInnerChannelFaulted;
        }
Esempio n. 14
0
        internal void Init(IDuplexChannel channel, IRequestReplyCorrelator correlator, Uri listenUri)
        {
            if (initialized)
            {
                Fx.Assert(this.channel == channel, "Wrong channel when calling Init");
                Fx.Assert(this.correlator == correlator, "Wrong channel when calling Init");
                Fx.Assert(this.listenUri == listenUri, "Wrong listenUri when calling Init");
                return;
            }

            Fx.Assert(channel != null, "caller must verify");
            Fx.Assert(correlator != null, "caller must verify");

            this.channel          = channel;
            this.listenUri        = listenUri;
            this.channel.Faulted += new EventHandler(OnFaulted);
            initialized           = true;
        }
            bool CompleteAccept(IAsyncResult result)
            {
                try
                {
                    Socket dataSocket = this.listener.listenSocket.EndAccept(result);
                    this.channel = new SizedTcpDuplexServerChannel(
                        this.listener.encoderFactory.Encoder,
                        this.listener.bufferManager,
                        new EndpointAddress(this.listener.uri),
                        dataSocket,
                        this.listener);
                }
                catch (ObjectDisposedException)
                {
                    this.channel = null;
                }

                return(true);
            }
Esempio n. 16
0
        /// <summary>
        /// Fecha um wcf channel associado a uma instancia de servico
        /// </summary>
        /// <param name="servico">instancia de um objeto criado anteriormente com Ativador.Get()</param>
        public static void AbortChannel(object servico)
        {
            try
            {
                if (servico == null)
                {
                    logger.Error("Erro em Ativador.AbortChannel(): Parametro nao pode ser nulo");
                    return;
                }

                IDuplexChannel channel2 = servico as IDuplexChannel;
                if (channel2 != null)
                {
                    logger.Info("Abort duplex channel for: " + servico.ToString());
                    channel2.Close();
                }
                else
                {
                    IChannel channel = servico as IChannel;
                    if (channel != null)
                    {
                        logger.Info("Abort channel for: " + servico.ToString());
                        try
                        {
                            channel.Close();
                        }
                        catch (Exception ex)
                        {
                            logger.Error("Erro em Ativador.AbortChannel()" + ex.Message, ex);
                            logger.Error("Trying really abort the channel");
                            channel.Abort();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                logger.Error("Erro em Ativador.AbortChannel()" + ex.Message, ex);
            }
        }
 public DuplexOutputChannel(DuplexOneWayChannelFactory factory, IDuplexChannel innerChannel) : base(factory)
 {
     this.packetRoutable = factory.packetRoutable;
     this.innerChannel   = innerChannel;
 }
		public OperationInvokerHandler (IChannel channel)
		{
			duplex = channel as IDuplexChannel;
		}
Esempio n. 19
0
        protected override IInputChannel OnEndAcceptChannel(IAsyncResult result)
        {
            IDuplexChannel innerChannel = this.innerChannelListener.EndAcceptChannel(result);

            return(this.WrapInnerChannel(innerChannel));
        }
Esempio n. 20
0
        protected override IInputChannel OnAcceptChannel(TimeSpan timeout)
        {
            IDuplexChannel innerChannel = this.innerChannelListener.AcceptChannel(timeout);

            return(this.WrapInnerChannel(innerChannel));
        }
Esempio n. 21
0
        protected override IOutputChannel OnCreateChannel(EndpointAddress address, Uri via)
        {
            IDuplexChannel channel = this.innnerFactory.CreateChannel(address, via);

            return(new DuplexOutputChannel(this, channel));
        }
Esempio n. 22
0
 public void SetUp()
 {
     _subject = new DefaultRequestHandler();
     _channel = MockRepository.GenerateMock <IDuplexChannel>();
 }
 protected override bool HasSecuritySession(IDuplexChannel channel)
 {
     return(false);
 }
Esempio n. 24
0
 public RemoteExecutor(IDuplexChannel channel, IMessageDispatcher dispatcher, IMessageFactory messageFactory)
 {
     _channel        = channel;
     _dispatcher     = dispatcher;
     _messageFactory = messageFactory;
 }
Esempio n. 25
0
        public void AssociateWith(string channelName)
        {
            var networkStream = RegisterChannel(channelName);

            AssociatedChannel = new DuplexHermesChannel(channelName, networkStream);
        }
Esempio n. 26
0
 public DuplexRequestContext(Message request, IDefaultCommunicationTimeouts defaultTimeouts, IDuplexChannel innerChannel)
 {
     this.request         = request;
     this.defaultTimeouts = defaultTimeouts;
     this.innerChannel    = innerChannel;
     if (request != null)
     {
         this.replyTo = request.Headers.ReplyTo;
     }
     this.thisLock = new object();
 }
 public DuplexChannelWrapper(ChannelManagerBase channelManager, IDuplexChannel innerChannel) : base(channelManager, innerChannel.LocalAddress)
 {
     this.innerChannel = innerChannel;
 }
Esempio n. 28
0
 public OperationInvokerHandler(IChannel channel)
 {
     duplex = channel as IDuplexChannel;
 }
Esempio n. 29
0
 public ClientDuplexReceiveMessageAndVerifySecurityAsyncResult(SecurityChannelFactory <TChannel> .SecurityDuplexChannel channel, IDuplexChannel innerChannel, TimeSpan timeout, AsyncCallback callback, object state) : base(innerChannel, timeout, callback, state)
 {
     this.channel = channel;
 }
Esempio n. 30
0
 internal DuplexRequestContext(IDuplexChannel channel, Message request, IDefaultCommunicationTimeouts timeouts)
     : base(request, timeouts.CloseTimeout, timeouts.SendTimeout)
 {
     this.channel = channel;
 }
Esempio n. 31
0
 /// <summary>
 /// Initializes a new instance of the DuplexRequestContext class
 /// </summary>
 /// <param name="request">request message</param>
 /// <param name="defaultTimeouts">default timeouts</param>
 /// <param name="innerChannel">inner channel</param>
 /// <param name="observer">indicating the broker observer</param>
 public DuplexRequestContext(Message request, IDefaultCommunicationTimeouts defaultTimeouts, IDuplexChannel innerChannel, BrokerObserver observer)
     : this(request, defaultTimeouts, innerChannel, observer, null)
 {
 }
Esempio n. 32
0
 public SecurityDuplexChannel(ChannelManagerBase factory, SecurityProtocolFactory securityProtocolFactory, IDuplexChannel innerChannel, EndpointAddress to, Uri via) : base(factory, securityProtocolFactory, innerChannel, to, via)
 {
 }
 protected override IAsyncResult BeginTryReceiveItem(IDuplexChannel channel, AsyncCallback callback, object state)
 {
     return(channel.BeginTryReceive(TimeSpan.MaxValue, callback, state));
 }
Esempio n. 34
0
 internal DuplexRequestContext(IDuplexChannel channel, Message request, DuplexChannelBinder binder)
     : base(request, binder.DefaultCloseTimeout, binder.DefaultSendTimeout)
 {
     _channel = channel;
     _binder  = binder;
 }
 protected override void EndTryReceiveItem(IDuplexChannel channel, IAsyncResult result, out Message item)
 {
     channel.EndTryReceive(result, out item);
 }