equal
deleted
inserted
replaced
39 params["tag"] = hashTag |
39 params["tag"] = hashTag |
40 default: |
40 default: |
41 return nil, ErrInvalidParameter |
41 return nil, ErrInvalidParameter |
42 } |
42 } |
43 |
43 |
44 req := g.prepareRequest("streaming/"+streamName, rest.Get, params) |
44 req, err := g.prepareRequest("streaming/"+streamName, rest.Get, params) |
|
45 if err != nil { |
|
46 return nil, fmt.Errorf("cannot build stream request: %s", err.Error()) |
|
47 } |
|
48 |
45 reqObj, err := rest.BuildRequestObject(req) |
49 reqObj, err := rest.BuildRequestObject(req) |
46 if err != nil { |
50 if err != nil { |
47 return nil, fmt.Errorf("cannot build stream request: %s", err.Error()) |
51 return nil, fmt.Errorf("cannot build stream request: %s", err.Error()) |
48 } |
52 } |
49 |
53 |
173 // The events are sent to the events channel (the errors as well). |
177 // The events are sent to the events channel (the errors as well). |
174 // The streaming is terminated if the 'stopCh' channel is closed. |
178 // The streaming is terminated if the 'stopCh' channel is closed. |
175 // The 'doneCh' channel is closed if the connection is closed by the server. |
179 // The 'doneCh' channel is closed if the connection is closed by the server. |
176 // Please note that this method launches a goroutine to listen to the events. |
180 // Please note that this method launches a goroutine to listen to the events. |
177 func (g *Client) StreamListener(name, hashTag string, events chan<- StreamEvent, stopCh <-chan bool, doneCh chan<- bool) error { |
181 func (g *Client) StreamListener(name, hashTag string, events chan<- StreamEvent, stopCh <-chan bool, doneCh chan<- bool) error { |
|
182 if g == nil { |
|
183 return fmt.Errorf("use of uninitialized gondole client") |
|
184 } |
|
185 |
178 resp, err := g.openStream(name, hashTag) |
186 resp, err := g.openStream(name, hashTag) |
179 if err != nil { |
187 if err != nil { |
180 return err |
188 return err |
181 } |
189 } |
182 go g.readStream(events, stopCh, doneCh, resp) |
190 go g.readStream(events, stopCh, doneCh, resp) |