]> git.tdb.fi Git - netvis.git/commitdiff
Remove unregistered ports that are no longer active
authorMikko Rasa <tdb@tdb.fi>
Sun, 15 Jun 2014 08:24:01 +0000 (11:24 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sun, 15 Jun 2014 08:24:01 +0000 (11:24 +0300)
source/netvis.cpp

index 17f113a369a2ba7c879439b0577435077280f172..83dbd1a78d53933bef55d1948fef43dc9024d3e0 100644 (file)
@@ -173,6 +173,19 @@ void NetVis::tick()
                }
        }
 
+       for(map<unsigned, Port *>::iterator i=ports.begin(); i!=ports.end();)
+       {
+               i->second->tick(dt);
+
+               if(!i->second->is_registered() && i->second->get_activity()<0.1)
+               {
+                       delete i->second;
+                       ports.erase(i++);
+               }
+               else
+                       ++i;
+       }
+
        for(list<Packet *>::iterator i=packets.begin(); i!=packets.end();)
        {
                (*i)->tick(dt);
@@ -227,10 +240,12 @@ void NetVis::render()
        GL::pop_matrix();
 
        GL::push_matrix();
-       GL::translate(-500, -360, 0);
+       GL::translate(-500, -348, 0);
        GL::scale_uniform(10);
        font->draw_string(format("%d hosts", hosts.size()+disabled_hosts.size()));
        GL::translate(0, -1.2, 0);
+       font->draw_string(format("%d ports", ports.size()));
+       GL::translate(0, -1.2, 0);
        font->draw_string(format("%.2f fps", fps));
        GL::Texture::unbind();
        GL::pop_matrix();