MCPcopy Create free account
hub / github.com/MayaPosch/NymphCast / sendGlobalStatusUpdate

Function sendGlobalStatusUpdate

src/server/NymphCastServer.cpp:357–391  ·  view source on GitHub ↗

--- SEND GLOBAL STATUS UPDATE --- Send playback status update to all connected clients.

Source from the content-addressed store, hash-verified

355// --- SEND GLOBAL STATUS UPDATE ---
356// Send playback status update to all connected clients.
357void 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 ---

Callers 9

session_dataFunction · 0.70
volume_setFunction · 0.70
volume_muteFunction · 0.70
playback_startFunction · 0.70
playback_pauseFunction · 0.70
subtitles_setFunction · 0.70
runMethod · 0.70
read_threadMethod · 0.50
runMethod · 0.50

Calls 6

formatFunction · 0.85
getPlaybackStatusFunction · 0.85
push_backMethod · 0.80
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected