Beispiel #1
0
        public SessionManager(Config config, ProtocolManagerFactory protocolManagerFactory)
        {
            Trace.Call(config, protocolManagerFactory);

            if (config == null) {
                throw new ArgumentNullException("config");
            }
            if (protocolManagerFactory == null) {
                throw new ArgumentNullException("protocolManagerFactory");
            }

            _Config = config;
            _ProtocolManagerFactory = protocolManagerFactory;

            EngineAssemblyVersion = Engine.AssemblyVersion;
            EngineProtocolVersion = Engine.ProtocolVersion;

            string[] users = (string[])Engine.Config["Engine/Users/Users"];
            if (users == null) {
                Console.WriteLine("No Engine/Users/*, aborting...\n");
                Environment.Exit(1);
            }
            foreach (string user in users) {
                // skip local session
                if (user == "local") {
                    continue;
                }
            #if LOG4NET
                _Logger.Debug("Creating Session for User "+user);
            #endif
                var session = new Session(_Config, _ProtocolManagerFactory, user);
                session.ExecuteOnStartupCommands();
                session.ProcessAutoConnect();
                _Sessions.Add(user, session);
            }
        }
Beispiel #2
0
 public static void InitLocalEngine()
 {
     if (!Engine.Engine.IsInitialized) {
         // only initialize a local engine once
         Engine.Engine.Init();
         _LocalSession = new Engine.Session(Engine.Engine.Config,
                                            Engine.Engine.ProtocolManagerFactory,
                                            "local");
         _LocalSession.ExecuteOnStartupCommands();
         _LocalSession.ProcessAutoConnect();
     }
     EngineAssemblyVersion = Engine.Engine.AssemblyVersion;
     EngineProtocolVersion = Engine.Engine.ProtocolVersion;
     Session = _LocalSession;
     _UserConfig = _Session.UserConfig;
 }
Beispiel #3
0
 public static void InitLocalEngine()
 {
     Engine.Engine.Init();
     _EngineVersion = Engine.Engine.Version;
     _Session = new Engine.Session(Engine.Engine.Config,
                                   Engine.Engine.ProtocolManagerFactory,
                                   "local");
     _Session.ExecuteOnStartupCommands();
     _Session.ProcessAutoConnect();
     _Session.RegisterFrontendUI(_MainWindow.UI);
     _UserConfig = _Session.UserConfig;
     ConnectEngineToGUI();
 }
Beispiel #4
0
        public static void Init(string[] args)
        {
            System.Threading.Thread.CurrentThread.Name = "Main";

            if (!(args.Length >= 1)) {
                Console.Error.WriteLine("Usage: smuxi-test.exe profile");
                Environment.Exit(1);
            }

            #if LOG4NET
            _Logger.Info("smuxi-test starting");
            #endif

            _FrontendConfig = new FrontendConfig("Test");
            _FrontendConfig.Load();

            string profile = args[0];
            if (String.IsNullOrEmpty(profile)) {
                Console.Error.WriteLine("profile parameter must not be empty!");
                Environment.Exit(1);
            }

            IFrontendUI ui = new TestUI();

            Session session = null;
            if (profile == "local") {
                Engine.Engine.Init();
                session = new Engine.Session(Engine.Engine.Config,
                                             Engine.Engine.ProtocolManagerFactory,
                                             "local");
                session.ExecuteOnStartupCommands();
                session.ProcessAutoConnect();
                session.RegisterFrontendUI(ui);
            } else {
                // remote engine
                EngineManager engineManager = new EngineManager(_FrontendConfig, ui);
                engineManager.Connect(profile);
                session = engineManager.Session;
            }

            if (session == null) {
                Console.Error.WriteLine("Session is null, something went wrong setting up or connecting to the engine!");
                Environment.Exit(1);
            }

            _Session = session;
            _UserConfig = session.UserConfig;
            _FrontendManager = session.GetFrontendManager(ui);
            _FrontendManager.Sync();

            if (_UserConfig.IsCaching) {
                // when our UserConfig is cached, we need to invalidate the cache
                _FrontendManager.ConfigChangedDelegate = new SimpleDelegate(_UserConfig.ClearCache);
            }

            while (true) {
                string line = Console.ReadLine();
                // TODO: remove the entered line from output
                //Console.WriteLine(Escape+"M");

                _ExecuteCommand(line);
            }
        }