Showing the changes to interface/src/scripting/ScreenshareScriptingInterface.cpp (1 of 6 files). Show all
Unified · Split
| @@ -37,14 +37,41 @@ ScreenshareScriptingInterface::ScreenshareScriptingInterface() { · 36 unmodified lines | ||
| 37 | 37 | _requestScreenshareInfoRetryTimer->setSingleShot(true); |
| 38 | 38 | _requestScreenshareInfoRetryTimer->setInterval(SCREENSHARE_INFO_REQUEST_RETRY_TIMEOUT_MS); |
| 39 | 39 | connect(_requestScreenshareInfoRetryTimer, &QTimer::timeout, this, &ScreenshareScriptingInterface::requestScreenshareInfo); |
| 40 | + | |
| 41 | + auto nodeList = DependencyManager::get<NodeList>(); | |
| 42 | + PacketReceiver& packetReceiver = nodeList->getPacketReceiver(); | |
| 43 | + packetReceiver.registerListener(PacketType::AvatarZonePresence, this, "processAvatarZonePresencePacketOnClient"); | |
| 40 | 44 | }; |
| 41 | 45 | |
| 42 | 46 | ScreenshareScriptingInterface::~ScreenshareScriptingInterface() { |
| 43 | 47 | stopScreenshare(); |
| 44 | 48 | } |
| 45 | 49 | |
| 50 | +void ScreenshareScriptingInterface::processAvatarZonePresencePacketOnClient(QSharedPointer<ReceivedMessage> message, SharedNodePointer senderNode) { | |
| 51 | + QUuid zone = QUuid::fromRfc4122(message->readWithoutCopy(NUM_BYTES_RFC4122_UUID)); | |
| 52 | + | |
| 53 | + if (zone.isNull()) { | |
| 54 | + qWarning() << "Ignoring avatar zone presence packet that doesn't specify a zone."; | |
| 55 | + return; | |
| 56 | + } | |
| 57 | + | |
| 58 | + _lastAuthorizedZoneID = zone; | |
| 59 | + | |
| 60 | + if (_waitingForAuthorization) { | |
| 61 | + requestScreenshareInfo(); | |
| 62 | + } | |
| 63 | +} | |
| 64 | + | |
| 46 | 65 | static const int MAX_NUM_SCREENSHARE_INFO_REQUEST_RETRIES = 5; |
| 47 | 66 | void ScreenshareScriptingInterface::requestScreenshareInfo() { |
| 67 | + if (_screenshareZoneID != _lastAuthorizedZoneID) { | |
| 68 | + qDebug() << "Client not yet authorized to screenshare. Waiting for authorization message from domain server..."; | |
| 69 | + _waitingForAuthorization = true; | |
| 70 | + return; | |
| 71 | + } | |
| 72 | + | |
| 73 | + _waitingForAuthorization = false; | |
| 74 | + | |
| 48 | 75 | _requestScreenshareInfoRetries++; |
| 49 | 76 | |
| 50 | 77 | if (_requestScreenshareInfoRetries >= MAX_NUM_SCREENSHARE_INFO_REQUEST_RETRIES) { |
| @@ -174,6 +201,7 @@ void ScreenshareScriptingInterface::stopScreenshare() { · 123 unmodified lines | ||
| 174 | 201 | _projectAPIKey = ""; |
| 175 | 202 | _sessionID = ""; |
| 176 | 203 | _isPresenter = false; |
| 204 | + _waitingForAuthorization = false; | |
| 177 | 205 | } |
| 178 | 206 | |
| 179 | 207 | // Called when the Metaverse returns the information necessary to start/view a screen share. |