internal ClientRemoteSessionDSHandlerImpl(ClientRemoteSession session, PSRemotingCryptoHelper cryptoHelper, RunspaceConnectionInfo connectionInfo, ClientRemoteSession.URIDirectionReported uriRedirectionHandler)
 {
     if (session == null)
     {
         throw PSTraceSource.NewArgumentNullException("session");
     }
     this._session = session;
     this._stateMachine = new ClientRemoteSessionDSHandlerStateMachine();
     this._stateMachine.StateChanged += new EventHandler<RemoteSessionStateEventArgs>(this.HandleStateChanged);
     this._connectionInfo = connectionInfo;
     this._cryptoHelper = cryptoHelper;
     if (this._connectionInfo is NewProcessConnectionInfo)
     {
         this._transportManager = new OutOfProcessClientSessionTransportManager(this._session.RemoteRunspacePoolInternal.InstanceId, (NewProcessConnectionInfo) this._connectionInfo, cryptoHelper);
     }
     else
     {
         this._transportManager = new WSManClientSessionTransportManager(this._session.RemoteRunspacePoolInternal.InstanceId, (WSManConnectionInfo) this._connectionInfo, cryptoHelper, this._session.RemoteRunspacePoolInternal.Name);
     }
     this._transportManager.DataReceived += new EventHandler<RemoteDataEventArgs>(this.DispatchInputQueueData);
     this._transportManager.WSManTransportErrorOccured += new EventHandler<TransportErrorOccuredEventArgs>(this.HandleTransportError);
     this._transportManager.CloseCompleted += new EventHandler<EventArgs>(this.HandleCloseComplete);
     this._transportManager.DisconnectCompleted += new EventHandler<EventArgs>(this.HandleDisconnectComplete);
     this._transportManager.ReconnectCompleted += new EventHandler<EventArgs>(this.HandleReconnectComplete);
     this._transportManager.RobustConnectionNotification += new EventHandler<ConnectionStatusEventArgs>(this.HandleRobustConnectionNotification);
     WSManConnectionInfo info = connectionInfo as WSManConnectionInfo;
     if (info != null)
     {
         this.uriRedirectionHandler = uriRedirectionHandler;
         this.maxUriRedirectionCount = info.MaximumConnectionRedirectionCount;
     }
 }
示例#2
0
 internal ClientRemoteSessionDSHandlerImpl(
     ClientRemoteSession session,
     PSRemotingCryptoHelper cryptoHelper,
     RunspaceConnectionInfo connectionInfo,
     ClientRemoteSession.URIDirectionReported uriRedirectionHandler)
 {
     using (ClientRemoteSessionDSHandlerImpl._trace.TraceConstructor((object)this))
     {
         this._session      = session != null ? session : throw ClientRemoteSessionDSHandlerImpl._trace.NewArgumentNullException(nameof(session));
         this._stateMachine = new ClientRemoteSessionDSHandlerStateMachine();
         this._stateMachine.StateChanged += new EventHandler <RemoteSessionStateEventArgs>(this.HandleStateChanged);
         this._connectionInfo             = connectionInfo;
         this._cryptoHelper     = cryptoHelper;
         this._transportManager = !(this._connectionInfo is NewProcessConnectionInfo) ? (BaseClientSessionTransportManager) new WSManClientSessionTransportManager(this._session.RemoteRunspacePoolInternal.InstanceId, (WSManConnectionInfo)this._connectionInfo, cryptoHelper) : (BaseClientSessionTransportManager) new OutOfProcessClientSessionTransportManager(this._session.RemoteRunspacePoolInternal.InstanceId, (NewProcessConnectionInfo)this._connectionInfo, cryptoHelper);
         this._transportManager.DataReceived += new EventHandler <RemoteDataEventArgs>(this.DispatchInputQueueData);
         this._transportManager.WSManTransportErrorOccured += new EventHandler <TransportErrorOccuredEventArgs>(this.HandleTransportError);
         this._transportManager.CloseCompleted             += new EventHandler <EventArgs>(this.HandleCloseComplete);
         if (!(connectionInfo is WSManConnectionInfo manConnectionInfo))
         {
             return;
         }
         this.uriRedirectionHandler  = uriRedirectionHandler;
         this.maxUriRedirectionCount = manConnectionInfo.MaximumConnectionRedirectionCount;
     }
 }
示例#3
0
        internal ClientRemoteSessionDSHandlerImpl(ClientRemoteSession session, PSRemotingCryptoHelper cryptoHelper, RunspaceConnectionInfo connectionInfo, ClientRemoteSession.URIDirectionReported uriRedirectionHandler)
        {
            if (session == null)
            {
                throw PSTraceSource.NewArgumentNullException("session");
            }
            this._session      = session;
            this._stateMachine = new ClientRemoteSessionDSHandlerStateMachine();
            this._stateMachine.StateChanged += new EventHandler <RemoteSessionStateEventArgs>(this.HandleStateChanged);
            this._connectionInfo             = connectionInfo;
            this._cryptoHelper = cryptoHelper;
            if (this._connectionInfo is NewProcessConnectionInfo)
            {
                this._transportManager = new OutOfProcessClientSessionTransportManager(this._session.RemoteRunspacePoolInternal.InstanceId, (NewProcessConnectionInfo)this._connectionInfo, cryptoHelper);
            }
            else
            {
                this._transportManager = new WSManClientSessionTransportManager(this._session.RemoteRunspacePoolInternal.InstanceId, (WSManConnectionInfo)this._connectionInfo, cryptoHelper, this._session.RemoteRunspacePoolInternal.Name);
            }
            this._transportManager.DataReceived += new EventHandler <RemoteDataEventArgs>(this.DispatchInputQueueData);
            this._transportManager.WSManTransportErrorOccured   += new EventHandler <TransportErrorOccuredEventArgs>(this.HandleTransportError);
            this._transportManager.CloseCompleted               += new EventHandler <EventArgs>(this.HandleCloseComplete);
            this._transportManager.DisconnectCompleted          += new EventHandler <EventArgs>(this.HandleDisconnectComplete);
            this._transportManager.ReconnectCompleted           += new EventHandler <EventArgs>(this.HandleReconnectComplete);
            this._transportManager.RobustConnectionNotification += new EventHandler <ConnectionStatusEventArgs>(this.HandleRobustConnectionNotification);
            WSManConnectionInfo info = connectionInfo as WSManConnectionInfo;

            if (info != null)
            {
                this.uriRedirectionHandler  = uriRedirectionHandler;
                this.maxUriRedirectionCount = info.MaximumConnectionRedirectionCount;
            }
        }
