History

Slight optimization; comments

Zach Fox committed 6 years ago

Commit 2b7d66c1 parent 04fe2983 files · +30 −17Browse files

Showing the changes to interface/src/scripting/ScreenshareScriptingInterface.cpp (1 of 3 files). Show all

Unified · Split

interface/src/scripting/ScreenshareScriptingInterface.cpp+7−0
@@ -39,6 +39,7 @@ ScreenshareScriptingInterface::ScreenshareScriptingInterface() { · 38 unmodified lines
3939 _requestScreenshareInfoRetryTimer->setInterval(SCREENSHARE_INFO_REQUEST_RETRY_TIMEOUT_MS);
4040 connect(_requestScreenshareInfoRetryTimer, &QTimer::timeout, this, &ScreenshareScriptingInterface::requestScreenshareInfo);
4141
42+ // This packet listener handles the packet containing information about the latest zone ID in which we are allowed to share.
4243 auto nodeList = DependencyManager::get<NodeList>();
4344 PacketReceiver& packetReceiver = nodeList->getPacketReceiver();
4445 packetReceiver.registerListener(PacketType::AvatarZonePresence, this, "processAvatarZonePresencePacketOnClient");
@@ -56,8 +57,11 @@ void ScreenshareScriptingInterface::processAvatarZonePresencePacketOnClient(QSha · 11 unmodified lines
5657 return;
5758 }
5859
60+ // Set the last known authorized screenshare zone ID to the zone that the Domain Server just told us about.
5961 _lastAuthorizedZoneID = zone;
6062
63+ // If we had previously started the screenshare process but knew that we weren't going to be authorized to screenshare,
64+ // let's continue the screenshare process here.
6165 if (_waitingForAuthorization) {
6266 requestScreenshareInfo();
6367 }
@@ -65,6 +69,9 @@ void ScreenshareScriptingInterface::processAvatarZonePresencePacketOnClient(QSha · 1 unmodified line
6569
6670 static const int MAX_NUM_SCREENSHARE_INFO_REQUEST_RETRIES = 5;
6771 void ScreenshareScriptingInterface::requestScreenshareInfo() {
72+ // If the screenshare zone that we're currently in (i.e. `startScreenshare()` was called) is different from
73+ // the zone in which we are authorized to screenshare...
74+ // ...return early here and wait for the DS to send us a packet containing this zone's ID.
6875 if (_screenshareZoneID != _lastAuthorizedZoneID) {
6976 qDebug() << "Client not yet authorized to screenshare. Waiting for authorization message from domain server...";
7077 _waitingForAuthorization = true;