コード例 #1
0
        private void OnDataPacketReceived(byte[] rawData, string stream, Guid psGuid)
        {
            string str = "stdin";

            if (stream.Equals(DataPriorityType.PromptResponse.ToString(), StringComparison.OrdinalIgnoreCase))
            {
                str = "pr";
            }
            if (Guid.Empty == psGuid)
            {
                lock (this._syncObject)
                {
                    this.sessionTM.ProcessRawData(rawData, str);
                    return;
                }
            }
            AbstractServerTransportManager commandTransportManager = null;

            lock (this._syncObject)
            {
                commandTransportManager = this.sessionTM.GetCommandTransportManager(psGuid);
            }
            if (commandTransportManager != null)
            {
                commandTransportManager.ProcessRawData(rawData, str);
            }
            else
            {
                this.originalStdOut.WriteLine(OutOfProcessUtils.CreateDataAckPacket(psGuid));
            }
        }
コード例 #2
0
        protected void OnDataPacketReceived(byte[] rawData, string stream, Guid psGuid)
        {
            string streamTemp = System.Management.Automation.Remoting.Client.WSManNativeApi.WSMAN_STREAM_ID_STDIN;

            if (stream.Equals(DataPriorityType.PromptResponse.ToString(), StringComparison.OrdinalIgnoreCase))
            {
                streamTemp = System.Management.Automation.Remoting.Client.WSManNativeApi.WSMAN_STREAM_ID_PROMPTRESPONSE;
            }

            if (Guid.Empty == psGuid)
            {
                lock (_syncObject)
                {
                    sessionTM.ProcessRawData(rawData, streamTemp);
                }
            }
            else
            {
                // this is for a command
                AbstractServerTransportManager cmdTM = null;

                lock (_syncObject)
                {
                    cmdTM = sessionTM.GetCommandTransportManager(psGuid);
                }

                if (cmdTM != null)
                {
                    // not throwing when there is no associated command as the command might have
                    // legitimately closed while the client is sending data. however the client
                    // should die after timeout as we are not sending an ACK back.
                    cmdTM.ProcessRawData(rawData, streamTemp);
                }
                else
                {
                    // There is no command transport manager to process the input data.
                    // However, we still need to acknowledge to the client that this input data
                    // was received.  This can happen with some cmdlets such as Select-Object -First
                    // where the cmdlet completes before all input data is received.
                    originalStdOut.WriteLine(OutOfProcessUtils.CreateDataAckPacket(psGuid));
                }
            }
        }