[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

@@ -586,6 +586,12 @@ class NetworkTableInstance final {
*/
void SetServerTeam(unsigned int team, unsigned int port = 0);
/**
* Disconnects the client if it's running and connected. This will
* automatically start reconnection attempts to the current server list.
*/
void Disconnect();
/**
* Starts requesting server address from Driver Station.
* This connects to the Driver Station running on localhost to obtain the

View File

@@ -163,6 +163,10 @@ inline void NetworkTableInstance::SetServerTeam(unsigned int team,
::nt::SetServerTeam(m_handle, team, port);
}
inline void NetworkTableInstance::Disconnect() {
::nt::Disconnect(m_handle);
}
inline void NetworkTableInstance::StartDSClient(unsigned int port) {
::nt::StartDSClient(m_handle, port);
}

View File

@@ -1147,6 +1147,14 @@ void NT_SetServerMulti(NT_Inst inst, size_t count, const char** server_names,
*/
void NT_SetServerTeam(NT_Inst inst, unsigned int team, unsigned int port);
/**
* Disconnects the client if it's running and connected. This will automatically
* start reconnection attempts to the current server list.
*
* @param inst instance handle
*/
void NT_Disconnect(NT_Inst inst);
/**
* Starts requesting server address from Driver Station.
* This connects to the Driver Station running on localhost to obtain the

View File

@@ -1087,6 +1087,14 @@ void SetServer(
*/
void SetServerTeam(NT_Inst inst, unsigned int team, unsigned int port);
/**
* Disconnects the client if it's running and connected. This will automatically
* start reconnection attempts to the current server list.
*
* @param inst instance handle
*/
void Disconnect(NT_Inst inst);
/**
* Starts requesting server address from Driver Station.
* This connects to the Driver Station running on localhost to obtain the