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 | _requestScreenshareInfoRetryTimer->setSingleShot(true); | 37 | _requestScreenshareInfoRetryTimer->setSingleShot(true); |
| 38 | _requestScreenshareInfoRetryTimer->setInterval(SCREENSHARE_INFO_REQUEST_RETRY_TIMEOUT_MS); | 38 | _requestScreenshareInfoRetryTimer->setInterval(SCREENSHARE_INFO_REQUEST_RETRY_TIMEOUT_MS); |
| 39 | connect(_requestScreenshareInfoRetryTimer, &QTimer::timeout, this, &ScreenshareScriptingInterface::requestScreenshareInfo); | 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 | ScreenshareScriptingInterface::~ScreenshareScriptingInterface() { | 46 | ScreenshareScriptingInterface::~ScreenshareScriptingInterface() { |
| 43 | stopScreenshare(); | 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 | static const int MAX_NUM_SCREENSHARE_INFO_REQUEST_RETRIES = 5; | 65 | static const int MAX_NUM_SCREENSHARE_INFO_REQUEST_RETRIES = 5; |
| 47 | void ScreenshareScriptingInterface::requestScreenshareInfo() { | 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 | _requestScreenshareInfoRetries++; | 75 | _requestScreenshareInfoRetries++; |
| 49 | 76 | ||
| 50 | if (_requestScreenshareInfoRetries >= MAX_NUM_SCREENSHARE_INFO_REQUEST_RETRIES) { | 77 | if (_requestScreenshareInfoRetries >= MAX_NUM_SCREENSHARE_INFO_REQUEST_RETRIES) { |
| @@ -174,6 +201,7 @@ void ScreenshareScriptingInterface::stopScreenshare() { · 123 unmodified lines | |||
| 174 | _projectAPIKey = ""; | 201 | _projectAPIKey = ""; |
| 175 | _sessionID = ""; | 202 | _sessionID = ""; |
| 176 | _isPresenter = false; | 203 | _isPresenter = false; |
| 204 | _waitingForAuthorization = false; | ||
| 177 | } | 205 | } |
| 178 | 206 | ||
| 179 | // Called when the Metaverse returns the information necessary to start/view a screen share. | 207 | // Called when the Metaverse returns the information necessary to start/view a screen share. |