bambou/session.go
func (s *Session) NextEvent(channel NotificationsChannel, lastEventID string) *Error {

	currentURL := s.URL + "/events"
	if lastEventID != "" {
		currentURL += "?uuid=" + lastEventID
	}

	request, err := http.NewRequest("GET", currentURL, nil)
	if err != nil {
		return NewBambouError("HTTP transaction error", err.Error())
	}

	response, berr := s.send(request, nil)
	if berr != nil {
		return berr
	}
	defer response.Body.Close()

	notification := NewNotification()
	if err := json.NewDecoder(response.Body).Decode(notification); err != nil {
		return NewBambouError("JSON error", err.Error())
	}

	if len(notification.Events) > 0 {
		channel <- notification
	}

	return nil
}
func (s *Session) NextEvent(channel NotificationsChannel, lastEventID string) *Error {

	currentURL := s.URL + "/events"
	if lastEventID != "" {
		currentURL += "?uuid=" + lastEventID
	}

	request, err := http.NewRequest("GET", currentURL, nil)
	if err != nil {
		return NewBambouError("HTTP transaction error", err.Error())
	}

	response, berr := s.send(request, nil)
	if berr != nil {
		return berr
	}
	defer response.Body.Close()

	notification := NewNotification()
	if err := json.NewDecoder(response.Body).Decode(notification); err != nil {
		return NewBambouError("JSON error", err.Error())
	}

	if len(notification.Events) > 0 {
		channel <- notification
	}

	return nil
}
func ( s * Session ) NextEvent ( channel NotificationsChannel , lastEventID string ) * Error { currentURL := s . URL + " " if lastEventID != " " { currentURL += " " + lastEventID } request , err := http . NewRequest ( " " , currentURL , nil ) if err != nil { return NewBambouError ( " " , err . Error ( ) ) } response , berr := s . send ( request , nil ) if berr != nil { return berr } defer response . Body . Close ( ) notification := NewNotification ( ) if err := json . NewDecoder ( response . Body ) . Decode ( notification ) ; err != nil { return NewBambouError ( " " , err . Error ( ) ) } if len ( notification . Events ) > 0 { channel <- notification } return nil }
// NextEvent will return the next notification from the backend as it occurs and will
// send it to the correct channel.
NextEvent will return the next notification from the backend as it occurs and will send it to the correct channel .