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
39 _requestScreenshareInfoRetryTimer->setInterval(SCREENSHARE_INFO_REQUEST_RETRY_TIMEOUT_MS);39 _requestScreenshareInfoRetryTimer->setInterval(SCREENSHARE_INFO_REQUEST_RETRY_TIMEOUT_MS);
40 connect(_requestScreenshareInfoRetryTimer, &QTimer::timeout, this, &ScreenshareScriptingInterface::requestScreenshareInfo);40 connect(_requestScreenshareInfoRetryTimer, &QTimer::timeout, this, &ScreenshareScriptingInterface::requestScreenshareInfo);
41 41
42 // This packet listener handles the packet containing information about the latest zone ID in which we are allowed to share.
42 auto nodeList = DependencyManager::get<NodeList>();43 auto nodeList = DependencyManager::get<NodeList>();
43 PacketReceiver& packetReceiver = nodeList->getPacketReceiver();44 PacketReceiver& packetReceiver = nodeList->getPacketReceiver();
44 packetReceiver.registerListener(PacketType::AvatarZonePresence, this, "processAvatarZonePresencePacketOnClient");45 packetReceiver.registerListener(PacketType::AvatarZonePresence, this, "processAvatarZonePresencePacketOnClient");
@@ -56,8 +57,11 @@ void ScreenshareScriptingInterface::processAvatarZonePresencePacketOnClient(QSha · 11 unmodified lines
56 return;57 return;
57 }58 }
58 59
60 // Set the last known authorized screenshare zone ID to the zone that the Domain Server just told us about.
59 _lastAuthorizedZoneID = zone;61 _lastAuthorizedZoneID = zone;
60 62
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.
61 if (_waitingForAuthorization) {65 if (_waitingForAuthorization) {
62 requestScreenshareInfo();66 requestScreenshareInfo();
63 }67 }
@@ -65,6 +69,9 @@ void ScreenshareScriptingInterface::processAvatarZonePresencePacketOnClient(QSha · 1 unmodified line
65 69
66static const int MAX_NUM_SCREENSHARE_INFO_REQUEST_RETRIES = 5;70static const int MAX_NUM_SCREENSHARE_INFO_REQUEST_RETRIES = 5;
67void ScreenshareScriptingInterface::requestScreenshareInfo() {71void 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.
68 if (_screenshareZoneID != _lastAuthorizedZoneID) {75 if (_screenshareZoneID != _lastAuthorizedZoneID) {
69 qDebug() << "Client not yet authorized to screenshare. Waiting for authorization message from domain server...";76 qDebug() << "Client not yet authorized to screenshare. Waiting for authorization message from domain server...";
70 _waitingForAuthorization = true;77 _waitingForAuthorization = true;