--- SEND GLOBAL STATUS UPDATE --- Send playback status update to all connected clients.
| 355 | // --- SEND GLOBAL STATUS UPDATE --- |
| 356 | // Send playback status update to all connected clients. |
| 357 | void sendGlobalStatusUpdate() { |
| 358 | NYMPH_LOG_INFORMATION("Sending status update to all " + Poco::NumberFormatter::format(clients.size()) |
| 359 | + " clients."); |
| 360 | |
| 361 | std::map<std::string, NymphPair>* pairs = getPlaybackStatus(); |
| 362 | std::map<int, CastClient>::const_iterator it; |
| 363 | for (it = clients.begin(); it != clients.end();/**/) { |
| 364 | NYMPH_LOG_DEBUG("Client ID: " + Poco::NumberFormatter::format(it->first) + "/" + it->second.name); |
| 365 | |
| 366 | // Call the status update callback with the current playback status. |
| 367 | NymphType* resVal = 0; |
| 368 | std::string result; |
| 369 | std::vector<NymphType*> values; |
| 370 | values.push_back(new NymphType(pairs)); |
| 371 | if (!NymphRemoteClient::callCallback(it->first, "MediaStatusCallback", values, result)) { |
| 372 | NYMPH_LOG_ERROR("Calling media status callback failed: " + result); |
| 373 | |
| 374 | // An error here very likely means that the client no long exists. Remove it. |
| 375 | it = clients.erase(it); |
| 376 | } |
| 377 | else { |
| 378 | ++it; |
| 379 | } |
| 380 | } |
| 381 | |
| 382 | // Delete the map and its values. |
| 383 | // TODO: persist the data somehow. |
| 384 | std::map<std::string, NymphPair>::iterator sit; |
| 385 | for (sit = pairs->begin(); sit != pairs->end(); ++sit) { |
| 386 | delete sit->second.key; |
| 387 | delete sit->second.value; |
| 388 | } |
| 389 | |
| 390 | delete pairs; |
| 391 | } |
| 392 | |
| 393 | |
| 394 | // --- DATA REQUEST HANDLER --- |
no test coverage detected