AddDatabase() public méthode

public AddDatabase ( Database db ) : void
db Database
Résultat void
Exemple #1
0
        public static void Run()
        {
            InitializeLogging ();

            if (!File.Exists (ConfigPath)) {
                log.WarnFormat ("Config file '{0}' was not found, using defaults", ConfigPath);
            }

            AppDomain.CurrentDomain.UnhandledException += OnUnhandledException;

            #if LINUX || MACOSX
            UnixSignal.RegisterHandler (Signum.SIGTERM, OnSignal);
            UnixSignal.RegisterHandler (Signum.SIGINT, OnSignal);
            UnixSignal.Start ();
            #else
            Application.EnableVisualStyles ();
            Application.SetCompatibleTextRenderingDefault (false);
            #endif

            server = new Server (Name);
            server.UserLogin += OnUserLogin;
            server.UserLogout += OnUserLogout;
            server.Port = Port;
            server.IsPublished = IsPublished;
            server.Collision += OnCollision;
            db = new Database (Name);
            server.AddDatabase (db);
            server.MaxUsers = MaxUsers;

            server.TrackRequested += OnTrackRequested;

            log.Info ("Server name: " + Name);

            PluginManager.LoadPlugins (PluginNames);

            #if LINUX
            if (Inotify.Enabled) {
                Inotify.Start ();
            }
            #endif

            AddUsers ();

            try {
                lock (server) {
                    server.Commit ();
                    server.Start ();
                }
            } catch (Exception e) {
                LogError ("Failed to start server", e);
                Shutdown ();
            }

            RunLoop ();
            Shutdown ();
        }
Exemple #2
0
    public static void Main(string[] args)
    {
        string server_name = "Sample Server";
        string database_name = "Sample Database";
        ushort port = 3689;

        Database db = new Database (database_name);

        for (int i = 0; i < args.Length; i++) {
            if (args[i] == "--port") {
                port = Convert.ToUInt16 (args[++i]);
                continue;
            }

            if (args[i] == "--server-name") {
                server_name = args[++i];
                continue;
            }

            if (args[i] == "--database-name") {
                database_name = args[++i];
                continue;
            }

            if (args[i] == "--help") {
                ShowHelp ();
                return;
            }

            AddDirectory (db, args[i]);
        }

        db.Name = database_name;

           server = new Server (server_name);
        server.Collision += OnCollision;
        server.Port = port;

        Playlist pl = new Playlist ("foo playlist");
        foreach (Track track in db.Tracks) {
            pl.AddTrack (track);
        }

        db.AddPlaylist (pl);

        Console.WriteLine ("Done adding files");
        Console.WriteLine ("Starting Server '{0}' on Port {1}",
            server.Name, server.Port);
        server.AddDatabase (db);
        server.Commit ();
        server.Start ();
        Console.ReadLine ();

        server.Stop ();
    }