示例#1
0
        public static void Init(ServerInitializer initializer)
        {
            if (Interlocked.CompareExchange(ref model, new ServerModel(), null) != null)
            {
                throw new InvalidOperationException("model already inited");
            }

            Server = new AsyncServer();
            API    = initializer.API ?? new StandardServerAPI();

            Plugins = new ServerPluginManager(initializer.PluginsPath);
            Plugins.LoadPlugins(initializer.ExcludedPlugins);
        }
示例#2
0
        public static void Init(ServerInitializer initializer)
        {
            if (Interlocked.CompareExchange(ref _chat, new ServerChat(), null) != null)
            {
                throw new InvalidOperationException("model already inited");
            }

            Api    = new ServerApi(initializer.AdminPassword);
            Server = new AsyncServer(Api, _notifier, Logger);

            Plugins = new ServerPluginManager(initializer.PluginsPath);
            Plugins.LoadPlugins(initializer.ExcludedPlugins);
        }
示例#3
0
        static void Main(string[] args)
        {
            int serverPort;
              int servicePort;
              bool usingIpV6;

              if (args.Length < 3)
              {
            Console.WriteLine("Parameters: \"serverPort\" \"servicePort\" \"usingIpV6\"");
            return;
              }

              if (!int.TryParse(args[0], out serverPort))
              {
            Console.WriteLine("Parameters: \"serverPort\" \"servicePort\" \"usingIpV6\"");
            return;
              }

              if (!int.TryParse(args[1], out servicePort))
              {
            Console.WriteLine("Parameters: \"serverPort\" \"servicePort\" \"usingIpV6\"");
            return;
              }

              if (!bool.TryParse(args[2], out usingIpV6))
              {
            Console.WriteLine("Parameters: \"serverPort\" \"servicePort\" \"usingIpV6\"");
            return;
              }

              var initializer = new ServerInitializer
              {
            PluginsPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "plugins"),
            ExcludedPlugins = new string[0]
              };

              ServerModel.Init(initializer);
              ServerModel.Server.Start(serverPort, servicePort, usingIpV6);

              Console.WriteLine("Enter \"exit\" for server stop");

              while (true)
              {
            var command = Console.ReadLine();
            if (string.Equals(command, "exit", StringComparison.OrdinalIgnoreCase))
              break;
              }

              ServerModel.Reset();
        }
示例#4
0
        public static void Init(ServerInitializer initializer)
        {
            if (!initializer.Certificate.HasPrivateKey)
            {
                throw new ArgumentException("Initializer should have certificate with private key.");
            }

            if (Interlocked.CompareExchange(ref _chat, new ServerChat(), null) != null)
            {
                throw new InvalidOperationException("model already inited");
            }

            Api    = new ServerApi(initializer.AdminPassword);
            Server = new AsyncServer(initializer.Certificate, Api, _notifier, Logger);

            Plugins = new ServerPluginManager(initializer.PluginsPath);
            Plugins.LoadPlugins(initializer.ExcludedPlugins);
        }
示例#5
0
        public static void Init(ServerInitializer initializer)
        {
            if (Interlocked.CompareExchange(ref model, new ServerModel(), null) != null)
            throw new InvalidOperationException("model already inited");

              Server = new AsyncServer();
              API = initializer.API ?? new StandardServerAPI();

              Plugins = new ServerPluginManager(initializer.PluginsPath);
              Plugins.LoadPlugins(initializer.ExcludedPlugins);
        }
示例#6
0
        private void EnableServer(object obj)
        {
            var dialog = new ServerDialog();
              if (dialog.ShowDialog() != true)
            return;

              try
              {
            var excludedPlugins = Settings.Current.Plugins
              .Where(s => !s.Enabled)
              .Select(s => s.Name)
              .ToArray();

            var initializer = new ServerInitializer
            {
              PluginsPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "plugins"),
              ExcludedPlugins = excludedPlugins
            };

            ServerModel.Init(initializer);
            ServerModel.Server.Start(Settings.Current.Port, Settings.Current.ServicePort, Settings.Current.StateOfIPv6Protocol);

            InitializeClient(true);
              }
              catch (ArgumentException)
              {
            SelectedRoom.AddSystemMessage(Localizer.Instance.Localize(ParamsErrorKey));

            if (ClientModel.IsInited)
              ClientModel.Reset();

            if (ServerModel.IsInited)
              ServerModel.Reset();
              }
        }