Skip to content

Asynchronous operation - possible pull request for you #7

@psh

Description

@psh

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions