Exemple #1
0
        /// <summary>
        /// 
        /// </summary>
        public Core()
        {
            Utils.Logger.Log(Utils.Logger.Level.Info, "cloudmusic2upnp version " +
                System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString() + " started"
            );

            HackMonoProxyIssue();

            UPnP = new DeviceController.UPnP.Controller(Utils.Config.Load().LanInterfaceId);
            Providers = new ContentProvider.Providers();
            WebInterface = new UserInterface.Web.Interface(UPnP, Providers);
            WebInterface.Start();

            // catch Strg+C, console quit's and SIGKILL's and free up the C++-UPnP-lib first
            AppDomain appDomain = AppDomain.CurrentDomain;
            appDomain.ProcessExit += new EventHandler(HandleShutdownRequest);
            Console.CancelKeyPress += HandleShutdownRequest;

            WebInterface.OnPlayRequest += HandleOnPlayRequest;
            WebInterface.OnSearchRequest += HandleOnSearchRequest;

            //add all device controller to the playlist singleton
            Playlist.Active.AddDeviceController(UPnP);

            Playlist.Active.ItemAdded += HandlePlaylistChanged;
            Playlist.Active.ItemRemoved += HandlePlaylistChanged;
        }
        /*
         * Methods
         */
        public Interface(DeviceController.IController controller,
                          ContentProvider.Providers providers)
        {
            Controller = controller;
            Providers = providers;
            Clients = new Dictionary<IWebClient, IDevice>();
            KnownDevices = new Dictionary<string, IDevice>();

            WebSocketManager = new WebSocket.Manger(WEBSOCKET_PORT);
            WebSocketManager.ClientConnect += HandleClientConnect;
            WebSocketManager.ClientDisconnect += HandleClientDisconnect;
            WebSocketManager.ClientMessage += HandleClientMessage;

            Controller.DeviceDiscovery += HandleDeviceDiscovery;
        }