コード例 #1
0
 public HttpAcknowledgementInputChannel(IReplyChannel innerChannel,
     HttpAcknowledgementChannelListener listener, ReceiveContextSettings receiveContextSettings)
     : base(listener)
 {
     this.innerChannel = innerChannel;
     this.receiveContextSettings = receiveContextSettings;
 }
コード例 #2
0
 public ProtoBufMetaDataReplyChannel(EndpointAddress address,
                                     ChannelManagerBase parent, IReplyChannel innerChannel) :
     base(parent, innerChannel)
 {
     this._localAddress = address;
     _innerChannel = innerChannel;
 }
コード例 #3
0
 public DurableInstanceContextReplyChannel(ChannelManagerBase channelManager,
     ContextType contextType,
     IReplyChannel innerChannel)
     : base(channelManager, innerChannel)
 {
     this.contextType = contextType;
     this.innerReplyChannel = innerChannel;
 }
 internal ReplyChannelBinder(IReplyChannel channel, Uri listenUri)
 {
     if (channel == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("channel");
     }
     this.channel = channel;
     this.listenUri = listenUri;
 }
コード例 #5
0
 internal ReplyChannelBinder(IReplyChannel channel, Uri listenUri)
 {
     if (channel == null)
     {
         Fx.Assert("ReplyChannelBinder.ReplyChannelBinder: (channel != null)");
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("channel");
     }
     _channel = channel;
     _listenUri = listenUri;
 }
コード例 #6
0
ファイル: WsUdpServer.cs プロジェクト: leeholder/Netduino_SDK
 public void Start(ServerBindingContext ctx)
 {
     if (1 == Interlocked.Increment(ref m_refcount))
     {
         m_requestStop  = false;
         m_replyChannel = m_binding.CreateServerChannel(ctx);
         m_replyChannel.Open();
         m_thread = new Thread(new ThreadStart(this.Listen));
         m_thread.Start();
     }
 }
コード例 #7
0
            public async Task <IChannelBinder> AcceptAsync(CancellationToken token)
            {
                IReplyChannel channel = await listener.AcceptChannelAsync(token);

                if (channel == null)
                {
                    return(null);
                }
                return(null);
                //return new ReplyChannelBinder(channel, listener.Uri);
            }
コード例 #8
0
 private static Exception CreateReceiveRequestTimedOutException(IReplyChannel channel, TimeSpan timeout)
 {
     if (channel.LocalAddress != null)
     {
         return(new TimeoutException(SR.ReceiveRequestTimedOut(channel.LocalAddress.Uri.AbsoluteUri, timeout)));
     }
     else
     {
         return(new TimeoutException(SR.ReceiveRequestTimedOutNoLocalAddress(timeout)));
     }
 }
コード例 #9
0
            public IChannelBinder Accept(TimeSpan timeout)
            {
                IReplyChannel channel = _listener.AcceptChannel(timeout);

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

                return(new ReplyChannelBinder(channel, _listener.Uri));
            }
コード例 #10
0
            public IChannelBinder EndAccept(IAsyncResult result)
            {
                IReplyChannel channel = _listener.EndAcceptChannel(result);

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

                return(new ReplyChannelBinder(channel, _listener.Uri));
            }
コード例 #11
0
        static void RunService()
        {
            //Step1: Create a custom binding with just TCP.
            BindingElement[] bindingElements = new BindingElement[2];
            bindingElements[0] = new TextMessageEncodingBindingElement();
            bindingElements[1] = new HttpTransportBindingElement();

            CustomBinding binding = new CustomBinding(bindingElements);


            //Step2: Use the binding to build the channel listener.
            IChannelListener <IReplyChannel> listener =
                binding.BuildChannelListener <IReplyChannel>(
                    new Uri("http://localhost:8080/channelapp"),
                    new BindingParameterCollection());

            //Step3: Listening for messages.
            listener.Open();
            Console.WriteLine(
                "Listening for incoming channel connections");
            //Wait for and accept incoming connections.
            IReplyChannel channel = listener.AcceptChannel();

            Console.WriteLine("Channel accepted. Listening for messages");
            //Open the accepted channel.
            channel.Open();
            //Wait for and receive a message from the channel.
            RequestContext request = channel.ReceiveRequest();
            //Step4: Reading the request message.
            Message message = request.RequestMessage;

            Console.WriteLine("Message received");
            Console.WriteLine("Message action: {0}",
                              message.Headers.Action);
            string data = message.GetBody <string>();

            Console.WriteLine("Message content: {0}", data);
            //Send a reply.
            Message replymessage = Message.CreateMessage(
                binding.MessageVersion,
                "http://contoso.com/someotheraction",
                data);

            request.Reply(replymessage);
            //Step5: Closing objects.
            //Do not forget to close the message.
            message.Close();
            //Do not forget to close RequestContext.
            request.Close();
            //Do not forget to close channels.
            channel.Close();
            //Do not forget to close listeners.
            listener.Close();
        }
