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")
for {
entity.AddUniqueAndSort(b.hIerarchyNumber) entity.AddUniqueAndSort(b.hIerarchyNumber)
brIp, _, err := net.ParseCIDR(b.BridgeIpCIDR)
if err != nil {
log.Println(err.Error())
}
for {
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
if !isActive(string(brIp)) {
entity.HierarchyArray = entity.HierarchyArray[:0] entity.HierarchyArray = entity.HierarchyArray[:0]
} }
} }
}