public void clickConnect(View v) {
   NsdServiceInfo service = mNsdHelper.getChosenServiceInfo();
   if (service != null) {
     Log.d(TAG, "Connecting.");
     mConnection.connectToServer(service.getHost(), service.getPort());
   } else {
     Log.d(TAG, "No service to connect to!");
   }
 }
Пример #2
0
  public void registerService(int port) {
    NsdServiceInfo serviceInfo = new NsdServiceInfo();
    serviceInfo.setPort(port);
    serviceInfo.setServiceName(mServiceName);
    serviceInfo.setServiceType(SERVICE_TYPE);

    mNsdManager.registerService(serviceInfo, NsdManager.PROTOCOL_DNS_SD, mRegistrationListener);

    System.out.println(
        TAG + " Registered " + String.valueOf(serviceInfo.getHost()) + " " + serviceInfo.getPort());
  }