/// <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>
 /// Handle transport manager's closing event.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="args"></param>
 private void HandleTransportClosing(object sender, EventArgs args)
 {
     StopPowerShellReceived.SafeInvoke(this, args);
 }