rename client ID to host ID

This commit is contained in:
badaix 2017-06-08 08:14:49 +02:00
parent 81f46ff41f
commit acd70148fe
3 changed files with 11 additions and 10 deletions

View file

@ -34,8 +34,8 @@
using namespace std;
Controller::Controller(const std::string& clientId, size_t instance) : MessageReceiver(),
clientId_(clientId),
Controller::Controller(const std::string& hostId, size_t instance) : MessageReceiver(),
hostId_(hostId),
instance_(instance),
active_(false),
latency_(0),
@ -177,6 +177,10 @@ void Controller::worker()
{
active_ = true;
string macAddress = clientConnection_->getMacAddress();
if (hostId_.empty())
hostId_ = ::getHostId(macAddress);
while (active_)
{
try
@ -184,10 +188,7 @@ void Controller::worker()
clientConnection_->start();
/// Say hello to the server
string macAddress = clientConnection_->getMacAddress();
if (clientId_.empty())
clientId_ = ::getHostId(macAddress);
msg::Hello hello(macAddress, clientId_, instance_);
msg::Hello hello(macAddress, hostId_, instance_);
clientConnection_->send(&hello);
/// Do initial time sync with the server

View file

@ -61,7 +61,7 @@ public:
private:
void worker();
bool sendTimeSyncMessage(long after = 1000);
std::string clientId_;
std::string hostId_;
size_t instance_;
std::atomic<bool> active_;
std::thread controllerThread_;

View file

@ -89,7 +89,7 @@ int main (int argc, char **argv)
Implicit<int> daemonOption("d", "daemon", "daemonize, optional process priority [-20..19]", -3, &processPriority);
Value<int> latencyValue("", "latency", "latency of the soundcard", 0, &latency);
Value<size_t> instanceValue("i", "instance", "instance id", 1, &instance);
Value<string> clientIdValue("", "clientID", "unique client id", "");
Value<string> hostIdValue("", "hostID", "unique host id", "");
Value<string> userValue("", "user", "the user[:group] to run snapclient as when daemonized");
OptionParser op("Allowed options");
@ -106,7 +106,7 @@ int main (int argc, char **argv)
.add(userValue)
#endif
.add(latencyValue)
.add(clientIdValue)
.add(hostIdValue)
.add(instanceValue);
try
@ -224,7 +224,7 @@ int main (int argc, char **argv)
#endif
}
std::unique_ptr<Controller> controller(new Controller(clientIdValue.getValue(), instance));
std::unique_ptr<Controller> controller(new Controller(hostIdValue.getValue(), instance));
if (!g_terminated)
{
logO << "Latency: " << latency << "\n";