示例#4
0
        /// <summary>
        /// Creates an instance of ClientRemoteSessionDSHandlerImpl
        /// </summary>
        internal ClientRemoteSessionDSHandlerImpl(ClientRemoteSession session,
                                                  PSRemotingCryptoHelper cryptoHelper,
                                                  RunspaceConnectionInfo connectionInfo,
                                                  ClientRemoteSession.URIDirectionReported uriRedirectionHandler)
        {
            Dbg.Assert(_maxUriRedirectionCount >= 0, "maxUriRedirectionCount cannot be less than 0.");

            if (session == null)
            {
                throw PSTraceSource.NewArgumentNullException("session");
            }

            _session = session;

            //Create state machine
            _stateMachine = new ClientRemoteSessionDSHandlerStateMachine();
            _stateMachine.StateChanged += HandleStateChanged;

            _connectionInfo = connectionInfo;

            // Create transport manager
            _cryptoHelper     = cryptoHelper;
            _transportManager = _connectionInfo.CreateClientSessionTransportManager(
                _session.RemoteRunspacePoolInternal.InstanceId,
                _session.RemoteRunspacePoolInternal.Name,
                cryptoHelper);

            _transportManager.DataReceived += DispatchInputQueueData;
            _transportManager.WSManTransportErrorOccured += HandleTransportError;
            _transportManager.CloseCompleted             += HandleCloseComplete;
            _transportManager.DisconnectCompleted        += HandleDisconnectComplete;
            _transportManager.ReconnectCompleted         += HandleReconnectComplete;

            _transportManager.RobustConnectionNotification += new EventHandler <ConnectionStatusEventArgs>(HandleRobustConnectionNotification);

            WSManConnectionInfo wsmanConnectionInfo = _connectionInfo as WSManConnectionInfo;

            if (wsmanConnectionInfo != null)
            {
                // only WSMan transport supports redirection

                // store the uri redirection handler and authmechanism
                // for uri redirection.
                _uriRedirectionHandler  = uriRedirectionHandler;
                _maxUriRedirectionCount = wsmanConnectionInfo.MaximumConnectionRedirectionCount;
            }
        }
        /// <summary>
        /// Creates an instance of ClientRemoteSessionDSHandlerImpl
        /// </summary>
        internal ClientRemoteSessionDSHandlerImpl(ClientRemoteSession session,
            PSRemotingCryptoHelper cryptoHelper,
            RunspaceConnectionInfo connectionInfo,
            ClientRemoteSession.URIDirectionReported uriRedirectionHandler)
        {
            Dbg.Assert(_maxUriRedirectionCount >= 0, "maxUriRedirectionCount cannot be less than 0.");

            if (session == null)
            {
                throw PSTraceSource.NewArgumentNullException("session");
            }

            _session = session;

            //Create state machine
            _stateMachine = new ClientRemoteSessionDSHandlerStateMachine();
            _stateMachine.StateChanged += HandleStateChanged;

            _connectionInfo = connectionInfo;

            // Create transport manager
            _cryptoHelper = cryptoHelper;
            _transportManager = _connectionInfo.CreateClientSessionTransportManager(
                _session.RemoteRunspacePoolInternal.InstanceId,
                _session.RemoteRunspacePoolInternal.Name,
                cryptoHelper);

            _transportManager.DataReceived += DispatchInputQueueData;
            _transportManager.WSManTransportErrorOccured += HandleTransportError;
            _transportManager.CloseCompleted += HandleCloseComplete;
            _transportManager.DisconnectCompleted += HandleDisconnectComplete;
            _transportManager.ReconnectCompleted += HandleReconnectComplete;

            _transportManager.RobustConnectionNotification += new EventHandler<ConnectionStatusEventArgs>(HandleRobustConnectionNotification);

            WSManConnectionInfo wsmanConnectionInfo = _connectionInfo as WSManConnectionInfo;
            if (null != wsmanConnectionInfo)
            {
                // only WSMan transport supports redirection

                // store the uri redirection handler and authmechanism 
                // for uri redirection.
                _uriRedirectionHandler = uriRedirectionHandler;
                _maxUriRedirectionCount = wsmanConnectionInfo.MaximumConnectionRedirectionCount;
            }
        }
 internal void Start(ClientRemoteSessionDSHandlerStateMachine stateMachine, bool inDisconnectMode)
 {
     this.SetupTransportManager(inDisconnectMode);
     this.transportManager.CreateAsync();
 }