Ejemplo n.º 1
0
 public WSSessionManager(
     IPEndPoint endpoint, 
     CommandProcessorJson commandprocessor,
     IFormatter formatter)
     : base (commandprocessor, formatter)
 {
     listener = new WebSocketListener(endpoint);
     WebSocketFactoryRfc6455 standard = new WebSocketFactoryRfc6455(listener);
     listener.Standards.RegisterStandard(standard);
 }
Ejemplo n.º 2
0
        public RoadplusService(Settings settings)
        {
            if (settings == null)
            {
                throw new ArgumentNullException("settings");
            }
            else if (!Directory.Exists(settings.HttpRoot))
            {
                Directory.CreateDirectory(settings.HttpRoot);
            }

            IPAddress ip = IPAddress.Parse(settings.IP);

            channels = new List<Channel>();

            if (settings.EnableHttp)
            {
                httpService = new HttpService(
                    new IPEndPoint(
                    ip,
                    settings.HttpPort),
                    settings.HttpRoot);
            }

            roadLinkService = new RoadLinkManager(
                new CommandProcessorText(),
                new TextFormatter(),
                settings.BaudRate,
                settings.RoadDetectTimeOut);

            roadLinkService.CommandProcessor.RegisteredCommands.AddRange(
            new ICommand[]
            {
                new TemperatureMessage(Path.Combine(settings.HttpRoot, "data.json")),
                    new DensityMessage(Path.Combine(settings.HttpRoot, "data.json"), roadLinkService)
            }); 

            channels.Add(roadLinkService);

            CommandProcessorJson processorJson = new CommandProcessorJson();
            processorJson.RegisteredCommands.AddRange(
            new ICommand[]
            {
                new CreateZoneCommand(),
                new CreateSchoolCommand(),
                new CreateRoadConstructionCommand(),
                new EdgeSetCommand(),

                new GetZonesCommand(),
                new GetSchoolsCommand(),
                new GetRoadconstructionsCommand(),

                new RemoveZoneCommand(),
                new RemoveSchoolCommand(),
                new RemoveRoadConstructionCommand(),

                new ConnectRoadToZoneCommand(roadLinkService, this),
                new GetConnectedRoadsCommand(roadLinkService),

                new GetMapCommand()
            });

            websocketService = new WSSessionManager(
                new IPEndPoint(
                    ip,
                    settings.Port),
                processorJson,
                new JsonFormatter());

            channels.Add(websocketService);
        }