open-webrtc-toolkit / owt-client-native

Open WebRTC Toolkit client SDK for native Windows/Linux/iOS applications.
https://01.org/open-webrtc-toolkit
Apache License 2.0
384 stars 180 forks source link

rtc::TimeMillis or rtc::TimeUTCMillis ? #688

Open dragon8609 opened 1 year ago

dragon8609 commented 1 year ago

void ConferenceSocketSignalingChannel::OnReconnectionTicket( const std::string& ticket) { RTC_LOG(LS_VERBOSE) << "On reconnection ticket: " << ticket; reconnectionticket = ticket; uint64_t now(0); // rtc::TimeMillis() seems not work well on iOS. It returns half of the actual // value on iPhone 6.

if defined(WEBRTC_IOS)

now = CFAbsoluteTimeGetCurrent(); now += kMachLinuxTimeDelta; now *= 1000;

else

now = rtc::TimeMillis();

endif

std::string ticket_decoded( rtc::Base64::Decode(reconnectionticket, rtc::Base64::DO_STRICT)); Json::Value ticket_json; Json::Reader ticket_reader; if (!ticket_reader.parse(ticket_decoded, ticket_json)) { RTC_NOTREACHED(); RTC_LOG(LS_WARNING) << "Cannot parse reconnection ticket."; return; } Json::Value expiration_json; std::string expiration_str; if (rtc::GetValueFromJsonObject(ticket_json, "notAfter", &expiration_json)) { expiration_str = expiration_json.asString(); auto expiration_time = std::stoll(expiration_str); int delay(expiration_time - now); if (delay < 0) { RTC_LOG(LS_WARNING) << "Reconnection ticket expiration time is earlier than now."; delay = 5 60 1000; // Set delay to 5 mins. } RTC_LOG(LS_VERBOSE) << "Reconnection ticket will expire in: " << delay / 1000 << "seconds"; std::weak_ptr weak_this = shared_from_this(); std::thread([weak_this, delay]() { std::this_thread::sleep_for(std::chrono::milliseconds(delay)); auto that = weak_this.lock(); if (!that) { return; } that->RefreshReconnectionTicket(); }).detach(); } }

in ConferenceSocketSignalingChannel::OnReconnectionTicket now = rtc::TimeMillis(); return the time is not utc time but the notAfter is utc time.

{"participantId":"gJamTJBczCTb9wsIAAAD","ticketId":"acif9iqe8rm","notBefore":1676448122238,"notAfter":1676448722238,"signature":"YmI5YTliZDY4MzY0YWNkYmU4ZWU3NjJiYjE4ZDI0Nzg3OWNlMjhiYTAzODNlMDU0YTZlZDAwOGM3ZG......."}

So is this a bug?