mirror of
https://github.com/badaix/snapcast.git
synced 2025-05-20 20:46:16 +02:00
rename client ID to host ID
This commit is contained in:
parent
81f46ff41f
commit
acd70148fe
3 changed files with 11 additions and 10 deletions
|
@ -34,8 +34,8 @@
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
|
||||||
Controller::Controller(const std::string& clientId, size_t instance) : MessageReceiver(),
|
Controller::Controller(const std::string& hostId, size_t instance) : MessageReceiver(),
|
||||||
clientId_(clientId),
|
hostId_(hostId),
|
||||||
instance_(instance),
|
instance_(instance),
|
||||||
active_(false),
|
active_(false),
|
||||||
latency_(0),
|
latency_(0),
|
||||||
|
@ -177,6 +177,10 @@ void Controller::worker()
|
||||||
{
|
{
|
||||||
active_ = true;
|
active_ = true;
|
||||||
|
|
||||||
|
string macAddress = clientConnection_->getMacAddress();
|
||||||
|
if (hostId_.empty())
|
||||||
|
hostId_ = ::getHostId(macAddress);
|
||||||
|
|
||||||
while (active_)
|
while (active_)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -184,10 +188,7 @@ void Controller::worker()
|
||||||
clientConnection_->start();
|
clientConnection_->start();
|
||||||
|
|
||||||
/// Say hello to the server
|
/// Say hello to the server
|
||||||
string macAddress = clientConnection_->getMacAddress();
|
msg::Hello hello(macAddress, hostId_, instance_);
|
||||||
if (clientId_.empty())
|
|
||||||
clientId_ = ::getHostId(macAddress);
|
|
||||||
msg::Hello hello(macAddress, clientId_, instance_);
|
|
||||||
clientConnection_->send(&hello);
|
clientConnection_->send(&hello);
|
||||||
|
|
||||||
/// Do initial time sync with the server
|
/// Do initial time sync with the server
|
||||||
|
|
|
@ -61,7 +61,7 @@ public:
|
||||||
private:
|
private:
|
||||||
void worker();
|
void worker();
|
||||||
bool sendTimeSyncMessage(long after = 1000);
|
bool sendTimeSyncMessage(long after = 1000);
|
||||||
std::string clientId_;
|
std::string hostId_;
|
||||||
size_t instance_;
|
size_t instance_;
|
||||||
std::atomic<bool> active_;
|
std::atomic<bool> active_;
|
||||||
std::thread controllerThread_;
|
std::thread controllerThread_;
|
||||||
|
|
|
@ -89,7 +89,7 @@ int main (int argc, char **argv)
|
||||||
Implicit<int> daemonOption("d", "daemon", "daemonize, optional process priority [-20..19]", -3, &processPriority);
|
Implicit<int> daemonOption("d", "daemon", "daemonize, optional process priority [-20..19]", -3, &processPriority);
|
||||||
Value<int> latencyValue("", "latency", "latency of the soundcard", 0, &latency);
|
Value<int> latencyValue("", "latency", "latency of the soundcard", 0, &latency);
|
||||||
Value<size_t> instanceValue("i", "instance", "instance id", 1, &instance);
|
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");
|
Value<string> userValue("", "user", "the user[:group] to run snapclient as when daemonized");
|
||||||
|
|
||||||
OptionParser op("Allowed options");
|
OptionParser op("Allowed options");
|
||||||
|
@ -106,7 +106,7 @@ int main (int argc, char **argv)
|
||||||
.add(userValue)
|
.add(userValue)
|
||||||
#endif
|
#endif
|
||||||
.add(latencyValue)
|
.add(latencyValue)
|
||||||
.add(clientIdValue)
|
.add(hostIdValue)
|
||||||
.add(instanceValue);
|
.add(instanceValue);
|
||||||
|
|
||||||
try
|
try
|
||||||
|
@ -224,7 +224,7 @@ int main (int argc, char **argv)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<Controller> controller(new Controller(clientIdValue.getValue(), instance));
|
std::unique_ptr<Controller> controller(new Controller(hostIdValue.getValue(), instance));
|
||||||
if (!g_terminated)
|
if (!g_terminated)
|
||||||
{
|
{
|
||||||
logO << "Latency: " << latency << "\n";
|
logO << "Latency: " << latency << "\n";
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue