C++ NetworkTable: Provide SetPort() method.

This was previously only available in Java.
This commit is contained in:
Peter Johnson
2015-09-19 11:44:14 -07:00
parent 23448c8277
commit 90ce262bb3
2 changed files with 12 additions and 2 deletions

View File

@@ -13,13 +13,14 @@ std::string NetworkTable::s_ip_address;
std::string NetworkTable::s_persistent_filename = "networktables.ini";
bool NetworkTable::s_client = false;
bool NetworkTable::s_running = false;
unsigned int NetworkTable::s_port = NT_DEFAULT_PORT;
void NetworkTable::Initialize() {
if (s_running) Shutdown();
if (s_client)
nt::StartClient(s_ip_address.c_str(), NT_DEFAULT_PORT);
nt::StartClient(s_ip_address.c_str(), s_port);
else
nt::StartServer(s_persistent_filename, "", NT_DEFAULT_PORT);
nt::StartServer(s_persistent_filename, "", s_port);
s_running = true;
}
@@ -48,6 +49,8 @@ void NetworkTable::SetTeam(int team) {
void NetworkTable::SetIPAddress(StringRef address) { s_ip_address = address; }
void NetworkTable::SetPort(unsigned int port) { s_port = port; }
void NetworkTable::SetPersistentFilename(StringRef filename) {
s_persistent_filename = filename;
}