Beispiel #1
0
        /// <summary>
        /// Initialise the socket server if necessary
        /// </summary>
        internal void InitAndStartSocket()
        {
            if (socketServer == null)
            {
                WifiRemote.LogMessage("Setting up socket server", LogType.Debug);

                String userName = null;
                String password = null;
                String passcode = null;
                AuthMethod auth = AuthMethod.None;
                int autologinTimeout = 0;
                bool showNotification = false;

                // Load port from config
                using (MediaPortal.Profile.Settings reader = new MediaPortal.Profile.Settings(Config.GetFile(Config.Dir.Config, "MediaPortal.xml")))
                {
                    port = (UInt16)reader.GetValueAsInt(PLUGIN_NAME, "port", DEFAULT_PORT);
                    disableBonjour = reader.GetValueAsBool(PLUGIN_NAME, "disableBonjour", false);
                    serviceName = reader.GetValueAsString(PLUGIN_NAME, "serviceName", "");
                    userName = reader.GetValueAsString(PLUGIN_NAME, "username", "");
                    userName = WifiRemote.DecryptString(userName);
                    password = reader.GetValueAsString(PLUGIN_NAME, "password", "");
                    password = WifiRemote.DecryptString(password);
                    passcode = reader.GetValueAsString(PLUGIN_NAME, "passcode", "");
                    passcode = WifiRemote.DecryptString(passcode);

                    auth = (AuthMethod)reader.GetValueAsInt(PLUGIN_NAME, "auth", 0);
                    autologinTimeout = reader.GetValueAsInt(PLUGIN_NAME, "autologinTimeout", 0);

                    showNotification = reader.GetValueAsBool(PLUGIN_NAME, "showNotifications", false);

                }

                // Start listening for client connections
                socketServer = new SocketServer(port);
                socketServer.UserName = userName;
                socketServer.Password = password;
                socketServer.PassCode = passcode;
                socketServer.AllowedAuth = auth;
                socketServer.AutologinTimeout = autologinTimeout;
                socketServer.ShowNotifications = showNotification;
            }

            socketServer.Start();
        }
Beispiel #2
0
        /// <summary>
        /// Plugin stopped
        /// </summary>
        public void Stop()
        {
            // Stop the socket server
            if (socketServer != null)
            {
                socketServer.Stop();
                socketServer = null;
            }

            // Stop the service if it is running
            if (servicePublished)
            {
                publishService.Stop();
                publishService = null;
            }
        }