Exemplo n.º 1
0
 private void HandleConnectionStateChanged(object sender, RemoteSessionStateEventArgs arg)
 {
     using (_trace.TraceEventHandlers())
     {
         if (arg == null)
         {
             throw PSTraceSource.NewArgumentNullException("arg");
         }
         if (arg.SessionStateInfo.State == RemoteSessionState.EstablishedAndKeyReceived)
         {
             this.StartKeyExchange();
         }
         if (arg.SessionStateInfo.State == RemoteSessionState.ClosingConnection)
         {
             this.CompleteKeyExchange();
         }
         this.StateChanged.SafeInvoke<RemoteSessionStateEventArgs>(this, arg);
     }
 }
 private void HandleStateChanged(object sender, RemoteSessionStateEventArgs arg)
 {
     if (arg == null)
     {
         throw PSTraceSource.NewArgumentNullException("arg");
     }
     if ((arg.SessionStateInfo.State == RemoteSessionState.NegotiationSending) || (arg.SessionStateInfo.State == RemoteSessionState.NegotiationSendingOnConnect))
     {
         this.HandleNegotiationSendingStateChange();
     }
     this.ConnectionStateChanged.SafeInvoke<RemoteSessionStateEventArgs>(this, arg);
     if ((arg.SessionStateInfo.State == RemoteSessionState.NegotiationSending) || (arg.SessionStateInfo.State == RemoteSessionState.NegotiationSendingOnConnect))
     {
         this.SendNegotiationAsync(arg.SessionStateInfo.State);
     }
     if (arg.SessionStateInfo.State == RemoteSessionState.Established)
     {
         WSManClientSessionTransportManager manager = this._transportManager as WSManClientSessionTransportManager;
         if (manager != null)
         {
             manager.AdjustForProtocolVariations(this._session.ServerProtocolVersion);
             manager.StartReceivingData();
         }
     }
     if (arg.SessionStateInfo.State == RemoteSessionState.ClosingConnection)
     {
         this.CloseConnectionAsync();
     }
     if (arg.SessionStateInfo.State == RemoteSessionState.Disconnecting)
     {
         this.DisconnectAsync();
     }
     if (arg.SessionStateInfo.State == RemoteSessionState.Reconnecting)
     {
         this.ReconnectAsync();
     }
 }
 private void SetState(RemoteSessionState newState, Exception reason)
 {
     RemoteSessionState state = this._state;
     if (newState != state)
     {
         this._state = newState;
         _trace.WriteLine("state machine state transition: from state {0} to state {1}", new object[] { state, this._state });
         RemoteSessionStateInfo remoteSessionStateInfo = new RemoteSessionStateInfo(this._state, reason);
         RemoteSessionStateEventArgs item = new RemoteSessionStateEventArgs(remoteSessionStateInfo);
         this._clientRemoteSessionStateChangeQueue.Enqueue(item);
     }
 }