001// Copyright (c) FIRST and other WPILib contributors.
002// Open Source Software; you can modify and/or share it under the terms of
003// the WPILib BSD license file in the root directory of this project.
004
005package edu.wpi.first.net;
006
007/** Class to resolve a service over mDNS. */
008public class MulticastServiceResolver implements AutoCloseable {
009  private final int m_handle;
010
011  /**
012   * Creates a MulticastServiceResolver.
013   *
014   * @param serviceType service type to look for
015   */
016  public MulticastServiceResolver(String serviceType) {
017    m_handle = WPINetJNI.createMulticastServiceResolver(serviceType);
018  }
019
020  @Override
021  public void close() {
022    WPINetJNI.freeMulticastServiceResolver(m_handle);
023  }
024
025  public void start() {
026    WPINetJNI.startMulticastServiceResolver(m_handle);
027  }
028
029  public void stop() {
030    WPINetJNI.stopMulticastServiceResolver(m_handle);
031  }
032
033  public boolean hasImplementation() {
034    return WPINetJNI.getMulticastServiceResolverHasImplementation(m_handle);
035  }
036
037  public int getEventHandle() {
038    return WPINetJNI.getMulticastServiceResolverEventHandle(m_handle);
039  }
040
041  public ServiceData[] getData() {
042    return WPINetJNI.getMulticastServiceResolverData(m_handle);
043  }
044}