Example #1
0
        /// <summary>
        /// Fires the NewLogonNeeded event.
        /// </summary>
        /// <param name="e">Event arguments.</param>
        /// <returns>True, if the event is handled, otherwise, false.</returns>
        protected virtual bool OnNewLogonNeeded(NewLogonNeededEventArgs e)
        {
            if (NewLogonNeeded != null)
            {
                NewLogonNeeded(this, e);
                return(true);
            }

            return(false);
        }
Example #2
0
        /// <summary>
        /// Reestablish connection to server.
        /// </summary>
        /// <remarks>
        /// This method checks if the session is valid. If not, a new logon in perfomed automatically.
        /// Handle the NewLogonNeeded event to provide credentials.
        /// </remarks>
        /// <returns>True, if reconnecting was successfull, otherwis false </returns>
        internal bool InternalReconnect()
        {
            // When the session isn´t valid, the server process must have been restarted
            if (!RemoteDispatcher.ExistSession(_sessionID))
            {
                AuthCredentials credentials     = null;
                var             performNewLogon = true;

                // If cached auto login credentials are present
                if (_autoLoginOnExpiredSession)
                {
                    credentials = _autoLoginCredentials;
                }
                else
                {
                    var newLogonNeededEventArgs = new NewLogonNeededEventArgs();
                    if (OnNewLogonNeeded(newLogonNeededEventArgs))
                    {
                        performNewLogon = !newLogonNeededEventArgs.Cancel;
                        credentials     = newLogonNeededEventArgs.Credentials;
                    }
                    else
                    {
                        performNewLogon = false;
                    }
                }

                if (performNewLogon)
                {
                    if (credentials == null)
                    {
                        credentials = new AuthCredentials();
                    }

                    credentials.Authenticate(_sessionID, RemoteDispatcher);
                    ReconnectRemoteEvents();

                    RemoteDispatcher.ReceiveClientHeartbeat(_sessionID);
                    return(true);
                }
            }
            else
            {
                RemoteDispatcher.ReceiveClientHeartbeat(_sessionID);
                return(true);
            }
            return(false);
        }
Example #3
0
        /// <summary>
        /// Reestablish connection to server.
        /// </summary>
        /// <remarks>
        /// This method checks if the session is valid. If not, a new logon in perfomed automatically.
        /// Handle the NewLogonNeeded event to provide credentials.
        /// </remarks>
        /// <returns>True, if reconnecting was successfull, otherwis false </returns>
        internal bool InternalReconnect()
        {
            // When the session isn´t valid, the server process must have been restarted
            //if (!RemoteDispatcher.ExistSession(_sessionID))
            if (!SendExistSessionMessage(_sessionID))
            {
                Hashtable credentials     = null;
                bool      performNewLogon = true;

                // If cached auto login credentials are present
                if (_autoLoginOnExpiredSession)
                {
                    credentials = _autoLoginCredentials;
                }
                else
                {
                    var newLogonNeededEventArgs = new NewLogonNeededEventArgs();
                    if (OnNewLogonNeeded(newLogonNeededEventArgs))
                    {
                        performNewLogon = !newLogonNeededEventArgs.Cancel;
                        credentials     = newLogonNeededEventArgs.Credentials;
                    }
                    else
                    {
                        performNewLogon = false;
                    }
                }
                if (performNewLogon)
                {
                    //RemoteDispatcher.Logon(_sessionID, credentials);
                    SendLogonMessage(_sessionID, credentials);
                    ReconnectRemoteEvents();

                    //RemoteDispatcher.ReceiveClientHeartbeat(_sessionID);
                    SendReceiveClientHeartbeatMessage(_sessionID);

                    return(true);
                }
            }
            else
            {
                //RemoteDispatcher.ReceiveClientHeartbeat(_sessionID);
                SendReceiveClientHeartbeatMessage(_sessionID);
                return(true);
            }
            return(false);
        }
Example #4
0
 static void Connection_NewLogonNeeded(object sender, NewLogonNeededEventArgs e)
 {
     e.Credentials = Credentials;
 }