コード例 #1
0
 static void TraceOnSessionPreambleKnown(ServerSessionPreambleConnectionReader serverSessionPreambleReader)
 {
     if (TD.SessionPreambleUnderstoodIsEnabled())
     {
         TD.SessionPreambleUnderstood((serverSessionPreambleReader.Via != null) ? serverSessionPreambleReader.Via.ToString() : String.Empty);
     }
 }
コード例 #2
0
        internal void OnHandleServerSessionPreamble(ServerSessionPreambleConnectionReader serverSessionPreambleReader,
                                                    ConnectionDemuxer connectionDemuxer)
        {
            Uri via = serverSessionPreambleReader.Via;
            TChannelListener channelListener = GetChannelListener(via);

            if (channelListener != null)
            {
                ISessionPreambleHandler sessionPreambleHandler = channelListener as ISessionPreambleHandler;

                if (sessionPreambleHandler != null && channelListener is IChannelListener <IDuplexSessionChannel> )
                {
                    sessionPreambleHandler.HandleServerSessionPreamble(serverSessionPreambleReader, connectionDemuxer);
                }
                else
                {
                    serverSessionPreambleReader.SendFault(FramingEncodingString.UnsupportedModeFault);
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
                              new ProtocolException(SR.GetString(SR.FramingModeNotSupported, FramingMode.Duplex)));
                }
            }
            else
            {
                serverSessionPreambleReader.SendFault(FramingEncodingString.EndpointNotFoundFault);
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new EndpointNotFoundException(SR.GetString(SR.DuplexSessionListenerNotFound, via.ToString())));
            }
        }
コード例 #3
0
        void ISessionPreambleHandler.HandleServerSessionPreamble(ServerSessionPreambleConnectionReader preambleReader,
                                                                 ConnectionDemuxer connectionDemuxer)
        {
            IDuplexSessionChannel channel = preambleReader.CreateDuplexSessionChannel(
                this, new EndpointAddress(this.Uri), ExposeConnectionProperty, connectionDemuxer);

            duplexAcceptor.EnqueueAndDispatch(channel, preambleReader.ConnectionDequeuedCallback);
        }
コード例 #4
0
 private void OnSessionPreambleKnown(ServerSessionPreambleConnectionReader serverSessionPreambleReader)
 {
     lock (this.ThisLock)
     {
         if (this.isDisposed)
         {
             return;
         }
         this.connectionReaders.Remove(serverSessionPreambleReader);
     }
     this.serverSessionPreambleCallback(serverSessionPreambleReader, this);
 }
コード例 #5
0
        void OnSessionPreambleKnown(ServerSessionPreambleConnectionReader serverSessionPreambleReader)
        {
            lock (ThisLock)
            {
                if (isDisposed)
                {
                    return;
                }

                connectionReaders.Remove(serverSessionPreambleReader);
            }

            TraceOnSessionPreambleKnown(serverSessionPreambleReader);

            serverSessionPreambleCallback(serverSessionPreambleReader, this);
        }
