protected BaseClientCommandTransportManager(ClientRemotePowerShell shell, PSRemotingCryptoHelper cryptoHelper, BaseClientSessionTransportManager sessnTM) : base(sessnTM.RunspacePoolInstanceId, cryptoHelper) { RemoteDataObject obj2; base.Fragmentor.FragmentSize = sessnTM.Fragmentor.FragmentSize; base.Fragmentor.TypeTable = sessnTM.Fragmentor.TypeTable; base.dataToBeSent.Fragmentor = base.Fragmentor; this.powershellInstanceId = shell.PowerShell.InstanceId; this.cmdText = new StringBuilder(); foreach (Command command in shell.PowerShell.Commands.Commands) { this.cmdText.Append(command.CommandText); this.cmdText.Append(" | "); } this.cmdText.Remove(this.cmdText.Length - 3, 3); if (shell.PowerShell.IsGetCommandMetadataSpecialPipeline) { obj2 = RemotingEncoder.GenerateGetCommandMetadata(shell); } else { obj2 = RemotingEncoder.GenerateCreatePowerShell(shell); } this.serializedPipeline = new SerializedDataStream(base.Fragmentor.FragmentSize); base.Fragmentor.Fragment <object>(obj2, this.serializedPipeline); }
internal virtual void SendDataToClient <T>(RemoteDataObject <T> data, bool flush, bool reportPending = false) { lock (this.syncObject) { RemoteDataObject obj2 = RemoteDataObject.CreateFrom(data.Destination, data.DataType, data.RunspacePoolId, data.PowerShellId, data.Data); if (this.isSerializing) { if (this.dataToBeSentQueue == null) { this.dataToBeSentQueue = new Queue <Tuple <RemoteDataObject, bool, bool> >(); } this.dataToBeSentQueue.Enqueue(new Tuple <RemoteDataObject, bool, bool>(obj2, flush, reportPending)); } else { this.isSerializing = true; try { do { using (SerializedDataStream stream = new SerializedDataStream(base.Fragmentor.FragmentSize, this.onDataAvailable)) { this.shouldFlushData = flush; this.reportAsPending = reportPending; this.runpacePoolInstanceId = obj2.RunspacePoolId; this.powerShellInstanceId = obj2.PowerShellId; this.dataType = obj2.DataType; this.targetInterface = obj2.TargetInterface; base.Fragmentor.Fragment <object>(obj2, stream); } if ((this.dataToBeSentQueue != null) && (this.dataToBeSentQueue.Count > 0)) { Tuple <RemoteDataObject, bool, bool> tuple = this.dataToBeSentQueue.Dequeue(); obj2 = tuple.Item1; flush = tuple.Item2; reportPending = tuple.Item3; } else { obj2 = null; } }while (obj2 != null); } finally { this.isSerializing = false; } } } }
internal void SendDataToClient <T>(RemoteDataObject <T> data, bool flush) { using (SerializedDataStream dataToBeSent = new SerializedDataStream(this.Fragmentor.FragmentSize, this.onDataAvailable)) { lock (this.syncObject) { this.shouldFlushData = flush; this.runpacePoolInstanceId = data.RunspacePoolId; this.powerShellInstanceId = data.PowerShellId; this.dataType = data.DataType; this.targetInterface = data.TargetInterface; this.Fragmentor.Fragment <T>(data, dataToBeSent); } } }