コード例 #12
0
        public void FullRequest()
        {
            EndpointIdentity identity =
                new X509CertificateEndpointIdentity(new X509Certificate2("Test/Resources/test.pfx", "mono"));
            EndpointAddress address =
                new EndpointAddress(new Uri("stream:dummy"), identity);

            Message mreq   = Message.CreateMessage(MessageVersion.Default, "myAction");
            Message mreply = null;

            XmlWriterSettings settings = new XmlWriterSettings();

            settings.Indent = true;

            // listener setup
            ReplyHandler replyHandler = delegate(Message rinput) {
                mreply = rinput;
            };
            RequestReceiver receiver = delegate() {
                return(mreq);
            };
            IChannelListener <IReplyChannel> listener = CreateListener(replyHandler, receiver);

            listener.Open();
            IReplyChannel reply = listener.AcceptChannel();

            reply.Open();

            RequestSender reqHandler = delegate(Message input) {
                try {
                    // sync version somehow causes an infinite loop (!?)
                    RequestContext ctx = reply.EndReceiveRequest(reply.BeginReceiveRequest(TimeSpan.FromSeconds(5), null, null));
//					RequestContext ctx = reply.ReceiveRequest (TimeSpan.FromSeconds (5));
                    Console.Error.WriteLine("Acquired RequestContext.");
                    ctx.Reply(input);
                } catch (Exception ex) {
                    Console.Error.WriteLine("ERROR during processing a request in FullRequest()");
                    Console.Error.WriteLine(ex);
                    Console.Error.Flush();
                    throw;
                }
                return(mreply);
            };
            CustomBinding b = CreateBinding(reqHandler);

            IRequestChannel ch = ChannelFactory <IRequestChannel> .CreateChannel(b, address);

            ch.Open();
            Console.Error.WriteLine("**** starting a request  ****");
            IAsyncResult async = ch.BeginRequest(mreq, null, null);

            Console.Error.WriteLine("**** request started. ****");
            Message res = ch.EndRequest(async);
        }
コード例 #13
0
        public void AcceptChannel_Returns_Null_If_Inner_Listener_Returns_Null()
        {
            MockChannelListener innerListener           = new MockChannelListener(true /* return null channel */);
            HttpMessageEncodingChannelListener listener = new HttpMessageEncodingChannelListener(innerListener);

            listener.Open();

            IReplyChannel replyChannel = listener.AcceptChannel();

            Assert.IsNull(replyChannel, "HttpMessageEncodingChannelListener.AcceptChannel should have returned null since the inner listener returned null.");
        }
コード例 #14
0
        protected override TChannel OnEndAcceptChannel(IAsyncResult result)
        {
            this.Print("OnEndAcceptChannel()");
            IReplyChannel innerChannel = (IReplyChannel)this.InnerChannelListener.EndAcceptChannel(result);

            if (null != innerChannel)
            {
                return(new SimpleReplyChannel(this, innerChannel) as TChannel);
            }
            return(null);
        }
コード例 #15
0
        protected override TChannel OnAcceptChannel(TimeSpan timeout)
        {
            this.Print("OnAcceptChannel()");
            IReplyChannel innerChannel = (IReplyChannel)this.InnerChannelListener.AcceptChannel(timeout);

            if (null != innerChannel)
            {
                return(new SimpleReplyChannel(this, innerChannel) as TChannel);
            }
            return(null);
        }
