Example #1
0
        async Task CloseChannelAsync(IChannel channel, CancellationToken token)
        {
            try
            {
                if (channel.State != CommunicationState.Closing && channel.State != CommunicationState.Closed)
                {
                    CloseChannelState state = new CloseChannelState(this, channel);
                    if (channel is ISessionChannel <IDuplexSession> )
                    {
                        IDuplexSession duplexSession = ((ISessionChannel <IDuplexSession>)channel).Session;
                        await duplexSession.CloseOutputSessionAsync(token);
                    }
                    else
                    {
                        await channel.CloseAsync(token);
                    }
                }
            }
            catch (Exception e)
            {
                if (Fx.IsFatal(e))
                {
                    throw;
                }
                HandleError(e);

                if (channel is ISessionChannel <IDuplexSession> )
                {
                    channel.Abort();
                }
            }
        }
 public ReplySessionOverDuplexSession(IDuplexSession innerSession)
 {
     if (innerSession == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("innerSession");
     }
     this.innerSession = innerSession;
 }
 public MessageBusDuplexSessionChannel(
     BufferManager bufferManager, MessageEncoderFactory encoder, ChannelManagerBase parent,
     EndpointAddress remoteAddress, Uri via,
     IBus bus,
     bool isClient)
     : base(bufferManager, encoder, remoteAddress, parent, via, bus, isClient)
 {
     _session = new MessageBusDuplexSession((new UniqueId()).ToString());
 }
 protected WseTcpDuplexSessionChannel(
     MessageEncoderFactory messageEncoderFactory, BufferManager bufferManager,
     EndpointAddress remoteAddress, EndpointAddress localAddress, Uri via, ChannelManagerBase channelManager)
     : base(channelManager)
 {
     this.remoteAddress = remoteAddress;
     this.localAddress = localAddress;
     this.via = via;
     this.session = new TcpDuplexSession(this);
     this.encoder = messageEncoderFactory.CreateSessionEncoder();
     this.bufferManager = bufferManager;
 }
Example #5
0
 protected WseTcpDuplexSessionChannel(
     MessageEncoderFactory messageEncoderFactory, BufferManager bufferManager,
     EndpointAddress remoteAddress, EndpointAddress localAddress, Uri via, ChannelManagerBase channelManager)
     : base(channelManager)
 {
     this.remoteAddress = remoteAddress;
     this.localAddress  = localAddress;
     this.via           = via;
     this.session       = new TcpDuplexSession(this);
     this.encoder       = messageEncoderFactory.CreateSessionEncoder();
     this.bufferManager = bufferManager;
 }
Example #6
0
        private void CloseChannel(IChannel channel, TimeSpan timeout)
        {
            try
            {
                if (channel.State != CommunicationState.Closing && channel.State != CommunicationState.Closed)
                {
                    CloseChannelState state = new CloseChannelState(this, channel);
                    if (channel is ISessionChannel <IDuplexSession> )
                    {
                        IDuplexSession duplexSession = ((ISessionChannel <IDuplexSession>)channel).Session;
                        IAsyncResult   result        = duplexSession.BeginCloseOutputSession(timeout, Fx.ThunkCallback(new AsyncCallback(CloseOutputSessionCallback)), state);
                        if (result.CompletedSynchronously)
                        {
                            duplexSession.EndCloseOutputSession(result);
                        }
                    }
                    else
                    {
                        IAsyncResult result = channel.BeginClose(timeout, Fx.ThunkCallback(new AsyncCallback(CloseChannelCallback)), state);
                        if (result.CompletedSynchronously)
                        {
                            channel.EndClose(result);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                if (Fx.IsFatal(e))
                {
                    throw;
                }
                this.HandleError(e);

                if (channel is ISessionChannel <IDuplexSession> )
                {
                    channel.Abort();
                }
            }
        }
 public MakeConnectionDuplexSessionClientChannel(ChannelManagerBase channelManager, IRequestSessionChannel innerChannel)
     : base(channelManager, innerChannel)
 {
     this.session = MakeConnectionDuplexSession.CreateClientSession
                        (this, innerChannel.Session);
 }
 protected override void OnAfterTryReceive(BusMessage message)
 {
     _session = new MessageBusDuplexSession(message.SessionID);
 }
Example #9
0
 public MakeConnectionDuplexSessionServiceChannel(ChannelManagerBase channelManager, IReplySessionChannel innerChannel)
     : base(channelManager, innerChannel)
 {
     this.session = MakeConnectionDuplexSession.CreateServerSession
                        (this, innerChannel.Session);
 }