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

Asynchronous operation - possible pull request for you #7

Open
psh opened this issue Oct 9, 2016 · 0 comments
Open

Asynchronous operation - possible pull request for you #7

psh opened this issue Oct 9, 2016 · 0 comments

Comments

@psh
Copy link

psh commented Oct 9, 2016

I was looking in the Query class and found

/**
 * Asynchronously runs the Query in a new thread.
 */
@SuppressWarnings("unused")
public void start() {
    throw new RuntimeException("Not implemented yet");
}

I'd like to propose a solution to the missing asynchronous operation by converting Hola to a multi-module Gradle project and introducing a second module that handles the asynchronous parts.

I use a lot of RxJava on other projects and have an Rx implementation that allows me to asynchronously enumerate printers on my local network -

Service service = Service.fromName("_ipp._tcp");
RxQuery.createFor(service, Domain.LOCAL)
    .subscribeOn(Schedulers.newThread())
    .subscribe(System.err::println);

Taking the multi-module approach would let you tackle the threading in other ways with other modules and not force people to pull in RxJava if they would rather use standard Java threads, for instance. The core module could stay synchronous.

I also noticed that I wasn't getting responses and it turned out that on a multi-home machine Java can pick the wrong network interface when you call InetAddress.getLocalHost() - in my case I have VirtualBox installed and it created a couple of extra network interfaces. I worked around the issue by iterating over the addresses on each item from NetworkInterface.getNetworkInterfaces() and collected the results, using the newly created Query method (that came from Issue #5).

If you like the idea, I can submit a pull request with my code.

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

1 participant