Ejemplo n.º 1
0
        //TemperatureSensors tempSensors;

        public HttpRestServer(int serverPort, AppServiceConnection connection, SprinklerValveController sprinkler, SprinklerProgramController program)//, TemperatureSensors temp)
        {
            listener = new StreamSocketListener();
            port = serverPort;
            appServiceConnection = connection;
            sprinklerController = sprinkler;
            programController = program;
            //tempSensors = temp;

            //Add event handler for HTTP connections
            listener.ConnectionReceived += (s, e) => ProcessRequestAsync(e.Socket);

            System.Diagnostics.Debug.WriteLine("Sprinkler HTTP REST server starting...");
        }
Ejemplo n.º 2
0
        private void Initialize()
        {
            valveController = new SprinklerValveController();
            programController = new SprinklerProgramController(valveController);

            //Define a new instance of our HTTPServer on Port 8888
            HttpRestServer server = new HttpRestServer(8888, appServiceConnection, valveController, programController);//, tempSensors);
            IAsyncAction asyncAction = Windows.System.Threading.ThreadPool.RunAsync(
                (workItem) =>
                {   //Start the Sever
                                server.StartServer();
                });

            WebServer webServer = new WebServer(8889);
            IAsyncAction asyncAction2 = Windows.System.Threading.ThreadPool.RunAsync(
                (workItem) =>
                {   //Start the Sever
                    webServer.StartServer();
                });


        }