class TwitterStreamImpl extends TwitterBaseImpl implements TwitterStream
Modifier and Type | Class and Description |
---|---|
(package private) static class |
TwitterStreamImpl.Mode |
(package private) class |
TwitterStreamImpl.TwitterStreamConsumer |
Modifier and Type | Field and Description |
---|---|
private static int |
count |
private static Dispatcher |
dispatcher |
private TwitterStreamImpl.TwitterStreamConsumer |
handler |
private HttpClient |
http |
private static int |
HTTP_ERROR_INITIAL_WAIT |
private static int |
HTTP_ERROR_WAIT_CAP |
private java.util.List<ConnectionLifeCycleListener> |
lifeCycleListeners |
private static Logger |
logger |
private static int |
NO_WAIT |
private static int |
numberOfHandlers |
private static long |
serialVersionUID |
private java.lang.String |
stallWarningsGetParam |
private HttpParameter |
stallWarningsParam |
private java.util.ArrayList<StreamListener> |
streamListeners |
private static int |
TCP_ERROR_INITIAL_WAIT |
private static int |
TCP_ERROR_WAIT_CAP |
auth, conf, factory
Constructor and Description |
---|
TwitterStreamImpl(Configuration conf,
Authorization auth) |
Modifier and Type | Method and Description |
---|---|
void |
addConnectionLifeCycleListener(ConnectionLifeCycleListener listener)
Adds a ConnectionLifeCycleListener
|
void |
addListener(StreamListener listener) |
void |
cleanUp()
shutdown internal stream consuming thread
|
void |
clearListeners()
clear status listeners
|
private void |
ensureSiteStreamsListenerIsSet() |
private void |
ensureStatusStreamListenerIsSet()
check if any listener is set.
|
boolean |
equals(java.lang.Object o) |
void |
filter(FilterQuery query)
Start consuming public statuses that match one or more filter predicates.
|
void |
firehose(int count)
Starts listening on all public statuses.
|
private StatusStream |
getCountStream(java.lang.String relativeUrl,
int count) |
private Dispatcher |
getDispatcher() |
(package private) StatusStream |
getFilterStream(FilterQuery query)
Returns public statuses that match one or more filter predicates.
|
(package private) StatusStream |
getFirehoseStream(int count)
Returns a status stream of all public statuses.
|
(package private) StatusStream |
getLinksStream(int count)
Returns a status stream of all public statuses containing links.
|
private RawStreamListener[] |
getRawStreamListeners() |
(package private) StatusStream |
getRetweetStream()
Returns a stream of all retweets.
|
(package private) StatusStream |
getSampleStream()
Returns a stream of random sample of all public statuses.
|
(package private) java.io.InputStream |
getSiteStream(boolean withFollowings,
long[] follow) |
private SiteStreamsListener[] |
getSiteStreamsListeners() |
private StatusListener[] |
getStatusListeners() |
(package private) UserStream |
getUserStream(java.lang.String[] track)
User Streams provides real-time updates of all data needed to update a desktop application display.
|
int |
hashCode() |
void |
links(int count)
Starts listening on all public statuses containing links.
|
void |
removeListener(StreamListener listener) |
void |
replaceListener(StreamListener toBeRemoved,
StreamListener toBeAdded)
replace existing listener
|
void |
retweet()
Starts listening on all retweets.
|
void |
sample()
Starts listening on random sample of all public statuses.
|
void |
shutdown()
Shuts down internal dispatcher thread shared by all TwitterStream instances.
|
StreamController |
site(boolean withFollowings,
long[] follow)
Site Streams, a new feature on the Streaming API, is now available for beta testing.
|
private void |
startHandler(TwitterStreamImpl.TwitterStreamConsumer handler) |
java.lang.String |
toString() |
private void |
updateListeners() |
void |
user()
User Streams provides real-time updates of all data needed to update a desktop application display.
|
void |
user(java.lang.String[] track)
User Streams provides real-time updates of all data needed to update a desktop application display.
|
addRateLimitStatusListener, ensureAuthorizationEnabled, ensureOAuthEnabled, fillInIDAndScreenName, getAuthorization, getConfiguration, getId, getOAuth2Token, getOAuthAccessToken, getOAuthAccessToken, getOAuthAccessToken, getOAuthAccessToken, getOAuthAccessToken, getOAuthRequestToken, getOAuthRequestToken, getOAuthRequestToken, getScreenName, httpResponseReceived, invalidateOAuth2Token, setFactory, setOAuth2Token, setOAuthAccessToken, setOAuthConsumer
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
getOAuthAccessToken, getOAuthAccessToken, getOAuthAccessToken, getOAuthAccessToken, getOAuthAccessToken, getOAuthRequestToken, getOAuthRequestToken, getOAuthRequestToken, setOAuthAccessToken, setOAuthConsumer
addRateLimitStatusListener, getAuthorization, getConfiguration, getId, getScreenName
private static final long serialVersionUID
private final HttpClient http
private static final Logger logger
private final java.util.List<ConnectionLifeCycleListener> lifeCycleListeners
private TwitterStreamImpl.TwitterStreamConsumer handler
private final java.lang.String stallWarningsGetParam
private final HttpParameter stallWarningsParam
private static transient Dispatcher dispatcher
private static int numberOfHandlers
private final java.util.ArrayList<StreamListener> streamListeners
private static final int TCP_ERROR_INITIAL_WAIT
private static final int TCP_ERROR_WAIT_CAP
private static final int HTTP_ERROR_INITIAL_WAIT
private static final int HTTP_ERROR_WAIT_CAP
private static final int NO_WAIT
private static int count
TwitterStreamImpl(Configuration conf, Authorization auth)
public void firehose(int count)
firehose
in interface TwitterStream
count
- Indicates the number of previous statuses to stream before transitioning to the live stream.StatusStream
,
Streaming API Methods statuses/firehoseStatusStream getFirehoseStream(int count) throws TwitterException
count
- Indicates the number of previous statuses to stream before transitioning to the live stream.TwitterException
- when Twitter service or network is unavailableStatusStream
,
Streaming API Methods statuses/firehosepublic void links(int count)
links
in interface TwitterStream
count
- Indicates the number of previous statuses to stream before transitioning to the live stream.StatusStream
,
Streaming API Methods statuses/linksStatusStream getLinksStream(int count) throws TwitterException
count
- Indicates the number of previous statuses to stream before transitioning to the live stream.TwitterException
- when Twitter service or network is unavailableStatusStream
,
Streaming API Methods statuses/linksprivate StatusStream getCountStream(java.lang.String relativeUrl, int count) throws TwitterException
TwitterException
public void retweet()
retweet
in interface TwitterStream
StatusStream
,
Streaming API Methods statuses/retweetStatusStream getRetweetStream() throws TwitterException
TwitterException
- when Twitter service or network is unavailableStatusStream
,
Streaming API: Methods statuses/retweetpublic void sample()
sample
in interface TwitterStream
StatusStream
,
Streaming API: Methods statuses/sampleStatusStream getSampleStream() throws TwitterException
TwitterException
- when Twitter service or network is unavailableStatusStream
,
Streaming API: Methods statuses/samplepublic void user()
user
in interface TwitterStream
public void user(java.lang.String[] track)
user
in interface TwitterStream
track
- keywords to trackUserStream getUserStream(java.lang.String[] track) throws TwitterException
track
- keywords to trackTwitterException
- when Twitter service or network is unavailablepublic StreamController site(boolean withFollowings, long[] follow)
site
in interface TwitterStream
withFollowings
- whether to receive status updates from people followingfollow
- an array of users to include in the streamprivate Dispatcher getDispatcher()
java.io.InputStream getSiteStream(boolean withFollowings, long[] follow) throws TwitterException
TwitterException
public void filter(FilterQuery query)
filter
in interface TwitterStream
query
- Filter queryStatusStream
,
Streaming API Methods statuses/filterStatusStream getFilterStream(FilterQuery query) throws TwitterException
query
- Filter queryTwitterException
- when Twitter service or network is unavailableStatusStream
,
Streaming API Methods | Twitter Developersprivate void ensureStatusStreamListenerIsSet()
java.lang.IllegalStateException
- when no listener is set.private void ensureSiteStreamsListenerIsSet()
private void startHandler(TwitterStreamImpl.TwitterStreamConsumer handler)
public void cleanUp()
cleanUp
in interface TwitterStream
public void shutdown()
shutdown
in interface TwitterStream
public void addConnectionLifeCycleListener(ConnectionLifeCycleListener listener)
addConnectionLifeCycleListener
in interface TwitterStream
listener
- listener to be addedpublic void addListener(StreamListener listener)
addListener
in interface TwitterStream
listener
- listener to addpublic void removeListener(StreamListener listener)
removeListener
in interface TwitterStream
listener
- listener to removepublic void clearListeners()
clearListeners
in interface TwitterStream
public void replaceListener(StreamListener toBeRemoved, StreamListener toBeAdded)
replaceListener
in interface TwitterStream
private void updateListeners()
private RawStreamListener[] getRawStreamListeners()
private SiteStreamsListener[] getSiteStreamsListeners()
private StatusListener[] getStatusListeners()
public boolean equals(java.lang.Object o)
equals
in class TwitterBaseImpl
public int hashCode()
hashCode
in class TwitterBaseImpl
public java.lang.String toString()
toString
in class TwitterBaseImpl