StartHost() public method

public StartHost ( SecureString password, string profilePath, ILogger outputLogger, LogVerbosity verbosity ) : void
password System.Security.SecureString
profilePath string
outputLogger ILogger
verbosity LogVerbosity
return void
Example #1
0
        public Session CreateSession(string id, Interpreter interpreter, string commandLineArguments, bool isInteractive)
        {
            Session session;

            lock (_sessions) {
                var oldUserSessions = GetOrCreateSessionList();

                var oldSessions = oldUserSessions.Where(s => s.Id == id).ToArray();
                foreach (var oldSession in oldSessions)
                {
                    oldUserSessions.Remove(oldSession);
                    Task.Run(() => oldSession.KillHost()).SilenceException <Exception>().DoNotWait();
                    oldSession.State = SessionState.Terminated;
                }

                var userSessions = GetOrCreateSessionList();
                session = new Session(this, _processService, _applicationLifetime, _sessionLogger, _messageLogger, interpreter, id, commandLineArguments, isInteractive);
                session.StateChanged += Session_StateChanged;

                userSessions.Add(session);
            }

            session.StartHost(
                _loggingOptions.LogFolder,
                _loggingOptions.LogPackets || _loggingOptions.LogHostOutput ? LogVerbosity.Traffic : LogVerbosity.Minimal);

            return(session);
        }
Example #2
0
        public Session CreateSession(IIdentity user, string id, Interpreter interpreter, string profilePath, string commandLineArguments)
        {
            Session session;

            lock (_sessions) {
                if (_blockedUsers.Contains(user.Name))
                {
                    throw new InvalidOperationException(Resources.Error_BlockedByProfileDeletion.FormatInvariant(user.Name));
                }

                var oldUserSessions = GetOrCreateSessionList(user);

                var oldSessions = oldUserSessions.Where(s => s.Id == id).ToArray();
                foreach (var oldSession in oldSessions)
                {
                    oldUserSessions.Remove(oldSession);
                    Task.Run(() => oldSession.KillHost()).SilenceException <Exception>().DoNotWait();
                    oldSession.State = SessionState.Terminated;
                }

                var userSessions = GetOrCreateSessionList(user);
                session = new Session(this, user, id, interpreter, commandLineArguments, _sessionLogger, _messageLogger);
                session.StateChanged += Session_StateChanged;

                userSessions.Add(session);
            }

            session.StartHost(
                profilePath,
                _loggingOptions.LogFolder,
                _loggingOptions.LogHostOutput ? _hostOutputLogger : null,
                _loggingOptions.LogPackets || _loggingOptions.LogHostOutput ? LogVerbosity.Traffic : LogVerbosity.Minimal);

            return(session);
        }
Example #3
0
        public Session CreateSession(IIdentity user, string id, Interpreter interpreter, SecureString password, string commandLineArguments)
        {
            Session session;

            lock (_sessions) {
                List <Session> userSessions;
                _sessions.TryGetValue(user.Name, out userSessions);
                if (userSessions == null)
                {
                    _sessions[user.Name] = userSessions = new List <Session>();
                }

                var oldSession = userSessions.FirstOrDefault(s => s.Id == id);
                if (oldSession != null)
                {
                    oldSession.KillHost();
                    userSessions.Remove(oldSession);
                }

                session = new Session(this, user, id, interpreter, commandLineArguments);
                userSessions.Add(session);
            }

            session.StartHost(
                password,
                _loggingOptions.LogHostOutput ? _hostOutputLogger : null,
                _loggingOptions.LogPackets ? _messageLogger : null);

            return(session);
        }
Example #4
0
        public Session CreateSession(IIdentity user, string id, Interpreter interpreter, SecureString password, string profilePath, string commandLineArguments)
        {
            Session session;

            lock (_sessions) {
                var userSessions = GetOrCreateSessionList(user);

                var oldSession = userSessions.FirstOrDefault(s => s.Id == id);
                if (oldSession != null)
                {
                    try {
                        oldSession.KillHost();
                    } catch (Exception) { }

                    oldSession.State = SessionState.Terminated;
                }

                session = new Session(this, user, id, interpreter, commandLineArguments, _sessionLogger, _messageLogger);
                session.StateChanged += Session_StateChanged;

                userSessions.Add(session);
            }

            session.StartHost(
                password,
                profilePath,
                _loggingOptions.LogHostOutput ? _hostOutputLogger : null,
                _loggingOptions.LogPackets || _loggingOptions.LogHostOutput ? LogVerbosity.Traffic : LogVerbosity.Minimal);

            return(session);
        }
Example #5
0
        public Session CreateSession(IIdentity user, string id, Interpreter interpreter, SecureString password, string profilePath, string commandLineArguments)
        {
            Session session;

            lock (_sessions) {
                if (!NativeMethods.IsWindowsServer() && !IsUserAllowedToCreateSession(user))
                {
                    // This is Client Windows, only 1 user is allowed to create sessions at a time.
                    throw new BrokerMaxedUsersException(Resources.Exception_MaxAllowedUsers);
                }

                var userSessions = GetOrCreateSessionList(user);

                var oldSession = userSessions.FirstOrDefault(s => s.Id == id);
                if (oldSession != null)
                {
                    try {
                        oldSession.KillHost();
                    } catch (Exception) { }

                    oldSession.State = SessionState.Terminated;
                }

                session = new Session(this, user, id, interpreter, commandLineArguments, _sessionLogger, _messageLogger);
                session.StateChanged += Session_StateChanged;

                userSessions.Add(session);
            }

            session.StartHost(
                password,
                profilePath,
                _loggingOptions.LogHostOutput ? _hostOutputLogger : null,
                _loggingOptions.LogPackets || _loggingOptions.LogHostOutput ? LogVerbosity.Traffic : LogVerbosity.Minimal);

            return(session);
        }
Example #6
0
        public Session CreateSession(IIdentity user, string id, Interpreter interpreter, SecureString password, string profilePath, string commandLineArguments) {
            Session session;

            lock (_sessions) {
                if (_blockedUsers.Contains(user.Name)) {
                    throw new InvalidOperationException(Resources.Error_BlockedByProfileDeletion.FormatInvariant(user.Name));
                }

                var oldUserSessions = GetOrCreateSessionList(user);

                var oldSessions = oldUserSessions.Where(s => s.Id == id).ToArray();
                foreach (var oldSession in oldSessions) {
                    oldUserSessions.Remove(oldSession);
                    Task.Run(() => oldSession.KillHost()).SilenceException<Exception>().DoNotWait();
                    oldSession.State = SessionState.Terminated;
                }

                var userSessions = GetOrCreateSessionList(user);
                session = new Session(this, user, id, interpreter, commandLineArguments, _sessionLogger, _messageLogger);
                session.StateChanged += Session_StateChanged;

                userSessions.Add(session);
            }

            session.StartHost(
                password,
                profilePath,
                _loggingOptions.LogHostOutput ? _hostOutputLogger : null,
                _loggingOptions.LogPackets || _loggingOptions.LogHostOutput ? LogVerbosity.Traffic : LogVerbosity.Minimal);

            return session;
        }