public final class TwitterStream extends TwitterOAuthSupportBaseImpl
Modifier and Type | Class and Description |
---|---|
(package private) class |
TwitterStream.TwitterStreamConsumer |
Modifier and Type | Field and Description |
---|---|
(package private) static int |
count |
private static twitter4j.internal.async.Dispatcher |
dispatcher |
private TwitterStream.TwitterStreamConsumer |
handler |
private twitter4j.internal.http.HttpClientWrapper |
http |
private static int |
HTTP_ERROR_INITIAL_WAIT |
private static int |
HTTP_ERROR_WAIT_CAP |
private java.util.List<ConnectionLifeCycleListener> |
lifeCycleListeners |
private static twitter4j.internal.logging.Logger |
logger |
private static int |
NO_WAIT |
private static long |
serialVersionUID |
private boolean |
shutdown |
private StreamListener[] |
streamListeners |
private static int |
TCP_ERROR_INITIAL_WAIT |
private static int |
TCP_ERROR_WAIT_CAP |
id, screenName
rateLimitStatusListener
auth, conf
Constructor and Description |
---|
TwitterStream()
Deprecated.
use
TwitterStreamFactory.getInstance() instead. |
TwitterStream(Configuration conf,
Authorization auth,
StreamListener listener) |
TwitterStream(java.lang.String screenName,
java.lang.String password)
Deprecated.
use
TwitterStreamFactory.getInstance() instead. |
TwitterStream(java.lang.String screenName,
java.lang.String password,
StreamListener listener)
Deprecated.
use
TwitterStreamFactory.getInstance() instead. |
Modifier and Type | Method and Description |
---|---|
void |
addConnectionLifeCycleListener(ConnectionLifeCycleListener listener)
Adds a ConnectionLifeCycleListener
|
void |
addListener(SiteStreamsListener listener) |
void |
addListener(StatusListener listener) |
private void |
addListener(StreamListener listener) |
void |
addListener(UserStreamListener listener) |
void |
addStatusListener(StatusListener statusListener)
Deprecated.
use
addListener(StatusListener) instead. |
void |
addUserStreamListener(UserStreamListener userStreamListener)
Deprecated.
use
addListener(UserStreamListener) instead. |
void |
cleanup()
Deprecated.
use #cleanUp instead
|
void |
cleanUp()
shutdown internal stream consuming thread
|
private void |
ensureListenerIsSet()
check if any listener is set.
|
private void |
ensureStatusStreamListenerIsSet() |
void |
filter(FilterQuery query)
Start consuming public statuses that match one or more filter predicates.
|
void |
filter(int count,
int[] follow,
java.lang.String[] track)
Deprecated.
use
filter(FilterQuery) instead |
void |
firehose(int count)
Starts listening on all public statuses.
|
private StatusStream |
getCountStream(java.lang.String relativeUrl,
int count) |
private twitter4j.internal.async.Dispatcher |
getDispatcher() |
StatusStream |
getFilterStream(FilterQuery query)
Returns public statuses that match one or more filter predicates.
|
StatusStream |
getFilterStream(int count,
int[] follow,
java.lang.String[] track)
Deprecated.
use
getFilterStream(FilterQuery) instead |
StatusStream |
getFirehoseStream(int count)
Returns a status stream of all public statuses.
|
StatusStream |
getLinksStream(int count)
Returns a status stream of all public statuses containing links.
|
StatusStream |
getRetweetStream()
Returns a stream of all retweets.
|
StatusStream |
getSampleStream()
Returns a stream of random sample of all public statuses.
|
(package private) java.io.InputStream |
getSiteStream(boolean withFollowings,
int[] follow) |
UserStream |
getUserStream()
User Streams provides real-time updates of all data needed to update a desktop application display.
|
UserStream |
getUserStream(java.lang.String[] track)
User Streams provides real-time updates of all data needed to update a desktop application display.
|
void |
links(int count)
Starts listening on all public statuses containing links.
|
void |
retweet()
Starts listening on all retweets.
|
void |
sample()
Starts listening on random sample of all public statuses.
|
void |
setStatusListener(StatusListener listener)
Deprecated.
use
addListener(StatusListener) instead. |
void |
setUserStreamListener(UserStreamListener listener)
Deprecated.
use
addListener(UserStreamListener) instead. |
void |
shutdown()
Shuts down internal dispatcher thread used by site stream.
|
void |
site(boolean withFollowings,
int[] follow)
Site Streams, a new feature on the Streaming API, is now available for beta testing.
|
private void |
startHandler(TwitterStream.TwitterStreamConsumer handler) |
void |
stream(java.lang.String relativeUrl,
int count,
boolean handleUserStream)
Deprecated.
|
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.
|
getOAuthAccessToken, getOAuthAccessToken, getOAuthAccessToken, getOAuthAccessToken, getOAuthAccessToken, getOAuthAccessToken, getOAuthRequestToken, getOAuthRequestToken, isOAuthEnabled, setOAuthAccessToken, setOAuthAccessToken, setOAuthConsumer
equals, hashCode, httpResponseReceived, setRateLimitStatusListener
ensureAuthorizationEnabled, ensureOAuthEnabled, getAuthorization, getConfiguration, isBasicAuthEnabled, toString
private static final long serialVersionUID
private final twitter4j.internal.http.HttpClientWrapper http
private static final twitter4j.internal.logging.Logger logger
private StreamListener[] streamListeners
private java.util.List<ConnectionLifeCycleListener> lifeCycleListeners
private TwitterStream.TwitterStreamConsumer handler
private static transient twitter4j.internal.async.Dispatcher dispatcher
private boolean shutdown
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
static int count
public TwitterStream()
TwitterStreamFactory.getInstance()
instead.public TwitterStream(java.lang.String screenName, java.lang.String password)
TwitterStreamFactory.getInstance()
instead.screenName
- screen namepassword
- passwordpublic TwitterStream(java.lang.String screenName, java.lang.String password, StreamListener listener)
TwitterStreamFactory.getInstance()
instead.screenName
- screen namepassword
- passwordlistener
- listenerTwitterStream(Configuration conf, Authorization auth, StreamListener listener)
public void firehose(int count)
count
- Indicates the number of previous statuses to stream before transitioning to the live stream.StatusStream
,
Streaming API: Methods statuses/firehosepublic StatusStream 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)
count
- Indicates the number of previous statuses to stream before transitioning to the live stream.StatusStream
,
Streaming API: Methods statuses/linkspublic StatusStream 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/linkspublic void stream(java.lang.String relativeUrl, int count, boolean handleUserStream)
relativeUrl
- The relative url of the feed, for example "statuses/firehose.json" for the firehose.count
- Indicates the number of previous statuses to stream before transitioning to the live stream.private StatusStream getCountStream(java.lang.String relativeUrl, int count) throws TwitterException
TwitterException
public void retweet()
StatusStream
,
Streaming API: Methods statuses/retweetpublic StatusStream getRetweetStream() throws TwitterException
TwitterException
- when Twitter service or network is unavailableStatusStream
,
Streaming API: Methods statuses/retweetpublic void sample()
StatusStream
,
Streaming API: Methods statuses/samplepublic StatusStream getSampleStream() throws TwitterException
TwitterException
- when Twitter service or network is unavailableStatusStream
,
Streaming API: Methods statuses/samplepublic void user()
java.lang.IllegalStateException
- when non-UserStreamListener is set, or no listener is setpublic void user(java.lang.String[] track)
track
- keywords to trackjava.lang.IllegalStateException
- when non-UserStreamListener is set, or no listener is setpublic UserStream getUserStream() throws TwitterException
TwitterException
- when Twitter service or network is unavailablepublic UserStream getUserStream(java.lang.String[] track) throws TwitterException
track
- keywords to trackTwitterException
- when Twitter service or network is unavailablepublic void site(boolean withFollowings, int[] follow)
withFollowings
- whether to receive status updates from people followingfollow
- an array of users to include in the streamprivate twitter4j.internal.async.Dispatcher getDispatcher()
public void shutdown()
shutdown
in class TwitterOAuthSupportBase
java.io.InputStream getSiteStream(boolean withFollowings, int[] follow) throws TwitterException
TwitterException
public void filter(FilterQuery query) throws TwitterException
query
- Filter queryTwitterException
StatusStream
,
Streaming API: Methods statuses/filterpublic StatusStream getFilterStream(FilterQuery query) throws TwitterException
query
- Filter queryTwitterException
- when Twitter service or network is unavailableStatusStream
,
Twitter API Wiki / Streaming API Documentation - filterpublic void filter(int count, int[] follow, java.lang.String[] track)
filter(FilterQuery)
insteadcount
- Indicates the number of previous statuses to stream before transitioning to the live stream.follow
- Specifies the users, by ID, to receive public tweets from.track
- Specifies keywords to track.StatusStream
,
Twitter API Wiki / Streaming API Documentation - filterpublic StatusStream getFilterStream(int count, int[] follow, java.lang.String[] track) throws TwitterException
getFilterStream(FilterQuery)
insteadfollow
- Specifies the users, by ID, to receive public tweets from.TwitterException
- when Twitter service or network is unavailableStatusStream
,
Twitter API Wiki / Streaming API Documentation - filterprivate void ensureListenerIsSet()
java.lang.IllegalStateException
- when no listener is set.private void ensureStatusStreamListenerIsSet()
private void startHandler(TwitterStream.TwitterStreamConsumer handler)
public void cleanUp()
public void cleanup()
public void addConnectionLifeCycleListener(ConnectionLifeCycleListener listener)
listener
- listener to be addedpublic void setStatusListener(StatusListener listener)
addListener(StatusListener)
instead.listener
- listener to be setpublic void addStatusListener(StatusListener statusListener)
addListener(StatusListener)
instead.statusListener
- listener to be addedpublic void setUserStreamListener(UserStreamListener listener)
addListener(UserStreamListener)
instead.listener
- listener to be setpublic void addUserStreamListener(UserStreamListener userStreamListener)
addListener(UserStreamListener)
instead.userStreamListener
- listener to be addedpublic void addListener(UserStreamListener listener)
listener
- public void addListener(StatusListener listener)
listener
- public void addListener(SiteStreamsListener listener)
listener
- private void addListener(StreamListener listener)