[ntcore] Add client disconnect function (#5022)

As setServer doesn't disconnect, it's useful to have a function that
disconnects without needing to completely stop the client.
This commit is contained in:
Peter Johnson
2023-02-03 15:28:00 -08:00
committed by GitHub
parent 7b828ce84f
commit b61ac6db33
12 changed files with 73 additions and 0 deletions

View File

@@ -911,6 +911,14 @@ public final class NetworkTableInstance implements AutoCloseable {
NetworkTablesJNI.setServerTeam(m_handle, team, port);
}
/**
* Disconnects the client if it's running and connected. This will automatically start
* reconnection attempts to the current server list.
*/
public void disconnect() {
NetworkTablesJNI.disconnect(m_handle);
}
/**
* Starts requesting server address from Driver Station. This connects to the Driver Station
* running on localhost to obtain the server IP address, and connects with the default port.

View File

@@ -251,6 +251,8 @@ public final class NetworkTablesJNI {
public static native void setServerTeam(int inst, int team, int port);
public static native void disconnect(int inst);
public static native void startDSClient(int inst, int port);
public static native void stopDSClient(int inst);