// StartListen polls events and sends them into channel.
// on network error closes that channel.
StartListen polls events and sends them into channel.
on network error closes that channel.
// StartListen polls events and sends them into channel . // on network error closes that channel .
func (b *Client) StartListen() <-chan events.Event {
	ch := make(chan events.Event)
	go func() {
		pollURL := b.URL + constants.RouteApi + constants.RouteLoggedOnly + constants.RoutePoll
		for {
			select {
			case <-b.ctx.Done():
				return
			default:
				w, err := b.client.Get(pollURL)
				if err != nil {
					close(ch)
					return
				}
				e, err := parseEvent(w.Body)
				if err != nil {
					continue
				}
				ch <- e
			}
		}
	}()
	return ch
}
func ( b * Client ) StartListen ( ) <- chan events . Event { ch := make ( chan events . Event ) go func ( ) { pollURL := b . URL + constants . RouteApi + constants . RouteLoggedOnly + constants . RoutePoll for { select { case <- b . ctx . Done ( ) : return default : w , err := b . client . Get ( pollURL ) if err != nil { close ( ch ) return } e , err := parseEvent ( w . Body ) if err != nil { continue } ch <- e } } } ( ) return ch }
StartListen polls events and sends them into channel.
StartListen polls events and sends them into channel .