コード例 #16
0
                protected ReceiveAsyncResultBase(IReplyChannel innerChannel, TimeSpan timeout, bool validateHeader, AsyncCallback callback, object state) : base(callback, state)
                {
                    this.innerChannel   = innerChannel;
                    this.timeoutHelper  = new TimeoutHelper(timeout);
                    this.validateHeader = validateHeader;
                    IAsyncResult result = this.OnBeginReceiveRequest(this.timeoutHelper.RemainingTime(), onReceiveRequest, this);

                    if (result.CompletedSynchronously && this.HandleReceiveRequestComplete(result))
                    {
                        base.Complete(true);
                    }
                }
コード例 #17
0
ファイル: WsUdpServer.cs プロジェクト: leeholder/Netduino_SDK
        // private
        private WsUdpServiceHost()
        {
            m_threadManager    = new WsThreadManager(5, "Udp");
            m_serviceEndpoints = new WsServiceEndpoints();
            m_refcount         = 0;
            m_binding          = null;
            m_replyChannel     = null;

            UdpTransportBindingElement transport = new UdpTransportBindingElement(new UdpTransportBindingConfig(WsDiscovery.WsDiscoveryAddress, WsDiscovery.WsDiscoveryPort, m_ignoreLocalRequests));

            m_binding = new CustomBinding(transport);
        }
コード例 #18
0
            public HelpReceiveRequestAsyncResult(IReplyChannel channel, TimeSpan timeout, AsyncCallback callback, object state) : base(callback, state)
            {
                this.channel = channel;
                this.timeout = timeout;
                IAsyncResult result = channel.BeginTryReceiveRequest(timeout, onReceiveRequest, this);

                if (result.CompletedSynchronously)
                {
                    this.HandleReceiveRequestComplete(result);
                    base.Complete(true);
                }
            }
コード例 #19
0
        public IChannelListenerPage()
        {
            InitializeComponent();
            ///监听者
            IChannelListener <IReplyChannel> listener = binding.BuildChannelListener <IReplyChannel>(new Uri("http://localhost:9090/RequestReplyService"), new BindingParameterCollection());

            listener.Open();//打开
            //创建IReplyChannel
            IReplyChannel replyChannel = listener.AcceptChannel();

            replyChannel.Open();//打开IReplyChannel应答通道
        }
コード例 #20
0
        public void AcceptChannel_Returns_HttpMessageEncodingReplyChannel()
        {
            MockChannelListener innerListener           = new MockChannelListener();
            HttpMessageEncodingChannelListener listener = new HttpMessageEncodingChannelListener(innerListener);

            listener.Open();

            IReplyChannel replyChannel = listener.AcceptChannel();

            Assert.IsNotNull(replyChannel, "HttpMessageEncodingChannelListener.AcceptChannel should not have returned null.");
            Assert.IsInstanceOfType(replyChannel, typeof(HttpMessageEncodingReplyChannel), "HttpMessageEncodingChannelListener.AcceptChannel should have returned an HttpMessageEncodingReplyChannel.");
        }
コード例 #21
0
        protected override void OnOpen(TimeSpan timeout)
        {
            // Because the inner listener is a Datagram (singleton) listener, we
            // accept the singleton channel and then dispose of the listener because
            // the lifetimes are decoupled.
            TimeoutHelper timeoutHelper = new TimeoutHelper(timeout);

            this.innerChannelListener.Open(timeoutHelper.RemainingTime());
            this.innerChannel = this.innerChannelListener.AcceptChannel(timeoutHelper.RemainingTime());
            this.innerChannel.Open(timeoutHelper.RemainingTime());
            this.innerChannelListener.Close(timeoutHelper.RemainingTime());
        }
