Exemple #1
0
        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            if (!DesignerProperties.GetIsInDesignMode(this))
            {
                ServerPluginHost host = (ServerPluginHost)DataContext;
                host.CollectionChanged += Plugins_CollectionChanged;

                CheckAvailable();
            }
        }
Exemple #2
0
        public AresServer(AresServerConfig config)
        {
            this.Config = config ??
                          throw new ArgumentNullException("config", "Server configuration cannot be null.");

            ticklength = TimeSpan.FromSeconds(1);

            Stats = new AresServerStats();
            Users = new ModelList <IClient>();

            Channels = new AresChannels {
                Server   = this,
                Channels = Persistence.LoadModel <ModelList <AresChannel> >(Path.Combine(config.Directories.AppData, "channels.json"))
            };

            if (Channels.Channels.Count == 0)
            {
                Channels.LoadFromDatFile();
            }

            PluginHost = new ServerPluginHost(this);

            idpool = new SortedStack <ushort>();
            idpool.SetSort((a, b) => (a - b));

            pending     = new List <PendingConnection>();
            flood_rules = new List <IFloodRule>();

            History = Persistence.LoadModel <AresUserHistory>(Path.Combine(config.Directories.AppData, "history.json"));
            History.Admin.Load(this);

            Logging.WriteLines(
                LogLevel.Info,
                "AresServer",
                new[] {
                "Chatroom configuration applied.",
                "Listen Port: {0}",
                "Using UDP Channels: {1}",
                "Allow TCP Connections: {2}",
                "Allow WebSocket Connections: {3}",
                "Listen for TLS Connections: {4}"
            },
                config.Port,
                config.UseUdpSockets,
                config.UseTcpSockets,
                config.UseWebSockets,
                config.UseTlsSockets);
        }
Exemple #3
0
        private void BtnLoad_Click(object sender, RoutedEventArgs e)
        {
            if (!(lvAvailable.SelectedItem is AvailablePlugin p))
            {
                return;
            }

            ServerPluginHost host = (ServerPluginHost)DataContext;

            if (p.Plugin != null && p.Plugin.Enabled)
            {
                host.KillPlugin(p.Name);
                btnLoad.Content = "Load";
            }
            else if (host.LoadPlugin(p.Name))
            {
                btnLoad.Content = "Unload";
            }

            CheckAvailable();
        }
Exemple #4
0
        void CheckAvailable()
        {
            ServerPluginHost host = (ServerPluginHost)DataContext;

            foreach (var dir in new DirectoryInfo(host.BaseDirectory).GetDirectories())
            {
                string file = System.IO.Path.Combine(dir.FullName, dir.Name + ".dll");

                if (File.Exists(file))
                {
                    var pname = files.Find((s) => s.Name == dir.Name);

                    if (pname == null)
                    {
                        pname = new AvailablePlugin(dir.Name);
                        files.Add(pname);
                    }

                    pname.Plugin = host.Find((s) => s.Name == dir.Name);
                }
            }
        }
Exemple #5
0
        private void UserControl_Unloaded(object sender, RoutedEventArgs e)
        {
            ServerPluginHost host = (ServerPluginHost)DataContext;

            host.CollectionChanged -= Plugins_CollectionChanged;
        }