Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What is stream.isOnline() used for? #29

Open
angelalukic opened this issue Jan 23, 2018 · 1 comment
Open

What is stream.isOnline() used for? #29

angelalukic opened this issue Jan 23, 2018 · 1 comment

Comments

@angelalukic
Copy link

angelalukic commented Jan 23, 2018

I don't often post to issues and I'm still very new to this kind of thing so I'm sorry if this question has already been answered or is perhaps obvious.

I'm currently trying to check whether or not a stream is online. I thought to use the isOnline() method in the JavaDoc Stream class. If the stream is online, this will return true. If it is offline, it returns a NullPointerException.

I have looked at this issue #18 which implies that the entire stream will be null if the Twitch stream is offline, which would explain why I am getting this NullPointerException. However the JavaDoc makes reference that the isOnline() method should return false if it is offline.

My entire code looks like this:

@Override
public void onSuccess(Stream stream) {
	log.info("" + stream.isOnline());					
}				

My question isn't so much how to check if my Twitch stream is online, but rather what is the correct usage of isOnline()?

@MaximKulikov
Copy link

Hello angelalukic,

    public boolean isOnline() {
        return id != 0;
    }

id is a long value and it means defalt value is 0, but the root object null itself. I guess idea was to create empty object with default id value. But in my opinion checking object for null faster rather getting value from this object and check it for specific value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants