コード例 #1
0
        public void BindServer(ITorchServer server)
        {
            _server      = (TorchBase)server;
            _multiplayer = (MultiplayerManager)server.Multiplayer;
            DataContext  = _multiplayer;

            ChatItems.Inlines.Clear();
            _multiplayer.ChatHistory.ForEach(InsertMessage);
            if (_multiplayer.ChatHistory is INotifyCollectionChanged ncc)
            {
                ncc.CollectionChanged += ChatHistory_CollectionChanged;
            }
            ChatScroller.ScrollToBottom();
        }
コード例 #2
0
ファイル: ChatControl.xaml.cs プロジェクト: thakyZ/Torch
        private void Server_Initialized(ITorchServer obj)
        {
            Dispatcher.InvokeAsync(() =>
            {
                ChatItems.Inlines.Clear();
            });

            var sessionManager = _server.Managers.GetManager <ITorchSessionManager>();

            if (sessionManager != null)
            {
                sessionManager.SessionStateChanged += SessionStateChanged;
            }
        }
コード例 #3
0
        public void BindServer(ITorchServer server)
        {
            _server = server;

            server.Initialized += Server_Initialized;
        }
コード例 #4
0
        private void Server_Initialized(ITorchServer obj)
        {
            var sessionManager = _server.Managers.GetManager <ITorchSessionManager>();

            sessionManager.SessionStateChanged += SessionStateChanged;
        }
コード例 #5
0
        public static void RunServer(TorchConfig config)
        {
            /*
             * if (!parser.ParseArguments(args, config))
             * {
             *  _log.Error($"Parsing arguments failed: {string.Join(" ", args)}");
             *  return;
             * }
             *
             * if (!string.IsNullOrEmpty(config.Config) && File.Exists(config.Config))
             * {
             *  config = ServerConfig.LoadFrom(config.Config);
             *  parser.ParseArguments(args, config);
             * }*/

            //RestartOnCrash autostart autosave=15
            //gamepath ="C:\Program Files\Space Engineers DS" instance="Hydro Survival" instancepath="C:\ProgramData\SpaceEngineersDedicated\Hydro Survival"

            /*
             * if (config.InstallService)
             * {
             *  var serviceName = $"\"Torch - {config.InstanceName}\"";
             *  // Working on installing the service properly instead of with sc.exe
             *  _log.Info($"Installing service '{serviceName}");
             *  var exePath = $"\"{Assembly.GetExecutingAssembly().Location}\"";
             *  var createInfo = new ServiceCreateInfo
             *  {
             *      Name = config.InstanceName,
             *      BinaryPath = exePath,
             *  };
             *  _log.Info("Service Installed");
             *
             *  var runArgs = string.Join(" ", args.Skip(1));
             *  _log.Info($"Installing Torch as a service with arguments '{runArgs}'");
             *  var startInfo = new ProcessStartInfo
             *  {
             *      FileName = "sc.exe",
             *      Arguments = $"create Torch binPath=\"{Assembly.GetExecutingAssembly().Location} {runArgs}\"",
             *      CreateNoWindow = true,
             *      UseShellExecute = true,
             *      Verb = "runas"
             *  };
             *  Process.Start(startInfo).WaitForExit();
             *  _log.Info("Torch service installed");
             *  return;
             * }
             *
             * if (config.UninstallService)
             * {
             *  _log.Info("Uninstalling Torch service");
             *  var startInfo = new ProcessStartInfo
             *  {
             *      FileName = "sc.exe",
             *      Arguments = "delete Torch",
             *      CreateNoWindow = true,
             *      UseShellExecute = true,
             *      Verb = "runas"
             *  };
             *  Process.Start(startInfo).WaitForExit();
             *  _log.Info("Torch service uninstalled");
             *  return;
             * }*/

            _server = new TorchServer(config);

            _server.Init();
            if (config.NoGui || config.Autostart)
            {
                new Thread(() => _server.Start()).Start();
            }

            if (!config.NoGui)
            {
                var ui = new TorchUI((TorchServer)_server);
                ui.ShowDialog();
            }
        }
