-
Notifications
You must be signed in to change notification settings - Fork 23
Open
Description
Hello, I'm having fun with your Twitch API Wrapper and up untill now it has done everything that i wanted to do.
There is one question I would like to ask. I'm trying to create a "Pass me the latest highlight" functionality so my IRCBot could handle and respond to a "!latesthighlight" command.
Up until now I've got this:
public String getLatestHighlight() {
RequestParams params = new RequestParams();
params.put("limit", "1");
params.put("broadcasts", "false");
VideosResponseHandler videos = new VideosResponseHandler() {
@Override
public void onSuccess(int i, List<Video> list) {
if (!list.isEmpty()) {
// This would be the desired outcome: list.get(0).getDescription() + " - " + list.get(0).getUrl()
}
}
@Override
public void onFailure(int statusCode, String statusMessage, String errorMessage) {
System.out.println("failure1");
}
@Override
public void onFailure(Throwable e) {
System.out.println("failure2");
}
};
twitch.channels().getVideos("ringoshiba", params, videos);
return <the string>
}
The problem is the asynchronous nature of the implementation. At the point of "return" the string would always be empty (Tried it with a 1 capacity arraylist and handling the "arraylist.add" in the onSuccess). Is there a way to let your the API return the response immediately (as in, block until there is a response)?
Regards,
Ringo
Metadata
Metadata
Assignees
Labels
No labels