Esempio n. 1
0
        /// <summary>
        /// Creates a default WebEvent.
        /// </summary>
        internal WebEvent()
        {
            noHandlerSet = true;
            this.manager = WebServerManager.Instance;

            ContentType = "text/plain;charset=utf-8";
        }
Esempio n. 2
0
        /// <summary>
        /// Creates a default WebEvent.
        /// </summary>
        internal WebEvent()
        {
            noHandlerSet = true;
            this.manager = WebServerManager.Instance;

            ContentType = "text/plain;charset=utf-8";
        }
Esempio n. 3
0
 ///<summary>
 /// Stops the server and removes all added resources.
 ///</summary>
 public static void StopLocalServer()
 {
     if (WebServerManager.GetInstance().ServerIsRunning())
     {
         WebServerManager.GetInstance().StopAll();
     }
 }
        /// <summary>
        /// Gets the WebServerManager instance, which is handled as a singleton.
        /// </summary>
        /// <returns>The <see cref="T:GTM.NetworkModule.WebServerManager"/> instance</returns>
        static WebServerManager()
        {
            Instance = new WebServerManager();
            Instance.DefaultEvent = new WebEvent();
            Instance.DefaultEvent.ResponseData = Encoding.UTF8.GetBytes("<html><head></head><body><h1>Hey, it works:-)</h1><p>Your own .NET Gadgeteer Web Server is up and running!</p></body></html>");
            Instance.DefaultEvent.ContentType  = "text/html;charset=utf-8";

            Timeout = 60000;
        }
Esempio n. 5
0
        /// <summary>
        /// Gets the WebServerManager instance, which is handled as a singleton. 
        /// </summary>
        /// <returns>The <see cref="T:GTM.NetworkModule.WebServerManager"/> instance</returns>
        static WebServerManager()
        {
            Instance = new WebServerManager();
            Instance.DefaultEvent = new WebEvent();
            Instance.DefaultEvent.ResponseData = Encoding.UTF8.GetBytes("<html><head></head><body><h1>Hey, it works:-)</h1><p>Your own .NET Gadgeteer Web Server is up and running!</p></body></html>");
            Instance.DefaultEvent.ContentType = "text/html;charset=utf-8";

            Timeout = 60000;
        }
Esempio n. 6
0
        /// <summary>
        /// Creates a path on the server so that an http GET request can be processed.
        /// Specifies a path of the form: http://{IP}:{port}/{path}.
        /// </summary>
        /// <param name="path">The path used to identify a resource.</param>
        /// <returns>A <see cref="T:GTM.NetworkModule.WebEvent"/> object that is used to update data and respond to incoming requests.
        /// </returns>
        public static WebEvent SetupWebEvent(string path)
        {
            WebEvent webEvent = WebServerManager.GetInstance().GetWebEventById(path);

            if (webEvent == null)
            {
                webEvent = new WebEvent(path);
            }
            return(webEvent);
        }
        ///<summary>
        /// Creates a WebEvent with the given path.
        ///</summary>
        ///<param name="path">A string that identifies the event when an http request is received.</param>
        internal WebEvent(string path)
        {
            noHandlerSet = true;

            this.Path    = path;
            this.manager = WebServerManager.GetInstance();
            manager.AddWebEvent(this);

            ContentType = "text/plain";
        }
Esempio n. 8
0
        ///<summary>
        /// Creates a WebEvent with the given path.
        ///</summary>
        ///<param name="path">A string that identifies the event when an http request is received.</param>
        internal WebEvent(string path)
        {
            noHandlerSet = true;

            this.Path = path;
            this.manager = WebServerManager.GetInstance();
            manager.AddWebEvent(this);

            ContentType = "text/plain";
        }
Esempio n. 9
0
        /// <summary>
        /// Creates a path to a resource on the server so that a http GET requests can be processed.
        /// Specifies the path of the form: http://{IP}:{port}/{path}.
        /// </summary>
        /// <param name="path">The path used to identify a resource.</param>
        /// <param name="refreshAfter">Specifies the refresh interval in seconds.</param>
        /// <returns>A <see cref="WebEvent"/> object that is used to update data and respond to incoming requests.
        /// </returns>
        public static WebEvent SetupWebEvent(string path, uint refreshAfter)
        {
            WebEvent webEvent = WebServerManager.GetInstance().GetWebEventById(path);

            if (webEvent == null)
            {
                webEvent = new WebEvent(path);
            }
            webEvent.refreshAfter = refreshAfter;
            return(webEvent);
        }
Esempio n. 10
0
        /// <summary>
        /// Gets the WebServerManager instance, which is handled as a singleton.
        /// </summary>
        /// <returns>The <see cref="T:GTM.NetworkModule.WebServerManager"/> instance</returns>
        public static WebServerManager GetInstance()
        {
            if (serverManager == null)
            {
                serverManager = new WebServerManager();
                serverManager.DefaultEvent = new WebEvent("index.html");
                serverManager.DefaultEvent.ResponseData = Encoding.UTF8.GetBytes("<html><head></head><body><h1>Hey, it works:-)</h1><p>Your own .NET Gadgeteer Web Server is up and running!</p></body></html>");
                serverManager.DefaultEvent.ContentType  = "text/html";

                Timeout = 60000;

                return(serverManager);
            }
            else
            {
                return(serverManager);
            }
        }
Esempio n. 11
0
        /// <summary>
        /// Gets the WebServerManager instance, which is handled as a singleton. 
        /// </summary>
        /// <returns>The <see cref="T:GTM.NetworkModule.WebServerManager"/> instance</returns>
        public static WebServerManager GetInstance()
        {
            if (serverManager == null)
            {
                serverManager = new WebServerManager();
                serverManager.DefaultEvent = new WebEvent();
                serverManager.DefaultEvent.ResponseData = Encoding.UTF8.GetBytes("<html><head></head><body><h1>Hey, it works:-)</h1><p>Your own .NET Gadgeteer Web Server is up and running!</p></body></html>");
                serverManager.DefaultEvent.ContentType = "text/html;charset=utf-8";

                Timeout = 60000;

                return serverManager;
            }
            else
            {
                return serverManager;
            }
        }
Esempio n. 12
0
 /// <summary>
 /// Creates the <see cref="Server"/> object.
 /// </summary>
 /// <param name="WebServerManager">The WebServerManager object that manages the server.</param>
 public Server(WebServerManager WebServerManager)
 {
     this.WebServerManager = WebServerManager;
 }
Esempio n. 13
0
 ///<summary>
 /// Starts the web server and configures the network for the specified port.
 ///</summary>
 ///<param name="ipAddress">Ip address of the server</param>
 ///<param name="port">An <see cref="T:System.int"/> that specifies a port on which the web server runs.</param>
 ///<remarks>
 /// The server starts automatically when a resource is shared and the network interface is
 /// up. If this does not happen, stop the server before sharing data.
 /// </remarks>
 public static void StartLocalServer(string ipAddress, int port)
 {
     _ipAddress = ipAddress;
     _port      = port;
     WebServerManager.GetInstance().StartServer(_ipAddress, _port);
 }
Esempio n. 14
0
 ///<summary>
 /// Stops and removes a single resource. If the resource is requesterd again, the server will return the default page.
 ///</summary>
 ///<param name="webEvent">The <see cref="WebEvent"/> to be stopped</param>
 ///<returns>The result of the operation, <b>true</b> if the resource is found and removed, otherwise <b>false</b>.</returns>
 public static bool DisableWebEvent(WebEvent webEvent)
 {
     return(WebServerManager.GetInstance().Stop(webEvent));
 }
Esempio n. 15
0
 /// <summary>
 /// Creates the <see cref="Server"/> object. 
 /// </summary>
 /// <param name="WebServerManager">The WebServerManager object that manages the server.</param>
 public Server(WebServerManager WebServerManager)
 {
     this.WebServerManager = WebServerManager;
 }