38 lines
575 B
Go
38 lines
575 B
Go
package reach
|
|
|
|
import (
|
|
"sync"
|
|
|
|
"forge.cadoles.com/Pyxis/golang-socketio"
|
|
"github.com/pkg/errors"
|
|
)
|
|
|
|
const (
|
|
// EventProbe -
|
|
EventProbe = "probe"
|
|
)
|
|
|
|
// Probe -
|
|
func (c *Client) Probe() error {
|
|
|
|
var wg sync.WaitGroup
|
|
|
|
wg.Add(1)
|
|
|
|
c.conn.On(EventProbe, func(h *gosocketio.Channel) {
|
|
wg.Done()
|
|
c.conn.On(EventProbe, nil)
|
|
})
|
|
|
|
c.logf("sending '%s' event", EventProbe)
|
|
if err := c.conn.Emit(EventProbe, nil); err != nil {
|
|
return errors.Wrapf(err, "error while emitting '%s' event", EventProbe)
|
|
}
|
|
c.logf("'%s' event sent", EventProbe)
|
|
|
|
wg.Wait()
|
|
|
|
return nil
|
|
|
|
}
|