Skip to content
This repository has been archived by the owner on Oct 25, 2024. It is now read-only.

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

Open
dragon8609 opened this issue Feb 16, 2023 · 0 comments
Open

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

dragon8609 opened this issue Feb 16, 2023 · 0 comments

Comments

@dragon8609
Copy link

dragon8609 commented Feb 16, 2023

void ConferenceSocketSignalingChannel::OnReconnectionTicket(
const std::string& ticket) {
RTC_LOG(LS_VERBOSE) << "On reconnection ticket: " << ticket;
reconnection_ticket_ = 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(reconnection_ticket_, 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?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant