This repository has been archived on 2024-08-02. You can view files and clone it, but cannot push or open issues or pull requests.
orion/reach/probe.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
}