Java Code Examples for javax.jmdns.ServiceInfo#getPort()

The following examples show how to use javax.jmdns.ServiceInfo#getPort() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AddHostFragmentZeroconf.java    From Kore with Apache License 2.0 5 votes vote down vote up
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    if (convertView == null) {
        convertView = LayoutInflater.from(getActivity())
                                    .inflate(R.layout.grid_item_host, parent, false);
    }

    final ServiceInfo item = this.getItem(position);
    ((TextView)convertView.findViewById(R.id.host_name)).setText(item.getName());
    String[] addresses = item.getHostAddresses();
    String hostAddress;
    if (addresses.length > 0) {
        hostAddress = addresses[0] + ":" + item.getPort();
    } else {
        hostAddress = getString(R.string.wizard_zeroconf_no_host_address);
    }
    ((TextView) convertView.findViewById(R.id.host_address)).setText(hostAddress);

    ImageView statusIndicator = (ImageView)convertView.findViewById(R.id.status_indicator);
    int statusColor = getActivity().getResources().getColor(R.color.host_status_available);
    statusIndicator.setColorFilter(statusColor);

    // Remove context menu
    ImageView contextMenu = (ImageView)convertView.findViewById(R.id.list_context_menu);
    contextMenu.setVisibility(View.GONE);

    return convertView;
}
 
Example 2
Source File: WlanBrowser.java    From jReto with MIT License 5 votes vote down vote up
private void onDiscoveredService(final ServiceInfo info) {
	if (info.getInetAddresses() == null) {
		return;
	}
	final WlanAddress address = new WlanAddress(this.dispatcher, info.getInetAddresses()[0], info.getPort());
	this.addresses.put(info.getName(), address);
	
	this.executor.execute(new Runnable() {
		public void run() {
			WlanBrowser.this.handler.onAddressDiscovered(WlanBrowser.this, address, UUID.fromString(info.getName()));
		}
	});
}
 
Example 3
Source File: ChromeCast.java    From chromecast-java-api-v2 with Apache License 2.0 5 votes vote down vote up
ChromeCast(JmDNS mDNS, String name) {
    this.name = name;
    ServiceInfo serviceInfo = mDNS.getServiceInfo(SERVICE_TYPE, name);
    this.address = serviceInfo.getInet4Addresses()[0].getHostAddress();
    this.port = serviceInfo.getPort();
    this.appsURL = serviceInfo.getURLs().length == 0 ? null : serviceInfo.getURLs()[0];
    this.application = serviceInfo.getApplication();

    this.title = serviceInfo.getPropertyString("fn");
    this.appTitle = serviceInfo.getPropertyString("rs");
    this.model = serviceInfo.getPropertyString("md");
}