Esempio n. 1
0
 public UdpReceiver(GpsPersister gpsPersister, int portToListenOn)
 {
     _runningLog           = new StringBuilder();
     _gpsCoordinatesBuffer = new List <GpsCoordinate>();
     _gpsPersister         = gpsPersister;
     _portToListenOn       = portToListenOn;
 }
Esempio n. 2
0
        static void Main(string[] args)
        {
            var builder = new ConfigurationBuilder()
                          .SetBasePath(Directory.GetCurrentDirectory())
                          .AddJsonFile("appsettings.json")
                          .AddJsonFile("appsettings.prod.json");

            Configuration = builder.Build();

            var runner = new Runner();

            var connectionString = Configuration["ConnectionString"];
            var portToListenOn   = Convert.ToInt32(Configuration["UdpPortToListenOn"]);
            var gpsPersister     = new GpsPersister(connectionString);


            Task.Run(async() =>
            {
                await runner.Run(gpsPersister, portToListenOn);
            });

            while (true)
            {
//                Console.Write("Press `X` to exit.");
//                var keyEntered = Console.ReadKey();
//                if (keyEntered.Key == ConsoleKey.X)
//                    break;
            }
        }
Esempio n. 3
0
        public async Task Run(GpsPersister gpsPersister, int portToListenOn)
        {
            Console.WriteLine($"Starting UDP listener {DateTime.Now}!");

            // TODO: Inject this
            var udpReceiver = new UdpReceiver(gpsPersister, portToListenOn);

            try
            {
                await udpReceiver.Listen();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }