Redial failed connections if possible

This commit is contained in:
Neil Alexander 2022-11-10 21:02:42 +00:00
parent 0da871f528
commit df75a3a4fe
9 changed files with 120 additions and 28 deletions

View file

@ -30,6 +30,7 @@ type Multicast struct {
_isOpen bool
_listeners map[string]*listenerInfo
_interfaces map[string]*interfaceInfo
_timer *time.Timer
config struct {
_groupAddr GroupAddress
_interfaces map[MulticastInterface]struct{}
@ -207,6 +208,15 @@ func (m *Multicast) _getAllowedInterfaces() map[string]*interfaceInfo {
return interfaces
}
func (m *Multicast) AnnounceNow() {
phony.Block(m, func() {
if m._timer != nil && !m._timer.Stop() {
<-m._timer.C
}
m.Act(nil, m._announce)
})
}
func (m *Multicast) _announce() {
if !m._isOpen {
return
@ -329,7 +339,7 @@ func (m *Multicast) _announce() {
break
}
}
time.AfterFunc(time.Second, func() {
m._timer = time.AfterFunc(time.Second, func() {
m.Act(nil, m._announce)
})
}