adamwynne / twitter-api

Async io interface to all the twitter APIs
372 stars 64 forks source link

Closing an open stream #49

Closed garycrawford closed 10 years ago

garycrawford commented 10 years ago

Hi Adam,

is there any way to close a stream when connected to it? The application I'm using your library in makes use of Stuart Sierras Components and Reloaded libs which, for hot reloads in the dev env, means I need to be able to close an existing stream.

Any help would be greatly appreciated!

Thanks Gary

adamwynne commented 10 years ago

Hi Gary

How are you using the lib? (i.e. what callback and sync model are you using for callbacks?)

Regards Adam

garycrawford commented 10 years ago

Hi Adam,

thank you for the quick response!

I'm using the AsyncStreamingCallback.

G

garycrawford commented 10 years ago

I've just spotted the following (line 93 in core.clj) client (or (:client arg-map) (default-client))

Is this an extensibility point for providing my own client into "def-twitter-method"? That way I can hold onto the client and call it's close fn on clean up?

adamwynne commented 10 years ago

Hi Gary

I think you'll need to check out neotyk/http.async.client as it provides the stream transport (if you have a look at the response handling stuff in the 'get-response-transform', the async callbacks simply use an 'identity' response (i.e. leave it untouched from the underlying stream transport library, accessed in the 'req/execute-request' call).

A cursory glance at the async client library seems to indicate that you could use cancel to close the stream?

Hope that helps Adam

garycrawford commented 10 years ago

I'll do that! thanks for your help Adam, Gary