コード例 #22
0
ファイル: WsUdpServer.cs プロジェクト: awakegod/NETMF-LPC
        // private
        private WsUdpServiceHost()
        {
            m_threadManager     = new WsThreadManager(5, "Udp");
            m_serviceEndpoints  = new WsServiceEndpoints();
            m_refcount          = 0;
            m_binding           = null;
            m_replyChannel      = null;

            UdpTransportBindingElement transport = new UdpTransportBindingElement(new UdpTransportBindingConfig(WsDiscovery.WsDiscoveryAddress, WsDiscovery.WsDiscoveryPort, m_ignoreLocalRequests));

            m_binding = new CustomBinding(transport);
        }
コード例 #23
0
	static void RunListener (IReplyChannel reply)
	{
		if (!reply.WaitForRequest (TimeSpan.FromSeconds (10))) {
			Console.WriteLine ("No request reached here.");
			return;
		}
		Console.WriteLine ("Receiving request ...");
		RequestContext ctx = reply.ReceiveRequest ();
		if (ctx == null)
			return;
		Console.WriteLine ("Starting reply ...");
		ctx.Reply (Message.CreateMessage (MessageVersion.Default, "Ack"));
	}
コード例 #24
0
        private static Exception CreateReceiveRequestTimedOutException(IReplyChannel channel, TimeSpan timeout)
        {
            if (channel.LocalAddress == null)
            {
                string   receiveRequestTimedOutNoLocalAddress = Resources.ReceiveRequestTimedOutNoLocalAddress;
                object[] objArray = new object[] { timeout };
                return(new TimeoutException(Microsoft.ServiceBus.SR.GetString(receiveRequestTimedOutNoLocalAddress, objArray)));
            }
            string receiveRequestTimedOut = Resources.ReceiveRequestTimedOut;

            object[] absoluteUri = new object[] { channel.LocalAddress.Uri.AbsoluteUri, timeout };
            return(new TimeoutException(Microsoft.ServiceBus.SR.GetString(receiveRequestTimedOut, absoluteUri)));
        }
コード例 #25
0
        private static RequestContext HelpReceiveRequest(IReplyChannel channel, TimeSpan timeout)
        {
            RequestContext requestContext;

            if (channel.TryReceiveRequest(timeout, out requestContext))
            {
                return(requestContext);
            }
            else
            {
                throw FxTrace.Exception.AsError(UdpReplyChannel.CreateReceiveRequestTimedOutException(channel, timeout));
            }
        }
コード例 #26
0
            public HelpReceiveRequestAsyncResult(IReplyChannel channel, TimeSpan timeout, AsyncCallback callback, object state) : base(callback, state)
            {
                this.channel = channel;
                this.timeout = timeout;
                IAsyncResult asyncResult = channel.BeginTryReceiveRequest(timeout, Microsoft.ServiceBus.Channels.ReplyChannel.HelpReceiveRequestAsyncResult.onReceiveRequest, this);

                if (!asyncResult.CompletedSynchronously)
                {
                    return;
                }
                this.HandleReceiveRequestComplete(asyncResult);
                base.Complete(true);
            }
コード例 #27
0
        public void AcceptChannel_Calls_The_Inner_Listener_With_Timeout()
        {
            MockChannelListener innerListener           = new MockChannelListener();
            HttpMessageEncodingChannelListener listener = new HttpMessageEncodingChannelListener(innerListener);

            listener.Open();

            TimeSpan      timeout      = new TimeSpan(0, 2, 0);
            IReplyChannel replyChannel = listener.AcceptChannel(timeout);

            Assert.IsTrue(innerListener.OnAcceptChannelCalled, "HttpMessageEncodingChannelListener.AcceptChannel should have called AcceptChannel on the inner listener.");
            Assert.AreEqual(innerListener.TimeoutParameter, timeout, "HttpMessageEncodingChannelListener.AcceptChannel should have passed along the same timeout instance to the inner listener.");
        }
コード例 #28
0
        internal static RequestContext HelpReceiveRequest(IReplyChannel channel, TimeSpan timeout)
        {
            RequestContext requestContext;

            if (channel.TryReceiveRequest(timeout, out requestContext))
            {
                return(requestContext);
            }
            else
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
                          ReplyChannel.CreateReceiveRequestTimedOutException(channel, timeout));
            }
        }
