// Path: dnssd/src/main/java/com/github/druk/dnssd/DNSSDService.java
// public interface	DNSSDService
// {
// 	/**
// 	Halt the active operation and free resources associated with the DNSSDService.<P>
// 
// 	Any services or records registered with this DNSSDService will be deregistered. Any
// 	Browse, Resolve, or Query operations associated with this reference will be terminated.<P>
// 
// 	Note: if the service was initialized with DNSSD.register(), and an extra resource record was
// 	added to the service via {@link DNSSDRegistration#addRecord}, the DNSRecord so created
// 	is invalidated when this method is called - the DNSRecord may not be used afterward.
// 	*/
// 	void		stop();
// } 
// 
// Path: dnssd/src/main/java/com/github/druk/dnssd/ResolveListener.java
// public interface ResolveListener extends BaseListener
// {
// 	/** Called when a service has been resolved.<P> 
// 
// 		@param	resolver
// 					The active resolver object.
// 		<P>
// 		@param	flags
// 					Currently unused, reserved for future use.
// 		<P>
// 		@param	fullName
// 					The full service domain name, in the form &lt;servicename&gt;.&lt;protocol&gt;.&lt;domain&gt;.
// 					(Any literal dots (".") are escaped with a backslash ("\."), and literal
// 					backslashes are escaped with a second backslash ("\\"), e.g. a web server
// 					named "Dr. Pepper" would have the fullname  "Dr\.\032Pepper._http._tcp.local.").
// 					This is the appropriate format to pass to standard system DNS APIs such as 
// 					res_query(), or to the special-purpose functions included in this API that
// 					take fullname parameters.
// 		<P>
// 		@param	hostName
// 					The target hostname of the machine providing the service.  This name can 
// 					be passed to functions like queryRecord() to look up the host's IP address.
// 		<P>
// 		@param	port
// 					The port number on which connections are accepted for this service.
// 		<P>
// 		@param	txtRecord
// 					The service's primary txt record.
// 	*/
// 	void serviceResolved(DNSSDService resolver, int flags, int ifIndex, String fullName, String hostName, int port, Map<String, String> txtRecord);
// }


import com.github.druk.dnssd.DNSSDService;
import com.github.druk.dnssd.ResolveListener;
import java.util.Map;
import io.reactivex.FlowableEmitter;
/*
 * Copyright (C) 2016 Andriy Druk
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.github.druk.rx2dnssd;




class Rx2ResolveListener implements ResolveListener {
    private final FlowableEmitter<? super BonjourService> emitter;
    private final BonjourService.Builder builder;

    Rx2ResolveListener(FlowableEmitter<? super BonjourService> emitter, BonjourService service) {
        this.emitter = emitter;
        this.builder = new BonjourService.Builder(service);
    }

    @Override
// Path: dnssd/src/main/java/com/github/druk/dnssd/DNSSDService.java
// public interface	DNSSDService
// {
// 	/**
// 	Halt the active operation and free resources associated with the DNSSDService.<P>
// 
// 	Any services or records registered with this DNSSDService will be deregistered. Any
// 	Browse, Resolve, or Query operations associated with this reference will be terminated.<P>
// 
// 	Note: if the service was initialized with DNSSD.register(), and an extra resource record was
// 	added to the service via {@link DNSSDRegistration#addRecord}, the DNSRecord so created
// 	is invalidated when this method is called - the DNSRecord may not be used afterward.
// 	*/
// 	void		stop();
// } 
// 
// Path: dnssd/src/main/java/com/github/druk/dnssd/ResolveListener.java
// public interface ResolveListener extends BaseListener
// {
// 	/** Called when a service has been resolved.<P> 
// 
// 		@param	resolver
// 					The active resolver object.
// 		<P>
// 		@param	flags
// 					Currently unused, reserved for future use.
// 		<P>
// 		@param	fullName
// 					The full service domain name, in the form &lt;servicename&gt;.&lt;protocol&gt;.&lt;domain&gt;.
// 					(Any literal dots (".") are escaped with a backslash ("\."), and literal
// 					backslashes are escaped with a second backslash ("\\"), e.g. a web server
// 					named "Dr. Pepper" would have the fullname  "Dr\.\032Pepper._http._tcp.local.").
// 					This is the appropriate format to pass to standard system DNS APIs such as 
// 					res_query(), or to the special-purpose functions included in this API that
// 					take fullname parameters.
// 		<P>
// 		@param	hostName
// 					The target hostname of the machine providing the service.  This name can 
// 					be passed to functions like queryRecord() to look up the host's IP address.
// 		<P>
// 		@param	port
// 					The port number on which connections are accepted for this service.
// 		<P>
// 		@param	txtRecord
// 					The service's primary txt record.
// 	*/
// 	void serviceResolved(DNSSDService resolver, int flags, int ifIndex, String fullName, String hostName, int port, Map<String, String> txtRecord);
// }


// Path: rx2dnssd/src/main/java/com/github/druk/rx2dnssd/Rx2ResolveListener.java
import com.github.druk.dnssd.DNSSDService;
import com.github.druk.dnssd.ResolveListener;
import java.util.Map;
import io.reactivex.FlowableEmitter;

/*
 * Copyright (C) 2016 Andriy Druk
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.github.druk.rx2dnssd;




class Rx2ResolveListener implements ResolveListener {
    private final FlowableEmitter<? super BonjourService> emitter;
    private final BonjourService.Builder builder;

    Rx2ResolveListener(FlowableEmitter<? super BonjourService> emitter, BonjourService service) {
        this.emitter = emitter;
        this.builder = new BonjourService.Builder(service);
    }

    @Override
    public void serviceResolved(DNSSDService resolver, int flags, int ifIndex, String fullName, String hostName, int port, Map<String, String> txtRecord) {