Exemplo n.º 1
0
        public static void Main()
        {
            Debug.EnableGCMessages(false);
            Debug.Print("Web Server test software");

            _led = new OutputPort(Pins.ONBOARD_LED, false);

            _photoResistorPort = new AnalogInput(Cpu.AnalogChannel.ANALOG_0);
            _thermistorPort    = new AnalogInput(Cpu.AnalogChannel.ANALOG_1);

            _powerOutletStrip = new PowerOutletStrip();
            _powerOutletStrip.AddOutlet(1, new OutputPort(Pins.GPIO_PIN_D8, false));
            _powerOutletStrip.AddOutlet(2, new OutputPort(Pins.GPIO_PIN_D9, false));
            _powerOutletStrip.AddOutlet(3, new OutputPort(Pins.GPIO_PIN_D10, false));

            DebugNetworkInfo();

            RouteDispatcher routeDispatcher = InitRouteDispatcher();

            var httpServer = new HttpServer();

            httpServer.AddHttpHandler(routeDispatcher);
            httpServer.RunAsync();
            Thread.Sleep(Timeout.Infinite);
        }
Exemplo n.º 2
0
        private static RouteDispatcher InitRouteDispatcher()
        {
            var routeDispatcher = new RouteDispatcher();

            routeDispatcher.Add(new Route("/time", HttpMethod.Get, GetTime));
            routeDispatcher.Add(new Route("/led", HttpMethod.Get, ChangeLedStatus));
            routeDispatcher.Add(new Route("/debugquery", HttpMethod.Get, DebugQuery));
            routeDispatcher.Add(new Route("/outlet", HttpMethod.Get, ChangeOutletStatus));
            routeDispatcher.Add(new Route("/luminosite", HttpMethod.Get, GetLuminosite));
            routeDispatcher.Add(new Route("/temperature", HttpMethod.Get, GetTemperature));
            return(routeDispatcher);
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            var requestDispatcher = new RequestDispatcher();

            var routingConfig        = new RoutingConfig();
            var createCutomerCommand = new CreateCustomerCommand();

            routingConfig.Register(createCutomerCommand.MessageType, new Tuple <Parse, DispatchCommand>(createCutomerCommand.Parse, requestDispatcher.CreateCustomer));

            var placeOrderCommand = new PlaceOrderCommand();

            routingConfig.Register(placeOrderCommand.MessageType,
                                   new Tuple <Parse, DispatchCommand>(placeOrderCommand.Parse, requestDispatcher.PlaceOrder));

            var routeDispatcher = new RouteDispatcher(routingConfig);

            var server = new SocketServer(new IPEndPoint(IPAddress.Loopback, 11000),
                                          routeDispatcher.Dispatch);

            server.StartListening();

            Console.ReadKey();
        }
Exemplo n.º 4
0
 public IMessage Handle(Update hook)
 {
     return(RouteDispatcher.GetMessageInstance(hook.CallbackQuery.Data));
 }