コード例 #6
0
        internal void OnHandleServerSessionPreamble(ServerSessionPreambleConnectionReader serverSessionPreambleReader, ConnectionDemuxer connectionDemuxer)
        {
            Uri via = serverSessionPreambleReader.Via;
            TChannelListener channelListener = this.GetChannelListener(via);

            if (channelListener != null)
            {
                ISessionPreambleHandler handler = channelListener as ISessionPreambleHandler;
                if ((handler != null) && (channelListener is IChannelListener <IDuplexSessionChannel>))
                {
                    handler.HandleServerSessionPreamble(serverSessionPreambleReader, connectionDemuxer);
                    return;
                }
                serverSessionPreambleReader.SendFault("http://schemas.microsoft.com/ws/2006/05/framing/faults/UnsupportedMode");
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ProtocolException(System.ServiceModel.SR.GetString("FramingModeNotSupported", new object[] { FramingMode.Duplex })));
            }
            serverSessionPreambleReader.SendFault("http://schemas.microsoft.com/ws/2006/05/framing/faults/EndpointNotFound");
            throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new EndpointNotFoundException(System.ServiceModel.SR.GetString("DuplexSessionListenerNotFound", new object[] { via.ToString() })));
        }
 private static void ReadCallback(object state)
 {
     ServerSessionPreambleConnectionReader reader = (ServerSessionPreambleConnectionReader) state;
     bool flag = false;
     try
     {
         reader.GetReadResult();
         reader.ContinueReading();
         flag = true;
     }
     catch (CommunicationException exception)
     {
         if (DiagnosticUtility.ShouldTraceInformation)
         {
             DiagnosticUtility.ExceptionUtility.TraceHandledException(exception, TraceEventType.Information);
         }
     }
     catch (TimeoutException exception2)
     {
         if (DiagnosticUtility.ShouldTraceInformation)
         {
             DiagnosticUtility.ExceptionUtility.TraceHandledException(exception2, TraceEventType.Information);
         }
     }
     catch (Exception exception3)
     {
         if (Fx.IsFatal(exception3))
         {
             throw;
         }
         if (!System.ServiceModel.Dispatcher.ExceptionHandler.HandleTransportExceptionHelper(exception3))
         {
             throw;
         }
     }
     finally
     {
         if (!flag)
         {
             reader.Abort();
         }
     }
 }
コード例 #8
0
        private void OnDuplexConnection(IConnection connection, Action connectionDequeuedCallback, long streamPosition, int offset, int size, TimeSpan timeout)
        {
            if (this.onSessionPreambleKnown == null)
            {
                this.onSessionPreambleKnown = new ServerSessionPreambleCallback(this.OnSessionPreambleKnown);
            }
            ServerSessionPreambleConnectionReader item = new ServerSessionPreambleConnectionReader(connection, connectionDequeuedCallback, streamPosition, offset, size, this.transportSettingsCallback, this.onConnectionClosed, this.onSessionPreambleKnown);

            lock (this.ThisLock)
            {
                if (this.isDisposed)
                {
                    item.Dispose();
                    return;
                }
                this.connectionReaders.Add(item);
            }
            item.StartReading(this.viaDelegate, timeout);
        }
コード例 #9
0
        void OnDuplexConnection(IConnection connection, Action connectionDequeuedCallback,
                                long streamPosition, int offset, int size, TimeSpan timeout)
        {
            if (onSessionPreambleKnown == null)
            {
                onSessionPreambleKnown = OnSessionPreambleKnown;
            }
            ServerSessionPreambleConnectionReader sessionPreambleReader = new ServerSessionPreambleConnectionReader(
                connection, connectionDequeuedCallback, streamPosition, offset, size,
                transportSettingsCallback, onConnectionClosed, onSessionPreambleKnown);

            lock (ThisLock)
            {
                if (isDisposed)
                {
                    sessionPreambleReader.Dispose();
                    return;
                }

                connectionReaders.Add(sessionPreambleReader);
            }

            sessionPreambleReader.StartReading(viaDelegate, timeout);
        }
 public ServerFramingDuplexSessionChannel(ConnectionOrientedTransportChannelListener channelListener, ServerSessionPreambleConnectionReader preambleReader, EndpointAddress localAddress, bool exposeConnectionProperty, ConnectionDemuxer connectionDemuxer) : base(channelListener, localAddress, preambleReader.Via, exposeConnectionProperty)
 {
     this.channelListener = channelListener;
     this.connectionDemuxer = connectionDemuxer;
     base.Connection = preambleReader.Connection;
     this.decoder = preambleReader.Decoder;
     this.connectionBuffer = preambleReader.connectionBuffer;
     this.offset = preambleReader.BufferOffset;
     this.size = preambleReader.BufferSize;
     this.rawConnection = preambleReader.RawConnection;
     StreamUpgradeProvider upgrade = channelListener.Upgrade;
     if (upgrade != null)
     {
         this.channelBindingProvider = upgrade.GetProperty<IStreamUpgradeChannelBindingProvider>();
         this.upgradeAcceptor = upgrade.CreateUpgradeAcceptor();
     }
 }