コード例 #29
0
        static void Main(string[] args)
        {
            try
            {
                //建立和发送端相同的通道栈
                BindingElement[] bindingElements = new BindingElement[2];
                bindingElements[0] = new TextMessageEncodingBindingElement();
                bindingElements[1] = new HttpTransportBindingElement();
                CustomBinding binding = new CustomBinding(bindingElements);

                //建立ChannelListener
                IChannelListener <IReplyChannel> listener = binding.BuildChannelListener <IReplyChannel>(
                    new Uri("http://localhost:9090/RequestReplyService"),
                    new BindingParameterCollection());
                listener.Open();       //打开监听

                //创建IReplyChannel
                IReplyChannel replyChannel = listener.AcceptChannel();
                replyChannel.Open();   //打开通道

                Console.WriteLine("开始接收消息");

                //接收并打印消息
                RequestContext requestContext = replyChannel.ReceiveRequest();     //会堵塞在这里

                Console.WriteLine("接收到一条消息, action为{0}, body为{1}",
                                  requestContext.RequestMessage.Headers.Action,
                                  requestContext.RequestMessage.GetBody <string>());

                //创建返回消息
                Message response = Message.CreateMessage(binding.MessageVersion, "response", "response body");

                //发送返回消息
                requestContext.Reply(response);

                requestContext.Close();
                replyChannel.Close();
                listener.Close();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
            finally
            {
                Console.WriteLine("Press any key to exit...");
                Console.ReadKey();
            }
        }
コード例 #30
0
ファイル: ReplyChannel.cs プロジェクト: zheng1748/CoreWCF
        internal static async Task <RequestContext> HelpReceiveRequestAsync(IReplyChannel channel, CancellationToken token)
        {
            var result = await channel.TryReceiveRequestAsync(token);

            if (result.Success)
            {
                return(result.Result);
            }
            else
            {
                // TODO: Fix timeout value
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
                          ReplyChannel.CreateReceiveRequestTimedOutException(channel, TimeSpan.Zero));
            }
        }
コード例 #31
0
        void OnReceive(IAsyncResult result)
        {
            if (result.CompletedSynchronously)
            {
                return;
            }

            IReplyChannel  channel = (IReplyChannel)result.AsyncState;
            RequestContext context = channel.EndReceiveRequest(result);

            if (HandleRequest(channel, context))
            {
                ReceiveRequest(channel);
            }
        }
コード例 #32
0
        public void AcceptRequest(IAsyncResult ar)
        {
            IReplyChannel channel = ar.AsyncState as IReplyChannel;

            try
            {
                RequestContext context = channel.EndReceiveRequest(ar);
                channel.BeginReceiveRequest(AcceptRequest, channel);
                ProcessRequest(context);
            }
            catch (TimeoutException)
            {
                channel.BeginReceiveRequest(AcceptRequest, channel);
            }
        }
コード例 #33
0
        void AcceptCallback(object state)
        {
            IChannelListener <IReplyChannel> listener = (IChannelListener <IReplyChannel>)state;

            this.acceptedChannel = listener.AcceptChannel(TimeSpan.MaxValue);
            if (this.acceptedChannel != null)
            {
                this.acceptedChannel.Open();
                ReceiveRequest(this.acceptedChannel);
            }
            else
            {
                listener.Close();
            }
        }
コード例 #34
0
        public void EndAcceptChannel_Returns_Null_If_The_Inner_Listener_Returns_Null()
        {
            MockChannelListener innerListener           = new MockChannelListener(true /* return null channel */);
            HttpMessageEncodingChannelListener listener = new HttpMessageEncodingChannelListener(innerListener);

            listener.Open();

            object        state    = new object();
            AsyncCallback callback = MockAsyncCallback.Create();
            TimeSpan      timeout  = new TimeSpan(0, 2, 0);
            IAsyncResult  result   = listener.BeginAcceptChannel(timeout, callback, state);
            IReplyChannel channel  = listener.EndAcceptChannel(result);

            Assert.IsNull(channel, "HttpMessageEncodingChannelListener.EndAcceptChannel should have returned null since the inner listener returned null.");
        }
