[ntcore] Add ability to announce mDNS for server (#8373)

We can use this as a new way of resolving addresses.
This commit is contained in:
Thad House
2025-12-16 22:26:56 -08:00
committed by GitHub
parent 7cb58962c5
commit e2d492ac3f
27 changed files with 133 additions and 56 deletions

View File

@@ -1171,7 +1171,7 @@ public final class NetworkTableInstance implements AutoCloseable {
* @param persistFilename the name of the persist file to use
*/
public void startServer(String persistFilename) {
startServer(persistFilename, "");
startServer(persistFilename, "", "");
}
/**
@@ -1181,18 +1181,32 @@ public final class NetworkTableInstance implements AutoCloseable {
* @param listenAddress the address to listen on, or empty to listen on any address
*/
public void startServer(String persistFilename, String listenAddress) {
startServer(persistFilename, listenAddress, kDefaultPort);
startServer(persistFilename, listenAddress, "");
}
/**
* Starts a server using the specified filename, listening address, and port.
* Starts a server using the specified filename, listening address, and mdns service,
* using the default port.
*
* @param persistFilename the name of the persist file to use
* @param listenAddress the address to listen on, or empty to listen on any address
* @param mdnsService the mDNS service name to advertise, or empty to not advertise
*/
public void startServer(String persistFilename, String listenAddress, String mdnsService) {
startServer(persistFilename, listenAddress, mdnsService, kDefaultPort);
}
/**
* Starts a server using the specified filename, listening address, mdns service and port.
*
* @param persistFilename the name of the persist file to use
* @param listenAddress the address to listen on, or empty to listen on any address
* @param mdnsService the mDNS service name to advertise, or empty to not advertise
* @param port port to communicate over
*/
public void startServer(String persistFilename, String listenAddress, int port) {
NetworkTablesJNI.startServer(m_handle, persistFilename, listenAddress, port);
public void startServer(String persistFilename, String listenAddress, String mdnsService,
int port) {
NetworkTablesJNI.startServer(m_handle, persistFilename, listenAddress, mdnsService, port);
}
/** Stops the server if it is running. */

View File

@@ -1404,10 +1404,11 @@ public final class NetworkTablesJNI {
* @param inst NT instance handle.
* @param persistFilename the name of the persist file to use
* @param listenAddress the address to listen on, or empty to listen on any address
* @param mdnsService the mDNS service name to advertise, or empty to not advertise
* @param port port to communicate over
*/
public static native void startServer(
int inst, String persistFilename, String listenAddress, int port);
int inst, String persistFilename, String listenAddress, String mdnsService, int port);
/**
* Stops the server if it is running.