Made it asynchronous.

master
Uriel Fanelli 2023-08-10 20:39:26 +02:00
parent 6c4f09f4cb
commit 08f139c8d2
1 changed files with 12 additions and 3 deletions

View File

@ -116,11 +116,20 @@ func (b *AbstractBridge) WaitAndClean(entity AbstractMulticast) {
log.Println("Inizializing Escalator") log.Println("Inizializing Escalator")
entity.AddUniqueAndSort(b.hIerarchyNumber)
brIp, _, err := net.ParseCIDR(b.BridgeIpCIDR)
if err != nil {
log.Println(err.Error())
}
for { for {
entity.AddUniqueAndSort(b.hIerarchyNumber)
pollTime := len(entity.HierarchyArray) + 1 pollTime := len(entity.HierarchyArray) + 1
time.Sleep(time.Duration(pollTime) * time.Second) time.Sleep(time.Duration(pollTime) * time.Second)
// svuotare l'array // svuotare l'array e rifare le elezioni
entity.HierarchyArray = entity.HierarchyArray[:0] if !isActive(string(brIp)) {
entity.HierarchyArray = entity.HierarchyArray[:0]
}
} }
} }