//Currently setupFacade is unused, because getting new setup data from clients is unsupported
 public void update(List <Client> clients, SetupFacade setupFacade)
 {
     //Handle client requests
     foreach (Client clientRequest in clientRequests)
     {
         bool consumed = false;
         //Compare if client request is already connected in clients
         foreach (Client client in clients)
         {
             if (clientRequest.connection.Address.Equals(client.connection.Address))
             {
                 client.request    = clientRequest.request;
                 client.lastUpdate = clientRequest.lastUpdate;
                 client.setup      = client.request;
                 consumed          = true;
                 break;
             }
         }
         if (!consumed)
         {
             clients.Add(clientRequest); Console.WriteLine("New client connected " + clientRequest.connection);
         }
     }
     clientRequests.Clear();
 }
Esempio n. 2
0
        public void update(List <Client> clients, SetupFacade setupFacade)
        {
            foreach (Client client in clients)
            {
                if (client.setup == null || client.request != client.setup)
                {
                    lookupClient(client, setupFacade);
                }
            }

            //if setup not used/updated in x time, consume?
            List <ISetup> setupsToRemove = new List <ISetup>();

            foreach (ISetup setup in setupFacade.getSetups())
            {
                if (DateTime.Now.Subtract(setup.getLastUsed()).TotalHours >= 1)
                {
                    setupsToRemove.Add(setup);
                }
            }
            foreach (ISetup setup in setupsToRemove)
            {
                //setupFacade.removeSetup(setup.id());
            }
        }
Esempio n. 3
0
 private void lookupClient(Client client, SetupFacade setupFacade)
 {
     //simple lookup; setup already loaded in memory
     if (client.setup == null)
     {
         return;
     }
     if (client.request == null)
     {
         return;
     }
     if (setupFacade.getSetup(client.request) == null)
     {
         return;
     }
     client.setup = setupFacade.getSetup(client.request).id();
     setupFacade.getSetup(client.setup).lastUsed(DateTime.Now);
 }
Esempio n. 4
0
        public PrototypeDatabase()
        {
            SetupFacade facade = SetupFacade.Instance;

            using (var reader = new StreamReader(@"C:\Users\mega-\Source\Repos\madsmogensen\PositioningServer\PositioningServer\DBHandler\uwb_GoCart.csv"))
            {
                if (!reader.EndOfStream)
                {
                    reader.ReadLine();
                }                                               //skip header

                facade.newSetup("From File");
                ISetup setup = facade.getSetup("From File");

                while (!reader.EndOfStream)
                {
                    var line   = reader.ReadLine();
                    var values = line.Split(';');

                    string   id          = values[0];
                    int      x           = Int32.Parse(values[1]);
                    int      y           = Int32.Parse(values[2]);
                    int      z           = Int32.Parse(values[3]);
                    string[] date        = values[4].Split(' ')[0].Split('-');
                    int      year        = Int32.Parse(date[0]);
                    int      month       = Int32.Parse(date[1]);
                    int      day         = Int32.Parse(date[2]);
                    string[] time        = values[4].Split(' ')[1].Split(':');
                    int      hour        = Int32.Parse(time[0]);
                    int      minute      = Int32.Parse(time[1]);
                    int      second      = Int32.Parse(time[2].Split('.')[0]);
                    int      millisecond = Int32.Parse(time[2].Split('.')[1]);
                    //public DateTime(int year, int month, int day, int hour, int minute, int second, int millisecond); // use .Ticks for long
                    DateTime   dateTime   = new DateTime(year, month, day, hour, minute, second, millisecond);
                    IUnit      newNode    = facade.makeUnit(id);
                    Coordinate coordinate = new Coordinate(x, y, z, dateTime);

                    newNode.addCoordinate(coordinate);

                    setup.addRawNode(newNode);
                }
            }
        }
Esempio n. 5
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            var         key         = Encoding.ASCII.GetBytes(Configuration.GetSection("AppSettings:Token").Value);
            SetupFacade setupFacade = new SetupFacade(services);

            setupFacade.InjectionBuildDatabase();
            services.AddMvc();
            services.AddCors();
            setupFacade.InjectionBuildRepository();
            services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme).AddJwtBearer(options =>
            {
                options.TokenValidationParameters = new TokenValidationParameters
                {
                    ValidateIssuerSigningKey = true,
                    IssuerSigningKey         = new SymmetricSecurityKey(key),
                    ValidateIssuer           = false,
                    ValidateAudience         = false
                };
            });
        }
Esempio n. 6
0
 public void update(List <Client> clients, SetupFacade setupFacade)
 {
     incoming.update(clients, setupFacade);
     outgoing.update(clients);
 }
 public void update(List <Client> clients, SetupFacade setupFacade)
 {
     server.update(clients, setupFacade);
 }