[Seaside] Re: Zinc - Twitter - Streaming API - Long lived connections

Andreas Raab andreas.raab at gmx.de
Fri Oct 21 13:00:01 UTC 2011


On 10/21/2011 10:20, Davorin Rusevljan wrote:
> Can Zinc do that? (or some other HTTP Client)

WebClient [1] + SqueakSSL [2] does it quite nicely:

| wc |
wc := WebClient new.
wc username: 'YOUR_TWITTER_USERNAME'.
wc password: 'YOUR_TWITTER_PASSWORD'.
resp := wc httpGet: 'https://stream.twitter.com/1/statuses/sample.json'.
resp isSuccess ifFalse:[^self error: 'Request failed'].

"Process incoming data"
stream := resp contentStream.
["Could also set the stream to be non-signaling, but perhaps we want
to keep track of timeouts at some point"
[stream waitForData] on: ConnectionTimedOut do:[:ignore].
stream isDataAvailable ifTrue:[
	"Transcript out the next chunk of data"
	Transcript show: resp nextChunk.
]] repeat.

[1] http://www.squeaksource.com/WebClient.html
[2] http://www.squeaksource.com/SqueakSSL.html

Cheers,
   - Andreas


More information about the seaside mailing list