<commit_before>package com.siberia.plugin;

import android.content.Context;
import android.net.nsd.NsdServiceInfo;
import android.net.nsd.NsdManager;

import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;

import java.net.InetAddress;

import org.apache.cordova.CallbackContext;
import org.apache.cordova.PluginResult;
import org.json.JSONException;
import org.json.JSONObject;

public class NsdHelper
    implements
        NsdManager.DiscoveryListener,
        NsdManager.ResolveListener
{

  public static final String TAG = "NsdHelper";

  private final Context mContext;
  private final CallbackContext mCallbackContext;
  private final NsdManager mNsdManager;
  private final String serviceName;
  private final String serviceType;

  NsdManager.ResolveListener mResolveListener;
  NsdManager.DiscoveryListener mDiscoveryListener = this;

  public NsdHelper(final Context context,
                   final CallbackContext callbackContext,
                   final String serviceType,
                   final String serviceName) {

    this.mContext = context;
    this.mCallbackContext = callbackContext;
    this.mNsdManager = (NsdManager) context.getSystemService(Context.NSD_SERVICE);
    this.serviceName = serviceName;
    this.serviceType = serviceType;
  }

  // NsdHelper API {{{
  public void discoverServices() {
    this.mNsdManager.discoverServices(
      this.serviceType,
      NsdManager.PROTOCOL_DNS_SD,
      this
    );
  }

  public void stopDiscovery() {
    this.mNsdManager.stopServiceDiscovery(this);
  }
  // NsdHelper API }}}

  // NsdManager.DiscoveryListener {{{
  @Override
  public void onDiscoveryStarted(final String regType) {
    Log.d(TAG, String.format("Service discovery started: %s", regType));
  }

  @Override
  public void onServiceFound(final NsdServiceInfo service) {
    // A service was found!  Do something with it.
    Log.d(TAG, "Service discovery success" + service);
    if (!service.getServiceType().equals(this.serviceType)) {
      // Service type is the string containing the protocol and<commit_msg>Trying to connect without serviceName.<commit_after>package com.siberia.plugin;

import android.content.Context;
import android.net.nsd.NsdServiceInfo;
import android.net.nsd.NsdManager;

import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;

import java.net.InetAddress;

import org.apache.cordova.CallbackContext;
import org.apache.cordova.PluginResult;
import org.json.JSONException;
import org.json.JSONObject;

public class NsdHelper
    implements
        NsdManager.DiscoveryListener,
        NsdManager.ResolveListener
{

  public static final String TAG = "NsdHelper";

  private final Context mContext;
  private final CallbackContext mCallbackContext;
  private final NsdManager mNsdManager;
  private final String serviceName;
  private final String serviceType;

  NsdManager.ResolveListener mResolveListener;
  NsdManager.DiscoveryListener mDiscoveryListener = this;

  // , final String serviceName
  public NsdHelper(final Context context, final CallbackContext callbackContext, final String serviceType) {

    this.mContext = context;
    this.mCallbackContext = callbackContext;
    this.mNsdManager = (NsdManager) context.getSystemService(Context.NSD_SERVICE);
    // this.serviceName = serviceName;
    this.serviceType = serviceType;
  }

  // NsdHelper API {{{
  public void discoverServices() {
    this.mNsdManager.discoverServices(
      this.serviceType,
      NsdManager.PROTOCOL_DNS_SD,
      this
    );
  }

  public void stopDiscovery() {
    this.mNsdManager.stopServiceDiscovery(this);
  }
  // NsdHelper API }}}

  // NsdManager.DiscoveryListener {{{
  @Override
  public void onDiscoveryStarted(final String regType) {
    Log.d(TAG, String.format("Service discovery started: %s", regType));
  }

  @Override
  public void onServiceFound(final NsdServiceInfo service) {
    // A service was found!  Do something with it.
    Log.d(TAG, "Service discovery success" + service);
    if (!service.getServiceType().equals(this.serviceType)) {
      // Service type is the string containing the protocol and
{'fraction_non_alphanumeric': 0.08549654679685639, 'fraction_numerical': 0.0, 'mean_word_length': 3.952830188679245, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2226503', 'n_tokens_mistral': 1222, 'n_tokens_neox': 1210, 'n_words': 293}