コード例 #35
0
ファイル: ChannelTests.cs プロジェクト: nuxleus/WCFWeb
        private void BasicChannelTestB(bool customBinding)
        {
            IChannelListener <IReplyChannel> listener = null;
            IReplyChannel    channel = null;
            ManualResetEvent done    = new ManualResetEvent(false);
            Thread           t       = null;

            try
            {
                channel = this.OpenChannel(customBinding, out listener);
                Assert.IsNotNull(channel);
                Assert.IsNotNull(listener);

                t = new Thread(BasicChannelTests.SubmitRequests);
                t.Start(done);

                for (var cnt = 0; cnt < TestServiceCommon.Iterations; cnt++)
                {
                    RequestContext context;
                    if (channel.TryReceiveRequest(TestServiceCommon.DefaultHostTimeout, out context))
                    {
                        this.SendResponse(context);
                    }
                    else
                    {
                        Assert.Fail("TryReceiveRequest failed.");
                    }
                }

                channel.Close(TestServiceCommon.DefaultHostTimeout);
                listener.Close(TestServiceCommon.DefaultHostTimeout);
            }
            catch (Exception e)
            {
                channel.Abort();
                listener.Abort();
                Assert.Fail("Unexpected exception: " + e);
            }
            finally
            {
                if (t != null && !done.WaitOne(TestServiceCommon.DefaultHostTimeout))
                {
                    t.Abort();
                }

                done.Dispose();
            }
        }
コード例 #36
0
        private static bool EndTryAcceptChannel(IAsyncResult result, out IReplyChannel channel)
        {
            Contract.Assert(result != null);

            CompletedAsyncResult <bool> handlerResult = result as CompletedAsyncResult <bool>;

            if (handlerResult != null)
            {
                channel = null;
                return(CompletedAsyncResult <bool> .End(handlerResult));
            }
            else
            {
                try
                {
                    HttpSelfHostServer server = (HttpSelfHostServer)result.AsyncState;
                    Contract.Assert(server != null);
                    Contract.Assert(server._listener != null);
                    channel = server._listener.EndAcceptChannel(result);
                    return(true);
                }
                catch (CommunicationObjectAbortedException)
                {
                    channel = null;
                    return(true);
                }
                catch (CommunicationObjectFaultedException)
                {
                    channel = null;
                    return(true);
                }
                catch (TimeoutException)
                {
                    channel = null;
                    return(false);
                }
                catch (CommunicationException)
                {
                    channel = null;
                    return(false);
                }
                catch
                {
                    channel = null;
                    return(false);
                }
            }
        }
コード例 #37
0
 internal async Task <IServiceChannelDispatcher> GetAuthChannelDispatcher(IReplyChannel outerChannel)
 {
     if (_securityAuthServiceChannelDispatcher == null)
     {
         lock (ThisLock)
         {
             if (_channelTask == null)
             {
                 _channelTask = SecurityAuthServiceDispatcher.CreateServiceChannelDispatcherAsync(outerChannel);
             }
         }
         _securityAuthServiceChannelDispatcher = await _channelTask;
         Thread.MemoryBarrier();
     }
     return(_securityAuthServiceChannelDispatcher);
 }
コード例 #38
0
 public Fetch(IReplyChannel<int?> channel)
 {
     this.Channel = channel;
 }
コード例 #39
0
            public ReceiveRequestAsyncResult(IReplyChannel channel, TimeSpan timeout, AsyncCallback callback, object state)
                : base(callback, state)
            {
                this.channel = channel;
                this.timeout = timeout;
                IAsyncResult result = channel.BeginTryReceiveRequest(timeout, onReceiveRequest, this);

                if (!result.CompletedSynchronously)
                {
                    return;
                }

                OnReceiveRequestCore(result);
                base.Complete(true);
            }
コード例 #40
0
ファイル: Service.cs プロジェクト: ssickles/archive
 void AcceptCallback(object state)
 {
     IChannelListener<IReplyChannel> listener = (IChannelListener<IReplyChannel>)state;
     this.acceptedChannel = listener.AcceptChannel(TimeSpan.MaxValue);
     if (this.acceptedChannel != null)
     {
         this.acceptedChannel.Open();
         ReceiveRequest(this.acceptedChannel);
     }
     else
     {
         listener.Close();
     }
 }
