internal RemoteSessionStateMachineEventArgs (RemoteSessionEvent stateEvent, Exception reason) { this._stateEvent = stateEvent; this._reason = reason; }
/// <summary> /// Handler which handles transport errors. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> internal void HandleTransportError(object sender, TransportErrorOccuredEventArgs e) { Dbg.Assert(e != null, "HandleTransportError expects non-null eventargs"); // handle uri redirections PSRemotingTransportRedirectException redirectException = e.Exception as PSRemotingTransportRedirectException; if ((redirectException != null) && (_maxUriRedirectionCount > 0)) { Exception exception = null; try { // honor max redirection count given by the user. _maxUriRedirectionCount--; PerformURIRedirection(redirectException.RedirectLocation); return; } catch (ArgumentNullException argumentException) { exception = argumentException; } catch (UriFormatException uriFormatException) { exception = uriFormatException; } // if we are here, there must be an exception constructing a uri if (exception != null) { PSRemotingTransportException newException = new PSRemotingTransportException(PSRemotingErrorId.RedirectedURINotWellFormatted, RemotingErrorIdStrings.RedirectedURINotWellFormatted, _session.Context.RemoteAddress.OriginalString, redirectException.RedirectLocation); newException.TransportMessage = e.Exception.TransportMessage; e.Exception = newException; } } RemoteSessionEvent sessionEvent = RemoteSessionEvent.ConnectFailed; switch (e.ReportingTransportMethod) { case TransportMethodEnum.CreateShellEx: sessionEvent = RemoteSessionEvent.ConnectFailed; break; case TransportMethodEnum.SendShellInputEx: case TransportMethodEnum.CommandInputEx: sessionEvent = RemoteSessionEvent.SendFailed; break; case TransportMethodEnum.ReceiveShellOutputEx: case TransportMethodEnum.ReceiveCommandOutputEx: sessionEvent = RemoteSessionEvent.ReceiveFailed; break; case TransportMethodEnum.CloseShellOperationEx: sessionEvent = RemoteSessionEvent.CloseFailed; break; case TransportMethodEnum.DisconnectShellEx: sessionEvent = RemoteSessionEvent.DisconnectFailed; break; case TransportMethodEnum.ReconnectShellEx: sessionEvent = RemoteSessionEvent.ReconnectFailed; break; } RemoteSessionStateMachineEventArgs errorArgs = new RemoteSessionStateMachineEventArgs(sessionEvent, e.Exception); _stateMachine.RaiseEvent(errorArgs); }
internal RemoteSessionStateMachineEventArgs(RemoteSessionEvent stateEvent) : this(stateEvent, null) { }
internal RemoteSessionStateMachineEventArgs(RemoteSessionEvent stateEvent, Exception reason) { StateEvent = stateEvent; Reason = reason; }
internal void HandleTransportError(object sender, TransportErrorOccuredEventArgs e) { PSRemotingTransportRedirectException exception = e.Exception as PSRemotingTransportRedirectException; if ((exception != null) && (this.maxUriRedirectionCount > 0)) { Exception exception2 = null; try { this.maxUriRedirectionCount--; this.PerformURIRedirection(exception.RedirectLocation); return; } catch (ArgumentNullException exception3) { exception2 = exception3; } catch (UriFormatException exception4) { exception2 = exception4; } if (exception2 != null) { PSRemotingTransportException exception5 = new PSRemotingTransportException(PSRemotingErrorId.RedirectedURINotWellFormatted, RemotingErrorIdStrings.RedirectedURINotWellFormatted, new object[] { this._session.Context.RemoteAddress.OriginalString, exception.RedirectLocation }) { TransportMessage = e.Exception.TransportMessage }; e.Exception = exception5; } } RemoteSessionEvent connectFailed = RemoteSessionEvent.ConnectFailed; switch (e.ReportingTransportMethod) { case TransportMethodEnum.CreateShellEx: connectFailed = RemoteSessionEvent.ConnectFailed; break; case TransportMethodEnum.SendShellInputEx: case TransportMethodEnum.CommandInputEx: connectFailed = RemoteSessionEvent.SendFailed; break; case TransportMethodEnum.ReceiveShellOutputEx: case TransportMethodEnum.ReceiveCommandOutputEx: connectFailed = RemoteSessionEvent.ReceiveFailed; break; case TransportMethodEnum.CloseShellOperationEx: connectFailed = RemoteSessionEvent.CloseFailed; break; case TransportMethodEnum.DisconnectShellEx: connectFailed = RemoteSessionEvent.DisconnectFailed; break; case TransportMethodEnum.ReconnectShellEx: connectFailed = RemoteSessionEvent.ReconnectFailed; break; } RemoteSessionStateMachineEventArgs arg = new RemoteSessionStateMachineEventArgs(connectFailed, e.Exception); this._stateMachine.RaiseEvent(arg, false); }
internal RemoteSessionStateMachineEventArgs(RemoteSessionEvent stateEvent) : this(stateEvent, (Exception)null) { using (RemoteSessionStateMachineEventArgs._trace.TraceConstructor((object)this)) ; }