| 432 | }; |
| 433 | |
| 434 | LuxController::LuxController(struct event_base* _base, const std::string& _target): |
| 435 | base(_base), |
| 436 | target(_target), conn(base), reconnect(true), reconnect_ev(0), |
| 437 | reconnect_timeout(RECONNECT_TIMEOUT_START) |
| 438 | { |
| 439 | reconnect_ev = event_new(base, -1, 0, reconnect_cb, this); |
| 440 | if (!reconnect_ev) |
| 441 | LogPrintf("lux: Failed to create event for reconnection: out of memory?\n"); |
| 442 | // Start connection attempts immediately |
| 443 | if (!conn.Connect(_target, boost::bind(&LuxController::connected_cb, this, _1), |
| 444 | boost::bind(&LuxController::disconnected_cb, this, _1) )) { |
| 445 | LogPrintf("lux: Initiating connection to Lux control port %s failed\n", _target); |
| 446 | } |
| 447 | // Read service private key if cached |
| 448 | std::pair<bool,std::string> pkf = ReadBinaryFile(GetPrivateKeyFile()); |
| 449 | if (pkf.first) { |
| 450 | LogPrint("lux", "lux: Reading cached private key from %s\n", GetPrivateKeyFile()); |
| 451 | private_key = pkf.second; |
| 452 | } |
| 453 | } |
| 454 | |
| 455 | LuxController::~LuxController() |
| 456 | { |
nothing calls this directly
no test coverage detected