1
0
mirror of https://github.com/taigrr/go-fastping synced 2025-01-18 05:03:15 -08:00

Add OnRecv and OnIdle field to Pinger. AddHandler is deprecated

This commit is contained in:
Tatsushi Demachi
2014-10-16 21:01:45 +09:00
parent 2ce592c234
commit bbe9a51966
3 changed files with 38 additions and 67 deletions

View File

@@ -38,19 +38,11 @@ func main() {
p.AddIPAddr(ra)
onRecv, onIdle := make(chan *response), make(chan bool)
err = p.AddHandler("receive", func(addr *net.IPAddr, t time.Duration) {
p.OnRecv = func(addr *net.IPAddr, t time.Duration) {
onRecv <- &response{addr: addr, rtt: t}
})
if err != nil {
fmt.Println(err)
os.Exit(1)
}
err = p.AddHandler("idle", func() {
p.OnIdle = func() {
onIdle <- true
})
if err != nil {
fmt.Println(err)
os.Exit(1)
}
p.MaxRTT = time.Second