我的问题如下:
public final class PrintUserStream {
public static void main(String[] args) throws TwitterException {
TwitterStream twitterStream = new TwitterStreamFactory().getInstance();
twitterStream.addListener(listener);
// user() method internally creates a thread which manipulates TwitterStream and calls these adequate listener methods continuously.
twitterStream.user();
}
static UserStreamListener listener = new UserStreamListener() {
public void onStatus(Status status) {
}
public void onDeletionNotice(StatusDeletionNotice statusDeletionNotice) {
}
public void onDeletionNotice(long directMessageId, long userId) {
}
public void onTrackLimitationNotice(int numberOfLimitedStatuses) {
}
public void onScrubGeo(long userId, long upToStatusId) {
}
public void onFriendList(long[] friendIds) {
}
public void onFavorite(User source, User target, Status favoritedStatus) {
}
public void onUnfavorite(User source, User target, Status unfavoritedStatus) {
}
public void onFollow(User source, User followedUser) {
}
public void onRetweet(User source, User target, Status retweetedStatus) {
}
public void onDirectMessage(DirectMessage directMessage) {
}
public void onUserListMemberAddition(User addedMember, User listOwner, UserList list) {
}
public void onUserListMemberDeletion(User deletedMember, User listOwner, UserList list) {
}
public void onUserListSubscription(User subscriber, User listOwner, UserList list) {
}
public void onUserListUnsubscription(User subscriber, User listOwner, UserList list) {
}
public void onUserListCreation(User listOwner, UserList list) {
}
public void onUserListUpdate(User listOwner, UserList list) {
}
public void onUserListDeletion(User listOwner, UserList list) {
}
public void onUserProfileUpdate(User updatedUser) {
}
public void onBlock(User source, User blockedUser) {
}
public void onUnblock(User source, User unblockedUser) {
}
public void onException(Exception ex) {
}
};
}
在上面的代码中,
twitterStream.user();不推荐使用,后者将根据Twitter流上发生的事件调用UserStreamListener重载方法。现在不推荐使用该方法。那么应该使用哪种方法代替twitterStream.user()方法,以便我可以根据twitter userStream上发生的事件调用重载方法。
有人可以帮忙吗?