Ejemplo n.º 1
0
        protected TReliableChannel ProcessCreateSequence(WsrmMessageInfo info, TInnerChannel channel, out bool dispatch, out bool newChannel)
        {
            EndpointAddress address;

            dispatch   = false;
            newChannel = false;
            CreateSequenceInfo createSequenceInfo = info.CreateSequenceInfo;

            if (!WsrmUtilities.ValidateCreateSequence <TChannel>(info, this, channel, out address))
            {
                return(default(TReliableChannel));
            }
            lock (base.ThisLock)
            {
                TReliableChannel local = default(TReliableChannel);
                if (((createSequenceInfo.OfferIdentifier == null) || !this.Duplex) || !this.channelsByOutput.TryGetValue(createSequenceInfo.OfferIdentifier, out local))
                {
                    if (!base.IsAccepting)
                    {
                        info.FaultReply = WsrmUtilities.CreateEndpointNotFoundFault(base.MessageVersion, System.ServiceModel.SR.GetString("RMEndpointNotFoundReason", new object[] { this.Uri }));
                        return(default(TReliableChannel));
                    }
                    if (this.inputQueueChannelAcceptor.PendingCount >= base.MaxPendingChannels)
                    {
                        info.FaultReply = WsrmUtilities.CreateCSRefusedServerTooBusyFault(base.MessageVersion, base.ReliableMessagingVersion, System.ServiceModel.SR.GetString("ServerTooBusy", new object[] { this.Uri }));
                        return(default(TReliableChannel));
                    }
                    UniqueId id = WsrmUtilities.NextSequenceId();
                    local = this.CreateChannel(id, createSequenceInfo, this.CreateBinder(channel, address, createSequenceInfo.ReplyTo));
                    this.channelsByInput.Add(id, local);
                    if (this.Duplex)
                    {
                        this.channelsByOutput.Add(createSequenceInfo.OfferIdentifier, local);
                    }
                    dispatch   = this.EnqueueWithoutDispatch((TChannel)local);
                    newChannel = true;
                }
                return(local);
            }
        }