コード例 #41
0
ファイル: Service.cs プロジェクト: ssickles/archive
        void ReceiveRequest(IReplyChannel channel)
        {
            for (; ; )
            {
                IAsyncResult result = channel.BeginReceiveRequest(TimeSpan.MaxValue, this.onReceive, channel);
                if (!result.CompletedSynchronously)
                    break;

                RequestContext context = channel.EndReceiveRequest(result);
                if (!HandleRequest(channel, context))
                {
                    break;
                }
            }
        }
コード例 #42
0
ファイル: Service.cs プロジェクト: ssickles/archive
        bool HandleRequest(IReplyChannel channel, RequestContext context)
        {
            if (context == null)
            {
                channel.Close();
                return false;
            }

            try
            {
                serviceManager.HandleRequest(context);
            }
            catch (CommunicationException)
            {
                context.Abort();
            }
            finally
            {
                context.Close();
            }
            return true;
        }
コード例 #43
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ChannelContext"/> class.
 /// </summary>
 /// <param name="server">The host to associate with this context.</param>
 /// <param name="channel">The channel to associate with this channel.</param>
 public ChannelContext(AzureServiceBusHttpServer server, IReplyChannel channel)
 {
     Contract.Assert(server != null);
     Contract.Assert(channel != null);
     Server = server;
     Channel = channel;
 }
コード例 #44
0
 public MyReplyChannel(ChannelManagerBase channelManager, IReplyChannel innerChannel)
     : base(channelManager)
 {
     this.InnerChannel = innerChannel;
 }
コード例 #45
0
ファイル: WsUdpServer.cs プロジェクト: awakegod/NETMF-LPC
 public void Start(ServerBindingContext ctx)
 {
     if (1 == Interlocked.Increment(ref m_refcount))
     {
         m_requestStop = false;
         m_replyChannel = m_binding.CreateServerChannel(ctx);
         m_replyChannel.Open();
         m_thread = new Thread(new ThreadStart(this.Listen));
         m_thread.Start();
     }
 }
コード例 #46
0
ファイル: SimpleReplyChannel.cs プロジェクト: Jaryli/WCFStudy
 public SimpleReplyChannel(ChannelManagerBase channelManager, IReplyChannel innerChannel)
     : base(channelManager, (ChannelBase)innerChannel)
 {
 }
コード例 #47
0
        private static bool EndTryAcceptChannel(IAsyncResult result, out IReplyChannel channel)
        {
            Contract.Assert(result != null);

            CompletedAsyncResult<bool> handlerResult = result as CompletedAsyncResult<bool>;
            if (handlerResult != null)
            {
                channel = null;
                return CompletedAsyncResult<bool>.End(handlerResult);
            }
            else
            {
                try
                {
                    HttpSelfHostServer server = (HttpSelfHostServer)result.AsyncState;
                    Contract.Assert(server != null);
                    Contract.Assert(server._listener != null);
                    channel = server._listener.EndAcceptChannel(result);
                    return true;
                }
                catch (CommunicationObjectAbortedException)
                {
                    channel = null;
                    return true;
                }
                catch (CommunicationObjectFaultedException)
                {
                    channel = null;
                    return true;
                }
                catch (TimeoutException)
                {
                    channel = null;
                    return false;
                }
                catch (CommunicationException)
                {
                    channel = null;
                    return false;
                }
                catch
                {
                    channel = null;
                    return false;
                }
            }
        }
コード例 #48
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ChannelContext"/> class.
 /// </summary>
 /// <param name="server">The host to associate with this context.</param>
 /// <param name="channel">The channel to associate with this channel.</param>
 public ChannelContext(HttpSelfHostServer server, IReplyChannel channel)
 {
     Contract.Assert(server != null);
     Contract.Assert(channel != null);
     Server = server;
     Channel = channel;
 }
コード例 #49
0
 public SimpleReplyChannel(ChannelManagerBase channelManager, IReplyChannel innerChannel)
     : base(channelManager, (ChannelBase)innerChannel)
 {
     this.Print("SimpleReplyChannel()");
 }