Esempio n. 1
0
        /// <summary>
        /// Try to begin receive messages
        /// </summary>
        /// <param name="ccs">indicating the channel and the client</param>
        /// <returns>if the operation completed synchronously</returns>
        protected override bool TryToBeginReceive(ChannelClientState ccs)
        {
            IDuplexSessionChannel channel = (IDuplexSessionChannel)ccs.Channel;
            BrokerClient          client  = ccs.Client;
            IAsyncResult          ar      = null;

            try
            {
                ar = channel.BeginReceive(this.receiveRequest, ccs);
            }
            catch (Exception e)
            {
                BrokerTracing.TraceEvent(TraceEventType.Information, 0, "[DuplexFrontEnd] Exception throwed while begin receive messages: {0}", e);

                // Channel must be in falted state
                lock (channel)
                {
                    if (channel.State == CommunicationState.Faulted)
                    {
                        BrokerTracing.TraceEvent(TraceEventType.Information, 0, "[DuplexFrontEnd] About the channel.");
                        this.FrontendDisconnect(channel, client);

                        // About the falted channel
                        channel.Abort();
                    }
                }

                return(false);
            }

            return(ar.CompletedSynchronously && channel.State == CommunicationState.Opened);
        }
 private void StartBackgroundReceive(IDuplexSessionChannel channel)
 {
     if (this.onReceive == null)
     {
         this.onReceive = Fx.ThunkCallback(new AsyncCallback(this.OnReceive));
     }
     channel.BeginReceive(TimeSpan.MaxValue, this.onReceive, channel);
 }
Esempio n. 3
0
 public IAsyncResult BeginReceive(TimeSpan timeout,
                                  AsyncCallback callback, object state)
 {
     return(innerDuplexSessionChannel.BeginReceive(timeout,
                                                   callback, state));
 }