Add some logging for voice chat updates.

This commit is contained in:
John Preston 2021-03-18 15:22:55 +04:00
parent decbbb9a73
commit 2f75e6bbe2

View file

@ -176,8 +176,16 @@ void GroupCall::enqueueUpdate(const MTPUpdate &update) {
updateData.vcall().match([&](const MTPDgroupCall &data) { updateData.vcall().match([&](const MTPDgroupCall &data) {
const auto version = data.vversion().v; const auto version = data.vversion().v;
if (!_version || _version == version) { if (!_version || _version == version) {
DEBUG_LOG(("Group Call Participants: "
"Apply updateGroupCall %1 -> %2"
).arg(_version
).arg(version));
applyUpdate(update); applyUpdate(update);
} else if (_version < version) { } else if (_version < version) {
DEBUG_LOG(("Group Call Participants: "
"Queue updateGroupCall %1 -> %2"
).arg(_version
).arg(version));
_queuedUpdates.emplace(std::pair{ version, false }, update); _queuedUpdates.emplace(std::pair{ version, false }, update);
} }
}, [&](const MTPDgroupCallDiscarded &data) { }, [&](const MTPDgroupCallDiscarded &data) {
@ -196,8 +204,17 @@ void GroupCall::enqueueUpdate(const MTPUpdate &update) {
proj); proj);
const auto required = increment ? (version - 1) : version; const auto required = increment ? (version - 1) : version;
if (_version == required) { if (_version == required) {
DEBUG_LOG(("Group Call Participants: "
"Apply updateGroupCallParticipant %1 (%2)"
).arg(_version
).arg(Logs::b(increment)));
applyUpdate(update); applyUpdate(update);
} else if (_version < required) { } else if (_version < required) {
DEBUG_LOG(("Group Call Participants: "
"Queue updateGroupCallParticipant %1 -> %2 (%3)"
).arg(_version
).arg(version
).arg(Logs::b(increment)));
_queuedUpdates.emplace(std::pair{ version, increment }, update); _queuedUpdates.emplace(std::pair{ version, increment }, update);
} }
}, [](const auto &) { }, [](const auto &) {
@ -255,6 +272,10 @@ void GroupCall::processFullCall(const MTPphone_GroupCall &call) {
} }
void GroupCall::applyCallFields(const MTPDgroupCall &data) { void GroupCall::applyCallFields(const MTPDgroupCall &data) {
DEBUG_LOG(("Group Call Participants: "
"Set from groupCall %1 -> %2"
).arg(_version
).arg(data.vversion().v));
_version = data.vversion().v; _version = data.vversion().v;
if (!_version) { if (!_version) {
LOG(("API Error: Got zero version in groupCall.")); LOG(("API Error: Got zero version in groupCall."));
@ -288,6 +309,10 @@ void GroupCall::applyUpdate(const MTPUpdate &update) {
discard(); discard();
}); });
}, [&](const MTPDupdateGroupCallParticipants &data) { }, [&](const MTPDupdateGroupCallParticipants &data) {
DEBUG_LOG(("Group Call Participants: "
"Set from updateGroupCallParticipants %1 -> %2"
).arg(_version
).arg(data.vversion().v));
_version = data.vversion().v; _version = data.vversion().v;
if (!_version) { if (!_version) {
LOG(("API Error: " LOG(("API Error: "
@ -328,12 +353,7 @@ void GroupCall::processQueuedUpdates() {
} }
} }
if (_queuedUpdates.empty()) { if (_queuedUpdates.empty()) {
const auto server = _serverParticipantsCount; _reloadByQueuedUpdatesTimer.cancel();
const auto local = int(_participants.size());
if (server < local
|| (_allParticipantsLoaded && server > local)) {
reload();
}
} else if (_queuedUpdates.size() != size } else if (_queuedUpdates.size() != size
|| !_reloadByQueuedUpdatesTimer.isActive()) { || !_reloadByQueuedUpdatesTimer.isActive()) {
_reloadByQueuedUpdatesTimer.callOnce(kWaitForUpdatesTimeout); _reloadByQueuedUpdatesTimer.callOnce(kWaitForUpdatesTimeout);
@ -354,6 +374,10 @@ void GroupCall::reload() {
_participantsRequestId = 0; _participantsRequestId = 0;
} }
DEBUG_LOG(("Group Call Participants: "
"Reloading with queued: %1"
).arg(_queuedUpdates.size()));
_queuedUpdates.clear(); _queuedUpdates.clear();
_reloadByQueuedUpdatesTimer.cancel(); _reloadByQueuedUpdatesTimer.cancel();