@@ -393,6 +393,9 @@ export function MatrixClient(opts) {
393393 this . _clientWellKnown = undefined ;
394394 this . _clientWellKnownPromise = undefined ;
395395
396+ this . _turnServers = [ ] ;
397+ this . _turnServersExpiry = null ;
398+
396399 // The SDK doesn't really provide a clean way for events to recalculate the push
397400 // actions for themselves, so we have to kinda help them out when they are encrypted.
398401 // We do this so that push rules are correctly executed on events in their decrypted
@@ -4942,6 +4945,15 @@ MatrixClient.prototype.getTurnServers = function() {
49424945 return this . _turnServers || [ ] ;
49434946} ;
49444947
4948+ /**
4949+ * Get the unix timestamp (in seconds) at which the current
4950+ * TURN credentials (from getTurnServers) expire
4951+ * @return {number } The expiry timestamp, in seconds, or null if no credentials
4952+ */
4953+ MatrixClient . prototype . getTurnServersExpiry = function ( ) {
4954+ return this . _turnServersExpiry ;
4955+ } ;
4956+
49454957/**
49464958 * Set whether to allow a fallback ICE server should be used for negotiating a
49474959 * WebRTC connection if the homeserver doesn't provide any servers. Defaults to
@@ -5437,6 +5449,7 @@ function checkTurnServers(client) {
54375449 credential : res . password ,
54385450 } ;
54395451 client . _turnServers = [ servers ] ;
5452+ client . _turnServersExpiry = Date . now ( ) + res . ttl ;
54405453 // re-fetch when we're about to reach the TTL
54415454 client . _checkTurnServersTimeoutID = setTimeout ( ( ) => {
54425455 checkTurnServers ( client ) ;
0 commit comments