internal override BaseClientCommandTransportManager CreateClientCommandTransportManager(RunspaceConnectionInfo connectionInfo, ClientRemotePowerShell cmd, bool noInput)
        {
            OutOfProcessClientCommandTransportManager cmdTM = new OutOfProcessClientCommandTransportManager(cmd, noInput, this, this.stdInWriter);

            this.AddCommandTransportManager(cmd.InstanceId, cmdTM);
            return(cmdTM);
        }
Example #2
0
 private void AddCommandTransportManager(
     Guid key,
     OutOfProcessClientCommandTransportManager cmdTM)
 {
     lock (this.syncObject)
         this.cmdTransportManagers.Add(key, cmdTM);
 }
 private OutOfProcessClientCommandTransportManager GetCommandTransportManager(Guid key)
 {
     lock (base.syncObject)
     {
         OutOfProcessClientCommandTransportManager manager = null;
         this.cmdTransportManagers.TryGetValue(key, out manager);
         return(manager);
     }
 }
        private void OnCommandCreationAckReceived(Guid psGuid)
        {
            OutOfProcessClientCommandTransportManager commandTransportManager = this.GetCommandTransportManager(psGuid);

            if (commandTransportManager == null)
            {
                throw new PSRemotingTransportException(PSRemotingErrorId.IPCUnknownCommandGuid, RemotingErrorIdStrings.IPCUnknownCommandGuid, new object[] { psGuid.ToString(), "CommandAck" });
            }
            commandTransportManager.OnCreateCmdCompleted();
            this._tracer.WriteMessage(string.Concat(new object[] { "OutOfProcessClientSessionTransportManager.OnCommandCreationAckReceived, in progress command count after cmd creation ACK : ", this.cmdTransportManagers.Count, ", psGuid : ", psGuid.ToString() }));
        }
        private void OnSiganlAckPacketReceived(Guid psGuid)
        {
            if (psGuid == Guid.Empty)
            {
                throw new PSRemotingTransportException(PSRemotingErrorId.IPCNoSignalForSession, RemotingErrorIdStrings.IPCNoSignalForSession, new object[] { "SignalAck" });
            }
            OutOfProcessClientCommandTransportManager commandTransportManager = this.GetCommandTransportManager(psGuid);

            if (commandTransportManager != null)
            {
                commandTransportManager.OnRemoteCmdSignalCompleted();
            }
        }
 private void AddCommandTransportManager(Guid key, OutOfProcessClientCommandTransportManager cmdTM)
 {
     lock (base.syncObject)
     {
         if (base.isClosed)
         {
             this._tracer.WriteMessage("OutOfProcessClientSessionTransportManager.AddCommandTransportManager, Adding command transport on closed session, RunSpacePool Id : " + base.RunspacePoolInstanceId);
         }
         else
         {
             this.cmdTransportManagers.Add(key, cmdTM);
         }
     }
 }
 private void AddCommandTransportManager(Guid key, OutOfProcessClientCommandTransportManager cmdTM)
 {
     lock (base.syncObject)
     {
         if (base.isClosed)
         {
             this._tracer.WriteMessage("OutOfProcessClientSessionTransportManager.AddCommandTransportManager, Adding command transport on closed session, RunSpacePool Id : " + base.RunspacePoolInstanceId);
         }
         else
         {
             this.cmdTransportManagers.Add(key, cmdTM);
         }
     }
 }
 private void OnDataAckPacketReceived(Guid psGuid)
 {
     if (psGuid == Guid.Empty)
     {
         this.OnRemoteSessionSendCompleted();
     }
     else
     {
         OutOfProcessClientCommandTransportManager commandTransportManager = this.GetCommandTransportManager(psGuid);
         if (commandTransportManager != null)
         {
             commandTransportManager.OnRemoteCmdSendCompleted();
         }
     }
 }
        private void OnDataPacketReceived(byte[] rawData, string stream, Guid psGuid)
        {
            string str = "stdout";

            if (stream.Equals(DataPriorityType.PromptResponse.ToString(), StringComparison.OrdinalIgnoreCase))
            {
                str = "pr";
            }
            if (psGuid == Guid.Empty)
            {
                object[] args = new object[] { base.RunspacePoolInstanceId.ToString(), Guid.Empty.ToString(), rawData.Length.ToString(CultureInfo.InvariantCulture) };
                PSEtwLog.LogAnalyticInformational(PSEventId.WSManReceiveShellOutputExCallbackReceived, PSOpcode.Receive, PSTask.None, PSKeyword.Transport | PSKeyword.UseAlwaysAnalytic, args);
                base.ProcessRawData(rawData, str);
            }
            else
            {
                OutOfProcessClientCommandTransportManager commandTransportManager = this.GetCommandTransportManager(psGuid);
                if (commandTransportManager != null)
                {
                    commandTransportManager.OnRemoteCmdDataReceived(rawData, str);
                }
            }
        }
        private void OnCloseAckReceived(Guid psGuid)
        {
            int count;

            lock (base.syncObject)
            {
                count = this.cmdTransportManagers.Count;
            }
            if (psGuid == Guid.Empty)
            {
                this._tracer.WriteMessage(string.Concat(new object[] { "OutOfProcessClientSessionTransportManager.OnCloseAckReceived, progress command count after CLOSE ACK should be zero = ", count, " psGuid : ", psGuid.ToString() }));
                this.OnCloseSessionCompleted();
            }
            else
            {
                this._tracer.WriteMessage(string.Concat(new object[] { "OutOfProcessClientSessionTransportManager.OnCloseAckReceived, in progress command count should be greater than zero: ", count, ", RunSpacePool Id : ", base.RunspacePoolInstanceId, ", psGuid : ", psGuid.ToString() }));
                OutOfProcessClientCommandTransportManager commandTransportManager = this.GetCommandTransportManager(psGuid);
                if (commandTransportManager != null)
                {
                    commandTransportManager.OnCloseCmdCompleted();
                }
            }
        }
        private void AddCommandTransportManager(Guid key, OutOfProcessClientCommandTransportManager cmdTM)
        {
            lock (syncObject)
            {
                if (isClosed)
                {
                    // It is possible for this add command to occur after/during session close via
                    // asynchronous stop pipeline or Stop-Job.  In this case ignore the command.
                    _tracer.WriteMessage("OutOfProcessClientSessionTransportManager.AddCommandTransportManager, Adding command transport on closed session, RunSpacePool Id : " + this.RunspacePoolInstanceId);
                    return;
                }

                Dbg.Assert(!_cmdTransportManagers.ContainsKey(key), "key already exists");
                _cmdTransportManagers.Add(key, cmdTM);
            }
        }
        /// <summary>
        /// Create a transport manager for command
        /// </summary>
        /// <param name="connectionInfo"></param>
        /// <param name="cmd"></param>
        /// <param name="noInput"></param>
        /// <returns></returns>
        internal override BaseClientCommandTransportManager CreateClientCommandTransportManager(
            RunspaceConnectionInfo connectionInfo,
            ClientRemotePowerShell cmd,
            bool noInput)
        {
            Dbg.Assert(null != cmd, "Cmd cannot be null");

            OutOfProcessClientCommandTransportManager result = new
                OutOfProcessClientCommandTransportManager(cmd, noInput, this, stdInWriter);
            AddCommandTransportManager(cmd.InstanceId, result);

            return result;
        }
 internal override BaseClientCommandTransportManager CreateClientCommandTransportManager(RunspaceConnectionInfo connectionInfo, ClientRemotePowerShell cmd, bool noInput)
 {
     OutOfProcessClientCommandTransportManager cmdTM = new OutOfProcessClientCommandTransportManager(cmd, noInput, this, this.stdInWriter);
     this.AddCommandTransportManager(cmd.InstanceId, cmdTM);
     return cmdTM;
 }