コード例 #6
0
        public static void Main(string[] args)
        {
            if (!Environment.UserInteractive)
            {
                using (var service = new TorchService())
                {
                    ServiceBase.Run(service);
                }
                return;
            }

            var         configName = /*args.FirstOrDefault() ??*/ "TorchConfig.xml";
            var         configPath = Path.Combine(Directory.GetCurrentDirectory(), configName);
            TorchConfig options;

            if (File.Exists(configName))
            {
                _log.Info($"Loading config {configPath}");
                options = TorchConfig.LoadFrom(configPath);
            }
            else
            {
                _log.Info($"Generating default config at {configPath}");
                options = new TorchConfig();
                options.Save(configPath);
            }

            bool gui = true;

            foreach (var arg in args)
            {
                switch (arg)
                {
                case "-noupdate":
                    options.EnableAutomaticUpdates = false;
                    break;

                case "-nogui":
                    gui = false;
                    break;
                }
            }

            /*
             * if (!parser.ParseArguments(args, options))
             * {
             *  _log.Error($"Parsing arguments failed: {string.Join(" ", args)}");
             *  return;
             * }
             *
             * if (!string.IsNullOrEmpty(options.Config) && File.Exists(options.Config))
             * {
             *  options = ServerConfig.LoadFrom(options.Config);
             *  parser.ParseArguments(args, options);
             * }*/

            //RestartOnCrash autostart autosave=15
            //gamepath ="C:\Program Files\Space Engineers DS" instance="Hydro Survival" instancepath="C:\ProgramData\SpaceEngineersDedicated\Hydro Survival"

            /*
             * if (options.InstallService)
             * {
             *  var serviceName = $"\"Torch - {options.InstanceName}\"";
             *  // Working on installing the service properly instead of with sc.exe
             *  _log.Info($"Installing service '{serviceName}");
             *  var exePath = $"\"{Assembly.GetExecutingAssembly().Location}\"";
             *  var createInfo = new ServiceCreateInfo
             *  {
             *      Name = options.InstanceName,
             *      BinaryPath = exePath,
             *  };
             *  _log.Info("Service Installed");
             *
             *  var runArgs = string.Join(" ", args.Skip(1));
             *  _log.Info($"Installing Torch as a service with arguments '{runArgs}'");
             *  var startInfo = new ProcessStartInfo
             *  {
             *      FileName = "sc.exe",
             *      Arguments = $"create Torch binPath=\"{Assembly.GetExecutingAssembly().Location} {runArgs}\"",
             *      CreateNoWindow = true,
             *      UseShellExecute = true,
             *      Verb = "runas"
             *  };
             *  Process.Start(startInfo).WaitForExit();
             *  _log.Info("Torch service installed");
             *  return;
             * }
             *
             * if (options.UninstallService)
             * {
             *  _log.Info("Uninstalling Torch service");
             *  var startInfo = new ProcessStartInfo
             *  {
             *      FileName = "sc.exe",
             *      Arguments = "delete Torch",
             *      CreateNoWindow = true,
             *      UseShellExecute = true,
             *      Verb = "runas"
             *  };
             *  Process.Start(startInfo).WaitForExit();
             *  _log.Info("Torch service uninstalled");
             *  return;
             * }*/

            _server = new TorchServer(options);
            _server.Init();
            if (gui)
            {
                var ui = new TorchUI((TorchServer)_server);
                ui.LoadConfig(options);
                ui.ShowDialog();
            }
            else
            {
                _server.Start();
            }
        }
コード例 #7
0
ファイル: ChatControl.xaml.cs プロジェクト: carlosmaid/Torch
 public void BindServer(ITorchServer server)
 {
     _server = server;
     server.Multiplayer.MessageReceived += Refresh;
 }
コード例 #8
0
        public void BindServer(ITorchServer server)
        {
            var pluginManager = new PluginManagerViewModel(server.Plugins);

            DataContext = pluginManager;
        }
コード例 #9
0
ファイル: PlayerListControl.xaml.cs プロジェクト: susu/Torch
 public void BindServer(ITorchServer server)
 {
     _server     = server;
     DataContext = (MultiplayerManager)_server.Multiplayer;
 }