/// <summary> /// Process the data received from the powershell on /// the client. /// </summary> /// <param name="receivedData">Data received.</param> internal void ProcessReceivedData(RemoteDataObject <PSObject> receivedData) { if (receivedData == null) { throw PSTraceSource.NewArgumentNullException("receivedData"); } Dbg.Assert(receivedData.TargetInterface == RemotingTargetInterface.PowerShell, "RemotingTargetInterface must be PowerShell"); switch (receivedData.DataType) { case RemotingDataType.StopPowerShell: { Dbg.Assert(StopPowerShellReceived != null, "ServerPowerShellDriver should subscribe to all data structure handler events"); StopPowerShellReceived.SafeInvoke(this, EventArgs.Empty); } break; case RemotingDataType.PowerShellInput: { Dbg.Assert(InputReceived != null, "ServerPowerShellDriver should subscribe to all data structure handler events"); InputReceived.SafeInvoke(this, new RemoteDataEventArgs <object>(receivedData.Data)); } break; case RemotingDataType.PowerShellInputEnd: { Dbg.Assert(InputEndReceived != null, "ServerPowerShellDriver should subscribe to all data structure handler events"); InputEndReceived.SafeInvoke(this, EventArgs.Empty); } break; case RemotingDataType.RemotePowerShellHostResponseData: { Dbg.Assert(HostResponseReceived != null, "ServerPowerShellDriver should subscribe to all data structure handler events"); RemoteHostResponse remoteHostResponse = RemoteHostResponse.Decode(receivedData.Data); // part of host message robustness algo. Now the host response is back, report to transport that // execution status is back to running _transportManager.ReportExecutionStatusAsRunning(); HostResponseReceived.SafeInvoke(this, new RemoteDataEventArgs <RemoteHostResponse>(remoteHostResponse)); } break; } }
/// <summary> /// Process the data received from the runspace pool on /// the server. /// </summary> /// <param name="receivedData">Data received.</param> internal void ProcessReceivedData(RemoteDataObject <PSObject> receivedData) { if (receivedData == null) { throw PSTraceSource.NewArgumentNullException("receivedData"); } Dbg.Assert(receivedData.TargetInterface == RemotingTargetInterface.RunspacePool, "RemotingTargetInterface must be Runspace"); switch (receivedData.DataType) { case RemotingDataType.CreatePowerShell: { Dbg.Assert(CreateAndInvokePowerShell != null, "The ServerRunspacePoolDriver should subscribe to all data structure handler events"); CreateAndInvokePowerShell.SafeInvoke(this, new RemoteDataEventArgs <RemoteDataObject <PSObject> >(receivedData)); } break; case RemotingDataType.GetCommandMetadata: { Dbg.Assert(GetCommandMetadata != null, "The ServerRunspacePoolDriver should subscribe to all data structure handler events"); GetCommandMetadata.SafeInvoke(this, new RemoteDataEventArgs <RemoteDataObject <PSObject> >(receivedData)); } break; case RemotingDataType.RemoteRunspaceHostResponseData: { Dbg.Assert(HostResponseReceived != null, "The ServerRunspacePoolDriver should subscribe to all data structure handler events"); RemoteHostResponse remoteHostResponse = RemoteHostResponse.Decode(receivedData.Data); // part of host message robustness algo. Now the host response is back, report to transport that // execution status is back to running _transportManager.ReportExecutionStatusAsRunning(); HostResponseReceived.SafeInvoke(this, new RemoteDataEventArgs <RemoteHostResponse>(remoteHostResponse)); } break; case RemotingDataType.SetMaxRunspaces: { Dbg.Assert(SetMaxRunspacesReceived != null, "The ServerRunspacePoolDriver should subscribe to all data structure handler events"); SetMaxRunspacesReceived.SafeInvoke(this, new RemoteDataEventArgs <PSObject>(receivedData.Data)); } break; case RemotingDataType.SetMinRunspaces: { Dbg.Assert(SetMinRunspacesReceived != null, "The ServerRunspacePoolDriver should subscribe to all data structure handler events"); SetMinRunspacesReceived.SafeInvoke(this, new RemoteDataEventArgs <PSObject>(receivedData.Data)); } break; case RemotingDataType.AvailableRunspaces: { Dbg.Assert(GetAvailableRunspacesReceived != null, "The ServerRunspacePoolDriver should subscribe to all data structure handler events"); GetAvailableRunspacesReceived.SafeInvoke(this, new RemoteDataEventArgs <PSObject>(receivedData.Data)); } break; case RemotingDataType.ResetRunspaceState: { Dbg.Assert(ResetRunspaceState != null, "The ServerRunspacePoolDriver should subscribe to all data structure handler events."); ResetRunspaceState.SafeInvoke(this, new RemoteDataEventArgs <PSObject>(receivedData.Data)); } break; } }