Ejemplo n.º 1
0
        private void SetConnectionState(bool isConnected)
        {
            _client.VerificationCode = null;
            _reqToken = null;

            if (IsConnected == isConnected)
            {
                return;
            }

            _client.AddDebugLog("Etrade: {0}", isConnected ? "connected" : "disconnected");

            if (isConnected)
            {
                Api.SetAuthenticator(AccessToken);
                _reconnecting = false;
            }
            else
            {
                Api.SetAuthenticator(null);
            }

            IsConnected = isConnected;
            ConnectionStateChanged.SafeInvoke();
        }
Ejemplo n.º 2
0
 private void OnConnectionStateChanged()
 {
     ConnectionStateChanged.SafeInvoke();
     if (Connection.IsConnected)
     {
         Dispatcher.OnResponseThreadAsync(() =>
         {
             RaiseHardcodedDataEvents();
             StartExport();
         });
     }
 }
Ejemplo n.º 3
0
        private void HandleStateChanged(object sender, RemoteSessionStateEventArgs arg)
        {
            if (arg == null)
            {
                throw PSTraceSource.NewArgumentNullException("arg");
            }

            // Enqueue session related negotiation packets first
            if ((arg.SessionStateInfo.State == RemoteSessionState.NegotiationSending) || (arg.SessionStateInfo.State == RemoteSessionState.NegotiationSendingOnConnect))
            {
                HandleNegotiationSendingStateChange();
            }

            // this will enable top-layers to enqueue any packets during NegotiationSending and
            // during other states.
            ConnectionStateChanged.SafeInvoke(this, arg);

            if ((arg.SessionStateInfo.State == RemoteSessionState.NegotiationSending) || (arg.SessionStateInfo.State == RemoteSessionState.NegotiationSendingOnConnect))
            {
                SendNegotiationAsync(arg.SessionStateInfo.State);
            }

            //once session is established.. start receiving data (if not already done and only apples to wsmanclientsessionTM)
            if (arg.SessionStateInfo.State == RemoteSessionState.Established)
            {
                WSManClientSessionTransportManager tm = _transportManager as WSManClientSessionTransportManager;
                if (tm != null)
                {
                    tm.AdjustForProtocolVariations(_session.ServerProtocolVersion);
                    tm.StartReceivingData();
                }
            }

            // Close the transport manager only after powershell's close their transports
            // Powershell's close their transport using the ConnectionStateChanged event notification.
            if (arg.SessionStateInfo.State == RemoteSessionState.ClosingConnection)
            {
                CloseConnectionAsync();
            }

            //process disconnect
            if (arg.SessionStateInfo.State == RemoteSessionState.Disconnecting)
            {
                DisconnectAsync();
            }

            //process reconnect
            if (arg.SessionStateInfo.State == RemoteSessionState.Reconnecting)
            {
                ReconnectAsync();
            }
        }
Ejemplo n.º 4
0
 private void RaiseConnectionStateChanged()
 {
     ConnectionStateChanged.SafeInvoke();
 }